sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Move CitationsTest down in the test dependencies because the constants now depend on SQL storage.
Date Wed, 25 Jul 2018 17:40:05 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit f87e4f0cc09fbf36703c4ffda50d9688ef2dd028
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jul 25 19:38:33 2018 +0200

    Move CitationsTest down in the test dependencies because the constants now depend on SQL
storage.
---
 .../sis/metadata/iso/ImmutableIdentifierTest.java  |  5 +--
 .../sis/metadata/iso/citation/CitationsTest.java   |  2 +
 .../sis/metadata/sql/MetadataSourceTest.java       | 44 ++++++++++++++++------
 .../apache/sis/test/suite/MetadataTestSuite.java   |  4 +-
 4 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
index 6623188..b9df3c7 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ImmutableIdentifierTest.java
@@ -45,10 +45,7 @@ import static org.opengis.metadata.Identifier.*;
  * @since   0.3
  * @module
  */
-@DependsOn({
-    DefaultIdentifierTest.class,
-    org.apache.sis.metadata.iso.citation.CitationsTest.class
-})
+@DependsOn(DefaultIdentifierTest.class)
 public final strictfp class ImmutableIdentifierTest extends TestCase {
     /**
      * Returns the properties map to be used in argument to test methods.
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
index 776eb4b..aa32db5 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/CitationsTest.java
@@ -29,6 +29,7 @@ import org.apache.sis.internal.simple.SimpleCitation;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.xml.IdentifierSpace;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -45,6 +46,7 @@ import static org.apache.sis.test.MetadataAssert.*;
  * @since   0.6
  * @module
  */
+@DependsOn(org.apache.sis.metadata.sql.MetadataSourceTest.class)
 public final strictfp class CitationsTest extends TestCase {
     /**
      * Verifies that {@link Citations#values()} is complete by comparing with the list
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
index dcca10d..2b8236b 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.metadata.sql;
 
+import java.util.Collection;
 import java.util.Collections;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.distribution.Format;
@@ -51,15 +52,8 @@ public final strictfp class MetadataSourceTest extends TestCase {
      */
     @Test
     public void testOnDerby() throws Exception {
-        try (TestDatabase db = TestDatabase.create("MetadataSource");
-             MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115, db.source,
"metadata", null))
-        {
-            source.install();
-            verifyFormats(source);
-            testSearch(source);
-
-            // Opportunistic verification using the database we have at hand.
-            MetadataFallbackVerifier.compare(source);
+        try (TestDatabase db = TestDatabase.create("MetadataSource")) {
+            testAll(db);
         }
     }
 
@@ -70,12 +64,23 @@ public final strictfp class MetadataSourceTest extends TestCase {
      */
     @Test
     public void testOnPostgreSQL() throws Exception {
-        try (TestDatabase db = TestDatabase.createOnPostgreSQL("metadata", false);
-             MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115, db.source,
"metadata", null))
-        {
+        try (TestDatabase db = TestDatabase.createOnPostgreSQL("metadata", false)) {
+            testAll(db);
+        }
+    }
+
+    /**
+     * Runs all public tests declared in this class.
+     * Also opportunistically run tests declared in {@link MetadataFallbackVerifier}.
+     */
+    private static void testAll(final TestDatabase db) throws Exception {
+        try (MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115, db.source,
"metadata", null)) {
             source.install();
             verifyFormats(source);
             testSearch(source);
+            testEmptyCollection(source);
+
+            // Opportunistic verification using the database we have at hand.
             MetadataFallbackVerifier.compare(source);
         }
     }
@@ -127,4 +132,19 @@ public final strictfp class MetadataSourceTest extends TestCase {
         specification.setTitle(null);
         assertNull(source.search(format));
     }
+
+    /**
+     * Verifies that empty collections are empty, not-null.
+     *
+     * @param  source  the instance to test.
+     * @throws MetadataStoreException if an error occurred while querying the database.
+     */
+    @TestStep
+    public static void testEmptyCollection(final MetadataSource source) throws MetadataStoreException
{
+        final Citation c = source.lookup(Citation.class, "SIS");
+        final Collection<?> details = c.getOtherCitationDetails();
+        assertNotNull("Empty collection should not be null.", details);
+        assertTrue("Expected an empty collection.", details.isEmpty());
+        assertSame("Collection shall be unmodifiable.", Collections.EMPTY_LIST, details);
+    }
 }
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
b/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
index 8701cc7..cd803d0 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
@@ -103,7 +103,6 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.citation.DefaultResponsibilityTest.class,
     org.apache.sis.metadata.iso.citation.DefaultCitationDateTest.class,
     org.apache.sis.metadata.iso.citation.DefaultCitationTest.class,
-    org.apache.sis.metadata.iso.citation.CitationsTest.class,
     org.apache.sis.metadata.iso.maintenance.DefaultScopeDescriptionTest.class,
     org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBoxTest.class,
     org.apache.sis.metadata.iso.extent.DefaultExtentTest.class,
@@ -142,7 +141,8 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.metadata.sql.ScriptRunnerTest.class,
     org.apache.sis.metadata.sql.IdentifierGeneratorTest.class,
     org.apache.sis.metadata.sql.MetadataSourceTest.class,
-    org.apache.sis.metadata.sql.MetadataWriterTest.class
+    org.apache.sis.metadata.sql.MetadataWriterTest.class,
+    org.apache.sis.metadata.iso.citation.CitationsTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**


Mime
View raw message