use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class MetadataFallbackVerifier method compare.
/**
* Creates a temporary database for comparing {@link MetadataFallback} content with database content.
* This method is provided for allowing to execute this class individually. In a complete Maven build,
* of {@code sis-metadata} module, the test will rather be executed by {@link MetadataSourceTest} for
* opportunistic reasons.
*
* @throws Exception if an exception occurred while creating or comparing the database.
*/
@Test
public void compare() throws Exception {
try (TestDatabase db = TestDatabase.create("MetadataSource");
MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115, db.source, "metadata", null)) {
source.install();
compare(source);
}
}
use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class MetadataWriterTest method testDerby.
/**
* Runs all tests on Derby in the required order.
*
* @throws Exception if an error occurred while writing or reading the database.
*/
@Test
public void testDerby() throws Exception {
try (final TestDatabase db = TestDatabase.create("MetadataWriter")) {
source = new MetadataWriter(MetadataStandard.ISO_19115, db.source, null, null);
try {
write();
search();
read();
readWriteDeprecated();
} finally {
source.close();
}
}
}
use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class MetadataWriterTest method testPostgreSQL.
/**
* Runs all tests on PostgreSQL in the required order. This test is disabled by default
* because it requires manual setup of a test database.
*
* @throws Exception if an error occurred while writing or reading the database.
*/
@Test
@org.junit.Ignore("Requires GeoAPI 3.1.")
public void testPostgreSQL() throws Exception {
try (final TestDatabase db = TestDatabase.createOnPostgreSQL("MetadataWriter", true)) {
source = new MetadataWriter(MetadataStandard.ISO_19115, db.source, "MetadataWriter", null);
try {
write();
search();
read();
readWriteDeprecated();
} finally {
source.close();
}
}
}
use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class IdentifierGeneratorTest method testSequence.
/**
* Tests the creation of identifiers with sequence numbers.
*
* @throws Exception if an error occurred while reading or writing in the temporary database.
*/
@Test
public void testSequence() throws Exception {
try (TestDatabase db = TestDatabase.create("IdentifierGenerator");
MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115, db.source, null, null)) {
synchronized (source) {
stmt = source.connection().createStatement();
stmt.executeUpdate("CREATE TABLE \"" + TABLE + "\" (ID VARCHAR(6) NOT NULL PRIMARY KEY)");
generator = new IdentifierGenerator(source, null, TABLE, "ID", new SQLBuilder(source.connection().getMetaData(), false));
/*
* Actual tests.
*/
addRecords("TD", 324);
removeAndAddRecords("TD");
addRecords("OT", 30);
/*
* Cleaning.
*/
stmt.executeUpdate("DROP TABLE \"" + TABLE + '"');
stmt.close();
generator.close();
source.close();
}
}
}
use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class EPSGInstallerTest method testCreationOnDerby.
/**
* Tests the creation of an EPSG database on Derby.
* This test is skipped if the SQL scripts are not found.
*
* <p>See {@link TestDatabase} javadoc if there is a need to inspect content of that in-memory database.</p>
*
* @throws Exception if an error occurred while creating the database.
*/
@Test
public void testCreationOnDerby() throws Exception {
// Needs to be invoked first.
final InstallationScriptProvider scripts = getScripts();
try (TestDatabase db = TestDatabase.create("EPSGInstaller")) {
createAndTest(db.source, scripts);
verifyParameterValues(db.source);
}
loggings.assertNextLogContains("EPSG", "jdbc:derby:memory:EPSGInstaller");
loggings.assertNoUnexpectedLog();
}
Aggregations