sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1808720 [2/2] - in /sis/branches/JDK8: application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ core/sis-utility/src/main/java/org/apache/sis/setup/ core/sis-utility/src/main/java/org/apache/sis/util/ core/sis-utility/src/main/java...
Date Mon, 18 Sep 2017 14:13:23 GMT
Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1808720&r1=1808719&r2=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -918,7 +918,7 @@ public class StorageConnector implements
          * (potentially an InputStream). We need to remember this chain in 'Coupled' objects.
          */
         final String name = getStorageName();
-        final ReadableByteChannel channel = factory.reader(name);
+        final ReadableByteChannel channel = factory.reader(name, null);
         addView(ReadableByteChannel.class, channel, null, factory.isCoupled() ? CASCADE_ON_RESET
: 0);
         ByteBuffer buffer = getOption(OptionKey.BYTE_BUFFER);       // User-supplied buffer.
         if (buffer == null) {

Modified: sis/branches/JDK8/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider?rev=1808720&r1=1808719&r2=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -1,4 +1,3 @@
 org.apache.sis.internal.storage.xml.StoreProvider
 org.apache.sis.internal.storage.wkt.StoreProvider
 org.apache.sis.internal.storage.csv.StoreProvider
-org.apache.sis.internal.storage.folder.FolderProvider

Copied: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java
(from r1808719, sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/FolderStoreTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java?p2=sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java&p1=sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/FolderStoreTest.java&r1=1808719&r2=1808720&rev=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/FolderStoreTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -16,49 +16,82 @@
  */
 package org.apache.sis.internal.storage.folder;
 
-import java.io.BufferedWriter;
 import java.io.IOException;
-import java.nio.file.Files;
+import java.net.URISyntaxException;
+import java.net.URL;
 import java.nio.file.Path;
-import org.apache.sis.internal.storage.io.IOUtilities;
-import org.apache.sis.referencing.CommonCRS;
-import org.apache.sis.storage.DataStore;
-import org.apache.sis.storage.DataStoreException;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.opengis.metadata.identification.Identification;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.storage.Aggregate;
 import org.apache.sis.storage.Resource;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+
+
 /**
- * Tests {@link FolderStore}.
+ * Tests folder {@link Store}.
  *
- * @author Johann Sorel (Geomatys)
+ * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
  * @since   0.8
  * @module
  */
-public class FolderStoreTest extends TestCase {
+public final strictfp class StoreTest extends TestCase {
+    /**
+     * Gets the path to the test directory. If the directory is not accessible through the
file system
+     * (for example if the test data are read from a JAR file), then skip the tests. This
happen if the
+     * test are executed from another Maven module than {@code sis-storage}.
+     */
+    private static Path testDirectory() throws URISyntaxException {
+        final URL sample = StoreTest.class.getResource("test-data/README.txt");
+        assertNotNull("Test data not found", sample);
+        assumeTrue(sample.getProtocol().equals("file"));
+        return Paths.get(sample.toURI()).getParent();
+    }
 
     /**
-     * Test if sub stores are correctly detected.
+     * Verifies that components in a folder are correctly detected.
+     *
+     * @throws URISyntaxException if the URL to test data can not be converted to a path
of the file system.
+     * @throws DataStoreException if an error occurred while reading the resources.
+     * @throws IOException if an I/O error occurs.
      */
     @Test
-    public void testOpeningFolder() throws IOException, DataStoreException {
-
-        //create a folder with a prj file
-        final Path directory = Files.createTempDirectory("folder");
-        final Path prjFile = directory.resolve("crs.prj");
-        try (BufferedWriter writer = Files.newBufferedWriter(prjFile)) {
-            writer.write(CommonCRS.WGS84.normalizedGeographic().toWKT());
+    public void testComponents() throws URISyntaxException, DataStoreException, IOException
{
+        final Set<String> identifiers = new HashSet<>(Arrays.asList("Sample 1",
"Sample 2", "Sample 3", "data4"));
+        try (Store store = new Store(null, new StorageConnector(testDirectory()))) {
+            assertEquals("Expected three data stores.", 3, store.components().size());
+            verifyContent(store, identifiers);
+        }
+        if (!identifiers.isEmpty()) {
+            fail("Missing resources: " + identifiers);
         }
-
-        final FolderStore store = new FolderStore(directory.toUri());
-        assertEquals(1,store.components().size());
-        final Resource prjResource = store.components().iterator().next();
-        assertTrue(prjResource instanceof DataStore);
-
-
-
     }
 
+    /**
+     * Verifies that the given metadata contains one of the given identifiers.
+     * The identifiers that are found are removed from the given set.
+     */
+    private static void verifyContent(final Aggregate store, final Set<String> identifiers)
throws DataStoreException {
+        for (final Resource resource : store.components()) {
+            assertNotNull("resource", resource);
+            for (Identification info : resource.getMetadata().getIdentificationInfo()) {
+                final String id = Citations.getIdentifier(info.getCitation());
+                assertTrue(id, identifiers.remove(id));
+                if (resource instanceof Aggregate) {
+                    verifyContent((Aggregate) resource, identifiers);
+                }
+            }
+        }
+    }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java?rev=1808720&r1=1808719&r2=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -135,7 +135,7 @@ public final strictfp class ChannelDataI
     }
 
     /**
-     * Tests the {@link ChannelDataInput#readString(int, String)} method.
+     * Tests the {@link ChannelDataInput#readString(int, Charset)} method.
      *
      * @throws IOException should never happen since we read and write in memory only.
      */

Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java?rev=1808720&r1=1808719&r2=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -48,7 +48,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.storage.wkt.StoreTest.class,
     org.apache.sis.internal.storage.csv.StoreProviderTest.class,
     org.apache.sis.internal.storage.csv.StoreTest.class,
-    org.apache.sis.internal.storage.folder.FolderStoreTest.class,
+    org.apache.sis.internal.storage.folder.StoreTest.class,
     org.apache.sis.storage.DataStoresTest.class
 })
 public final strictfp class StorageTestSuite extends TestSuite {

Added: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt?rev=1808720&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -0,0 +1,6 @@
+This directory contains data to be read by the folder data store.
+We need to put those data in a different directory than the Store
+implementation class because otherwise, opening the folder would
+scan all *.class files in addition to test files. Implementation
+should be robust to that, but we nevertheless keep those files
+separated for more predictable tests.

Propchange: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data1.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data1.xml?rev=1808720&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data1.xml
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data1.xml
Mon Sep 18 14:13:22 2017
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco">
+  <gmd:identificationInfo>
+    <gmd:MD_DataIdentification>
+      <gmd:citation>
+        <gmd:CI_Citation>
+          <gmd:title>
+            <gco:CharacterString>Sample 1</gco:CharacterString>
+          </gmd:title>
+        </gmd:CI_Citation>
+      </gmd:citation>
+    </gmd:MD_DataIdentification>
+  </gmd:identificationInfo>
+</gmd:MD_Metadata>

Added: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data2.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data2.xml?rev=1808720&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data2.xml
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data2.xml
Mon Sep 18 14:13:22 2017
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+  <!-- Dummy document for verifying that the folder data store skips unknown formats.
-->
+</root>

Added: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data3.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data3.xml?rev=1808720&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data3.xml
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data3.xml
Mon Sep 18 14:13:22 2017
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco">
+  <gmd:identificationInfo>
+    <gmd:MD_DataIdentification>
+      <gmd:citation>
+        <gmd:CI_Citation>
+          <gmd:title>
+            <gco:CharacterString>Sample 2</gco:CharacterString>
+          </gmd:title>
+        </gmd:CI_Citation>
+      </gmd:citation>
+    </gmd:MD_DataIdentification>
+  </gmd:identificationInfo>
+</gmd:MD_Metadata>

Added: sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data4/data5.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data4/data5.xml?rev=1808720&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data4/data5.xml
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/test/resources/org/apache/sis/internal/storage/folder/test-data/data4/data5.xml
Mon Sep 18 14:13:22 2017
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco">
+  <gmd:identificationInfo>
+    <gmd:MD_DataIdentification>
+      <gmd:citation>
+        <gmd:CI_Citation>
+          <gmd:title>
+            <gco:CharacterString>Sample 3</gco:CharacterString>
+          </gmd:title>
+        </gmd:CI_Citation>
+      </gmd:citation>
+    </gmd:MD_DataIdentification>
+  </gmd:identificationInfo>
+</gmd:MD_Metadata>

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1808720&r1=1808719&r2=1808720&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] Mon Sep 18 14:13:22 2017
@@ -125,9 +125,9 @@ public abstract class StaxDataStore exte
      * <p>We keep this reference as long as possible in order to use {@link #mark()}
and {@link #reset()}
      * instead than creating new streams for re-reading the data.  If we can not reset the
stream but can
      * create a new one, then this field will become a reference to the new stream. This
change should be
-     * done only in last resort, when there is no way to reuse the existing stream.  This
is because the
-     * streams created by {@link ChannelFactory#inputStream(String)} are not of the same
kind than the
-     * streams created by {@link StorageConnector}.</p>
+     * done only in last resort, when there is no way to reuse the existing stream. This
is because the
+     * streams created by {@link ChannelFactory#inputStream(String, WarningListeners)} are
not of the same
+     * kind than the streams created by {@link StorageConnector}.</p>
      *
      * @see #close()
      */
@@ -473,7 +473,7 @@ public abstract class StaxDataStore exte
                     if (channelFactory == null) {
                         throw new ForwardOnlyStorageException(getLocale(), name, StandardOpenOption.READ);
                     }
-                    inputOrFile = input = channelFactory.inputStream(name);
+                    inputOrFile = input = channelFactory.inputStream(name, listeners);
                     type = InputType.STREAM;
                     if (stream == null) {
                         stream = input;



Mime
View raw message