parent
a50e1fb99b
commit
04789fd327
|
|
@ -46,7 +46,7 @@ public class DatasetsTest extends DatasetsVerifier {
|
|||
@Parameterized.Parameters(name = "Dataset {0}")
|
||||
public static Collection<String> data() {
|
||||
return Arrays.asList(new String[]{
|
||||
"/datasets/org/libreccm/modules/ConfigurationLoaderTest/after-load.yml",});
|
||||
"/datasets/org/libreccm/modules/ConfigurationLoaderTest/after-load.x,l",});
|
||||
}
|
||||
|
||||
public DatasetsTest(final String datasetPath) {
|
||||
|
|
@ -60,7 +60,7 @@ public class DatasetsTest extends DatasetsVerifier {
|
|||
|
||||
@Override
|
||||
public DatasetType getDatasetType() {
|
||||
return YAML;
|
||||
return FLAT_XML;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
-- create schema CCM_CORE;
|
||||
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
create table CCM_CORE.APPLICATIONS (
|
||||
APPLICATION_TYPE varchar(1024) not null,
|
||||
PRIMARY_URL varchar(1024) not null,
|
||||
OBJECT_ID bigint not null,
|
||||
|
|
@ -148,7 +148,7 @@
|
|||
|
||||
create table CCM_CORE.FORMBUILDER_DATA_QUERIES (
|
||||
DESCRIPTION json,
|
||||
NAME json,
|
||||
QUERY_NAME json,
|
||||
QUERY_ID varchar(255),
|
||||
OBJECT_ID bigint not null,
|
||||
primary key (OBJECT_ID)
|
||||
|
|
@ -194,7 +194,7 @@
|
|||
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENERS (
|
||||
DESCRIPTION json,
|
||||
LISTENER_CLASS varchar(255),
|
||||
NAME json,
|
||||
LISTENER_NAME json,
|
||||
PROCESS_LISTENER_ORDER bigint,
|
||||
OBJECT_ID bigint not null,
|
||||
formSection_OBJECT_ID bigint,
|
||||
|
|
@ -452,12 +452,12 @@
|
|||
SETTING_ID bigint not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
SETTING_VALUE json,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_LONG bigint,
|
||||
SETTING_VALUE_LOCALIZED_STRING json,
|
||||
SETTING_VALUE_DOUBLE double,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -446,12 +446,12 @@
|
|||
SETTING_ID int8 not null,
|
||||
CONFIGURATION_CLASS varchar(512) not null,
|
||||
NAME varchar(512) not null,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
SETTING_VALUE_LOCALIZED_STRING jsonb,
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
SETTING_VALUE_LONG int8,
|
||||
SETTING_VALUE_LOCALIZED_STRING jsonb,
|
||||
SETTING_VALUE_DOUBLE float8,
|
||||
SETTING_VALUE_STRING varchar(1024),
|
||||
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
|
||||
SETTING_VALUE_BOOLEAN boolean,
|
||||
primary key (SETTING_ID)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<ccm_core.settings
|
||||
dtype="LocalizedStringSetting"
|
||||
setting_id="120"
|
||||
configuration_class="org.libreccm.configuration.ExampleConfiguration"
|
||||
name="title"
|
||||
setting_value_localized_string="{'de': 'Versuch', 'en': 'Test'}"
|
||||
/>
|
||||
<ccm_core.settings
|
||||
dtype="BooleanSetting"
|
||||
setting_id="100"
|
||||
configuration_class="org.libreccm.configuration.ExampleConfiguration"
|
||||
name="enabled"
|
||||
setting_value_boolean="true"
|
||||
/>
|
||||
<ccm_core.settings
|
||||
dtype="LongSetting"
|
||||
setting_id="110"
|
||||
configuration_class="org.libreccm.configuration.ExampleConfiguration"
|
||||
name="itemsPerPage"
|
||||
setting_value_long="100"
|
||||
/>
|
||||
</dataset>
|
||||
|
|
@ -1,23 +1,31 @@
|
|||
ccm_core.settings:
|
||||
- setting_id: 100
|
||||
- dtype: LocalizedStringSetting
|
||||
setting_id: 120
|
||||
configuration_class: org.libreccm.configuration.ExampleConfiguration
|
||||
name: title
|
||||
setting_value_long: null
|
||||
setting_value_localized_string: "{\"de\": \"Versuch\", \"en\": \"Test\"}"
|
||||
setting_value_double: null
|
||||
setting_value_string: null
|
||||
setting_value_big_decimal: null
|
||||
setting_value_boolean: null
|
||||
- dtype: BooleanSetting
|
||||
setting_id: 100
|
||||
configuration_class: org.libreccm.configuration.ExampleConfiguration
|
||||
name: enabled
|
||||
setting_value_long: null
|
||||
setting_value_localized_string: null
|
||||
setting_value_double: null
|
||||
setting_value_string: null
|
||||
setting_value_big_decimal: null
|
||||
setting_value_boolean: true
|
||||
dtype: BooleanSetting
|
||||
- setting_id: 110
|
||||
- dtype: LongSetting
|
||||
setting_id: 110
|
||||
configuration_class: org.libreccm.configuration.ExampleConfiguration
|
||||
name: itemsPerPage
|
||||
setting_value_long: 100
|
||||
dtype: LongSetting
|
||||
- setting_id: 120
|
||||
configuration_class: org.libreccm.configuration.ExampleConfiguration
|
||||
name: title
|
||||
dtype: LocalizedStringSetting
|
||||
ccm_core.settings_l10n_str_values:
|
||||
- entry_id: 120
|
||||
locale: de
|
||||
localized_value: Versuch
|
||||
- entry_id: 120
|
||||
locale: en
|
||||
localized_value: Test
|
||||
|
||||
setting_value_localized_string: null
|
||||
setting_value_double: null
|
||||
setting_value_string: null
|
||||
setting_value_big_decimal: null
|
||||
setting_value_boolean: null
|
||||
|
|
|
|||
|
|
@ -42,12 +42,14 @@ import org.junit.runners.Parameterized;
|
|||
|
||||
import static org.libreccm.testutils.DatasetType.*;
|
||||
|
||||
import org.dbunit.database.DatabaseConfig;
|
||||
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
|
||||
import org.jboss.arquillian.persistence.dbunit.dataset.yaml.YamlDataSet;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -75,32 +77,31 @@ import java.nio.charset.StandardCharsets;
|
|||
*/
|
||||
public class DatasetsVerifier {
|
||||
|
||||
private final String datasetPath;
|
||||
private final String datasetPath;
|
||||
|
||||
public DatasetsVerifier(final String datasetsPath) {
|
||||
public DatasetsVerifier(final String datasetsPath) {
|
||||
this.datasetPath = datasetsPath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this method if you are using another schema than the default
|
||||
* one.
|
||||
/**
|
||||
* Overwrite this method if you are using another schema than the default one.
|
||||
*
|
||||
* @return An string array contains the names of the database schemata used
|
||||
* by the datasets the test.
|
||||
* @return An string array contains the names of the database schemata used by
|
||||
* the datasets the test.
|
||||
*/
|
||||
public String[] getSchemas() {
|
||||
public String[] getSchemas() {
|
||||
return new String[]{};
|
||||
}
|
||||
}
|
||||
|
||||
public DatasetType getDatasetType() {
|
||||
public DatasetType getDatasetType() {
|
||||
return JSON;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
|
||||
@Test
|
||||
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
|
||||
value = "DMI_EMPTY_DB_PASSWORD",
|
||||
justification = "H2 in mem database does not need a password")
|
||||
public void verifyDataset() throws SQLException,
|
||||
public void verifyDataset() throws SQLException,
|
||||
URISyntaxException,
|
||||
IOException,
|
||||
DatabaseUnitException {
|
||||
|
|
@ -136,12 +137,44 @@ public class DatasetsVerifier {
|
|||
for (final String ddlFile : getDdlFiles()) {
|
||||
processDdlFile(connection, ddlFile);
|
||||
}
|
||||
|
||||
// final Path schemaPath = Paths.get(getClass().getResource(
|
||||
// "/sql/ddl/auto/h2.sql").toURI());
|
||||
// RunScript.execute(connection, Files.newBufferedReader(
|
||||
// schemaPath, StandardCharsets.UTF_8));
|
||||
connection.commit();
|
||||
|
||||
System.out.println("DB Info:");
|
||||
System.out.println("Catalogs:");
|
||||
try (ResultSet resultSet = connection.getMetaData().getCatalogs()) {
|
||||
while(resultSet.next()) {
|
||||
System.out.println(resultSet.getString("table_cat"));
|
||||
}
|
||||
}
|
||||
System.out.println("Schemas");
|
||||
try(ResultSet resultSet = connection.getMetaData().getSchemas()) {
|
||||
while(resultSet.next()) {
|
||||
System.out.println(resultSet.getString("TABLE_SCHEM"));
|
||||
}
|
||||
}
|
||||
System.out.println("Tables");
|
||||
try (ResultSet resultSet = connection.getMetaData().getTables("TESTDATABASE", "CCM_CORE", null, null)) {
|
||||
while(resultSet.next()) {
|
||||
System.out.println(resultSet.getString("table_name"));
|
||||
}
|
||||
}
|
||||
System.out.println("settings columns:");
|
||||
try (ResultSet resultSet = connection.getMetaData().getColumns(
|
||||
"TESTDATABASE", "CCM_CORE", "SETTINGS", null
|
||||
)) {
|
||||
while (resultSet.next()) {
|
||||
System.out.printf("table_name = %s%n", resultSet.getString(
|
||||
"table_name"));
|
||||
System.out.printf("col_name = %s%n", resultSet.getString(
|
||||
"column_name"));
|
||||
}
|
||||
}
|
||||
|
||||
//Get dataset to test
|
||||
final IDataSet dataSet;
|
||||
try (final InputStream inputStream = getClass().getResourceAsStream(
|
||||
|
|
@ -181,13 +214,13 @@ public class DatasetsVerifier {
|
|||
System.out.println("Dump after loading dataset...");
|
||||
verifyDumping(dbUnitConn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String[] getDdlFiles() {
|
||||
protected String[] getDdlFiles() {
|
||||
return new String[]{"/sql/ddl/auto/libreccmh2.sql"};
|
||||
}
|
||||
}
|
||||
|
||||
private void processDdlFile(final Connection connection,
|
||||
private void processDdlFile(final Connection connection,
|
||||
final String ddlFile) throws URISyntaxException,
|
||||
SQLException,
|
||||
IOException {
|
||||
|
|
@ -196,12 +229,12 @@ public class DatasetsVerifier {
|
|||
RunScript.execute(connection,
|
||||
Files.newBufferedReader(schemaPath,
|
||||
StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyDumping(final IDatabaseConnection connection)
|
||||
private void verifyDumping(final IDatabaseConnection connection)
|
||||
throws SQLException, IOException, DataSetException {
|
||||
final IDataSet data = connection.createDataSet();
|
||||
FlatXmlDataSet.write(data, System.out);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue