sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1771151 - in /sis/branches/JDK8/core/sis-metadata/src: main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java main/java/org/apache/sis/metadata/sql/MetadataSource.java test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
Date Thu, 24 Nov 2016 14:30:36 GMT
Author: desruisseaux
Date: Thu Nov 24 14:30:36 2016
New Revision: 1771151

URL: http://svn.apache.org/viewvc?rev=1771151&view=rev
Log:
Add a test case for MetadataSource.search(Object).

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java?rev=1771151&r1=1771150&r2=1771151&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/SQLBuilder.java
[UTF-8] Thu Nov 24 14:30:36 2016
@@ -183,7 +183,7 @@ public class SQLBuilder {
      */
     public final SQLBuilder appendCondition(final Object value) {
         if (value == null) {
-            buffer.append("IS NULL");
+            buffer.append(" IS NULL");
             return this;
         }
         buffer.append('=');

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1771151&r1=1771150&r2=1771151&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Thu Nov 24 14:30:36 2016
@@ -303,7 +303,8 @@ public class MetadataSource implements A
     /**
      * Creates a new metadata source. The metadata standard to implement (typically
      * {@linkplain MetadataStandard#ISO_19115 ISO 19115}, but not necessarily) and
-     * the database source are mandatory information. All other information are optional.
+     * the database source are mandatory information.
+     * All other information are optional and can be {@code null}.
      *
      * @param  standard       the metadata standard to implement.
      * @param  dataSource     the source for getting a connection to the database.

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java?rev=1771151&r1=1771150&r2=1771151&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataSourceTest.java
[UTF-8] Thu Nov 24 14:30:36 2016
@@ -16,11 +16,15 @@
  */
 package org.apache.sis.metadata.sql;
 
+import java.util.Collections;
 import javax.sql.DataSource;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.distribution.Format;
 import org.apache.sis.metadata.MetadataStandard;
 import org.apache.sis.internal.metadata.sql.TestDatabase;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.distribution.DefaultFormat;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestStep;
@@ -52,6 +56,7 @@ public final strictfp class MetadataSour
         try (final MetadataSource source = new MetadataSource(MetadataStandard.ISO_19115,
ds, "metadata", null, null)) {
             source.install();
             verifyFormats(source);
+            testSearch(source);
         } finally {
             TestDatabase.drop(ds);
         }
@@ -86,4 +91,22 @@ public final strictfp class MetadataSour
         assertEquals("abbreviation", abbreviation, String.valueOf(getSingleton(spec.getAlternateTitles())));
         assertEquals("title", title, String.valueOf(spec.getTitle()));
     }
+
+    /**
+     * Tests {@link MetadataSource#search(Object)}
+     *
+     * @param  source  the instance to test.
+     * @throws MetadataStoreException if an error occurred while querying the database.
+     */
+    @TestStep
+    public static void testSearch(final MetadataSource source) throws MetadataStoreException
{
+        final DefaultCitation specification = new DefaultCitation("PNG (Portable Network
Graphics) Specification");
+        specification.setAlternateTitles(Collections.singleton(new SimpleInternationalString("PNG")));
+        final DefaultFormat format = new DefaultFormat();
+        format.setFormatSpecificationCitation(specification);
+
+        assertEquals("PNG", source.search(format));
+        specification.setTitle(null);
+        assertNull(source.search(format));
+    }
 }



Mime
View raw message