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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 9b45753  Make the GPX tests more robust to coexistance of ESRI and JTS 
librairies on the classpath.
9b45753 is described below

commit 9b45753c23a318b393e4c1f0f136d36eb375086d
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Mon Jan 10 02:48:53 2022 +0100

    Make the GPX tests more robust to coexistance of ESRI and JTS librairies on 
the classpath.
---
 .../sis/internal/storage/xml/stream/StaxDataStore.java  | 10 +++++-----
 .../org/apache/sis/internal/storage/gpx/ReaderTest.java |  8 ++++++--
 .../org/apache/sis/internal/storage/gpx/WriterTest.java | 17 +++++++++++------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git 
a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
 
b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
index 4c2295c..20ee0ca 100644
--- 
a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
+++ 
b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
@@ -229,7 +229,7 @@ public abstract class StaxDataStore extends URIDataStore {
         if (stream == null && storage instanceof AutoCloseable) {
             stream = (AutoCloseable) storage;
         }
-        channelFactory = connector.getStorageAs(ChannelFactory.class);  // 
Must be last before 'closeAllExcept'.
+        channelFactory = connector.getStorageAs(ChannelFactory.class);  // 
Must be last before `closeAllExcept(…)`.
         connector.closeAllExcept(stream);
         /*
          * If possible, remember the position where data begin in the stream 
in order to allow reading
@@ -329,7 +329,7 @@ public abstract class StaxDataStore extends URIDataStore {
         public void report(String message, String errorType, Object info, 
Location location) {
             final LogRecord record = new LogRecord(Level.WARNING, message);
             
record.setSourceClassName(StaxDataStore.this.getClass().getCanonicalName());
-            // record.setLoggerName(…) will be invoked by 'listeners' with 
inferred name.
+            // record.setLoggerName(…) will be invoked by `listeners` with 
inferred name.
             listeners.warning(record);
         }
 
@@ -340,7 +340,7 @@ public abstract class StaxDataStore extends URIDataStore {
          */
         @Override
         public boolean isLoggable(final LogRecord warning) {
-            warning.setLoggerName(null);        // For allowing 'listeners' to 
select a logger name.
+            warning.setLoggerName(null);        // For allowing `listeners` to 
select a logger name.
             listeners.warning(warning);
             return false;
         }
@@ -439,7 +439,7 @@ public abstract class StaxDataStore extends URIDataStore {
             case FINISHED: {
                 if (reset()) break;       // If we can reuse existing stream, 
nothing more to do.
                 if (input != null) {
-                    stream = null;        // Cleared first in case of error 
during 'close()' call.
+                    stream = null;        // Cleared first in case of error 
during `close()` call.
                     input.close();
                     input = null;
                 }
@@ -449,7 +449,7 @@ public abstract class StaxDataStore extends URIDataStore {
                 /*
                  * If the input stream is in use, or if we finished to use it 
but were unable to reset its position,
                  * then we need to create a new input stream (except if the 
input was a DOM in memory, which we can
-                 * share). The 'target' StaxStreamReader will be in charge of 
closing that stream.
+                 * share). The `target` StaxStreamReader will be in charge of 
closing that stream.
                  */
                 if (type != InputType.NODE) {
                     final String name = getDisplayName();
diff --git 
a/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
 
b/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
index b477697..e53176b 100644
--- 
a/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
+++ 
b/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
@@ -25,6 +25,7 @@ import com.esri.core.geometry.Point;
 import com.esri.core.geometry.Polyline;
 import org.opengis.geometry.Envelope;
 import org.opengis.metadata.content.FeatureCatalogueDescription;
+import org.apache.sis.setup.GeometryLibrary;
 import org.apache.sis.setup.OptionKey;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.StorageConnector;
@@ -51,7 +52,7 @@ import org.opengis.metadata.content.FeatureTypeInfo;
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.2
  * @since   0.8
  * @module
  */
@@ -84,7 +85,9 @@ public final strictfp class ReaderTest extends TestCase {
      * @param  resource  name of the test file in a directory relative to 
{@code "org/apache/sis/internal/gpx"}.
      */
     private static Store create(final String resource) throws 
DataStoreException {
-        return new Store(provider, new 
StorageConnector(ReaderTest.class.getResourceAsStream(resource)));
+        final StorageConnector connector = new 
StorageConnector(ReaderTest.class.getResourceAsStream(resource));
+        connector.setOption(OptionKey.GEOMETRY_LIBRARY, GeometryLibrary.ESRI);
+        return new Store(provider, connector);
     }
 
     /**
@@ -567,6 +570,7 @@ public final strictfp class ReaderTest extends TestCase {
      */
     private static Store createFromURL() throws DataStoreException {
         final StorageConnector connector = new 
StorageConnector(ReaderTest.class.getResource("1.1/route.xml"));
+        connector.setOption(OptionKey.GEOMETRY_LIBRARY, GeometryLibrary.ESRI);
         connector.setOption(OptionKey.URL_ENCODING, "UTF-8");
         return new Store(provider, connector);
     }
diff --git 
a/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
 
b/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
index 926458f..ae66a25 100644
--- 
a/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
+++ 
b/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
@@ -24,6 +24,8 @@ import java.io.UncheckedIOException;
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
 import com.esri.core.geometry.Point;
+import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.setup.OptionKey;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
@@ -49,7 +51,7 @@ import org.opengis.feature.Feature;
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.2
  * @since   0.8
  * @module
  */
@@ -85,7 +87,9 @@ public final strictfp class WriterTest extends TestCase {
      * Creates a new GPX data store which will read and write in memory.
      */
     private Store create() throws DataStoreException {
-        return new Store(provider, new StorageConnector(output));
+        final StorageConnector connector = new StorageConnector(output);
+        connector.setOption(OptionKey.GEOMETRY_LIBRARY, GeometryLibrary.ESRI);
+        return new Store(provider, connector);
     }
 
     /**
@@ -244,7 +248,7 @@ public final strictfp class WriterTest extends TestCase {
      * @param type   the kind of feature to write: way point, route or track.
      */
     private void testFeatures(final Store store, final Type type) throws 
Exception {
-        final Types types = Types.DEFAULT;
+        final Types types = store.types;
         /*
          * Way Points as defined in "waypoint.xml" test file.
          * Appear also in "route.xml" and "track.xml" files.
@@ -363,9 +367,10 @@ public final strictfp class WriterTest extends TestCase {
     @Test
     @DependsOnMethod("testRoutes110")
     public void testInputReplacement() throws Exception {
-        try (Store store = new Store(provider, new StorageConnector(
-                TestUtilities.createTemporaryFile(ReaderTest.class, 
"1.1/metadata.xml"))))
-        {
+        final StorageConnector connector = new StorageConnector(
+                TestUtilities.createTemporaryFile(ReaderTest.class, 
"1.1/metadata.xml"));
+        connector.setOption(OptionKey.GEOMETRY_LIBRARY, GeometryLibrary.ESRI);
+        try (Store store = new Store(provider, connector)) {
             /*
              * Read part of the file. We verify its content as a matter of 
principle,
              * but the main purpose of following code is to advance in the 
stream.

Reply via email to