Search in sources :

Example 1 with TestDatabase

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);
    }
}
Also used : TestDatabase(org.apache.sis.test.sql.TestDatabase) Test(org.junit.Test)

Example 2 with TestDatabase

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();
        }
    }
}
Also used : TestDatabase(org.apache.sis.test.sql.TestDatabase) Test(org.junit.Test)

Example 3 with TestDatabase

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();
        }
    }
}
Also used : TestDatabase(org.apache.sis.test.sql.TestDatabase) Test(org.junit.Test)

Example 4 with TestDatabase

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();
        }
    }
}
Also used : SQLBuilder(org.apache.sis.internal.metadata.sql.SQLBuilder) TestDatabase(org.apache.sis.test.sql.TestDatabase) Test(org.junit.Test)

Example 5 with TestDatabase

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();
}
Also used : TestDatabase(org.apache.sis.test.sql.TestDatabase) Test(org.junit.Test)

Aggregations

TestDatabase (org.apache.sis.test.sql.TestDatabase)13 Test (org.junit.Test)11 Connection (java.sql.Connection)3 StorageConnector (org.apache.sis.storage.StorageConnector)3 SQLStoreProvider (org.apache.sis.storage.sql.SQLStoreProvider)2 Method (java.lang.reflect.Method)1 AbstractFeature (org.apache.sis.feature.AbstractFeature)1 SQLBuilder (org.apache.sis.internal.metadata.sql.SQLBuilder)1 GeometryGetterTest (org.apache.sis.internal.sql.feature.GeometryGetterTest)1 SchemaModifier (org.apache.sis.internal.sql.feature.SchemaModifier)1 TableReference (org.apache.sis.internal.sql.feature.TableReference)1 DataStore (org.apache.sis.storage.DataStore)1 FeatureSet (org.apache.sis.storage.FeatureSet)1 ResourceDefinition (org.apache.sis.storage.sql.ResourceDefinition)1 SQLStore (org.apache.sis.storage.sql.SQLStore)1 SQLStoreTest (org.apache.sis.storage.sql.SQLStoreTest)1 Envelope (org.opengis.geometry.Envelope)1