sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1792396 - in /sis/branches/JDK8: ./ core/sis-build-helper/ core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/ core/sis-referencing/src/test/java/org/apach...
Date Sun, 23 Apr 2017 21:38:30 GMT
Author: desruisseaux
Date: Sun Apr 23 21:38:29 2017
New Revision: 1792396

URL: http://svn.apache.org/viewvc?rev=1792396&view=rev
Log:
Fix test failures that occur during integration tests (when we put all JAR togethers in one
big project).

Added:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
  (with props)
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-build-helper/pom.xml
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
    sis/branches/JDK8/pom.xml
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
    sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java

Modified: sis/branches/JDK8/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/pom.xml?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/pom.xml (original)
+++ sis/branches/JDK8/core/sis-build-helper/pom.xml Sun Apr 23 21:38:29 2017
@@ -24,6 +24,9 @@
          xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
                                http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
 
   <!-- Do not inherit from core/pom.xml because doing so would create a cyclic dependency.
-->
   <parent>

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -119,7 +119,7 @@ final class CachedStatement implements A
             if (!r.next()) {
                 final String table = r.getMetaData().getTableName(1);
                 r.close();
-                throw new SQLException(Errors.format(Errors.Keys.RecordNotFound_2, table,
id));
+                throw new MetadataStoreException(Errors.format(Errors.Keys.RecordNotFound_2,
table, id));
             }
             results = r;
             identifier = id;

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=1792396&r1=1792395&r2=1792396&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] Sun Apr 23 21:38:29 2017
@@ -34,6 +34,7 @@ import java.util.logging.LogRecord;
 import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.io.IOException;
 import javax.sql.DataSource;
 import java.sql.DatabaseMetaData;
 import java.sql.Connection;
@@ -66,6 +67,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.ObjectConverters;
 import org.apache.sis.util.UnconvertibleObjectException;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.iso.Types;
 
@@ -390,16 +392,12 @@ public class MetadataSource implements A
             }
             final Installer installer = new Installer(connection);
             installer.run();
-        } catch (Exception e) {
+        } catch (IOException | SQLException e) {
             /*
              * Derby sometime wraps SQLException into another SQLException.  For making the
stack strace a
              * little bit simpler, keep only the root cause provided that the exception type
is compatible.
              */
-            final String message = e.getLocalizedMessage();
-            for (Throwable cause; e.getClass().isInstance(cause = e.getCause());) {
-                e = (Exception) cause;
-            }
-            throw new MetadataStoreException(message, e);
+            throw new MetadataStoreException(e.getLocalizedMessage(), Exceptions.unwrap(e));
         }
     }
 
@@ -785,7 +783,7 @@ public class MetadataSource implements A
      * @param  toSearch  contains the identifier and preferred index of the record to search.
      * @return the value of the requested attribute.
      * @throws SQLException if the SQL query failed.
-     * @throws MetadataStoreException if a value can not be converted to the expected type.
+     * @throws MetadataStoreException if a value was not found or can not be converted to
the expected type.
      */
     final Object getValue(final Class<?> type, final Method method, final Dispatcher
toSearch)
             throws SQLException, MetadataStoreException

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -463,11 +463,7 @@ public class EPSGFactory extends Concurr
              * Derby sometime wraps SQLException into another SQLException.  For making the
stack strace a
              * little bit simpler, keep only the root cause provided that the exception type
is compatible.
              */
-            final String message = message(e);
-            for (Throwable cause; e.getClass().isInstance(cause = e.getCause());) {
-                e = (Exception) cause;
-            }
-            exception = new UnavailableFactoryException(message, e);
+            exception = new UnavailableFactoryException(message(e), Exceptions.unwrap(e));
         }
         exception.setUnavailableFactory(this);
         throw exception;

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java?rev=1792396&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.FileSystemNotFoundException;
+import org.apache.sis.test.TestCase;
+
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+
+
+/**
+ * Base class of tests that need to load a datum shift grid. This base class provides a
+ * {@link #getResourceAsConvertibleURL(String)} method for fetching the data in a form
+ * convertible to {@link Path}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+public abstract strictfp class DatumShiftTestCase extends TestCase {
+    /**
+     * For subclass constructors only.
+     */
+    DatumShiftTestCase() {
+    }
+
+    /**
+     * Finds resource of the given name as a URL convertible to a {@link Path}.
+     * If the URL is not convertible, then this method declares the test as ignored.
+     *
+     * @param  name  name of the resource to get.
+     * @return the requested resources.
+     */
+    public static URL getResourceAsConvertibleURL(final String name) {
+        final URL file = DatumShiftTestCase.class.getResource(name);
+        if (file == null) {
+            fail("Test file \"" + name + "\" not found.");
+        } else {
+            assumeFalse("Can not read grid data in a JAR file.", "jar".equals(file.getProtocol()));
+        }
+        return file;
+    }
+
+    /**
+     * Finds resource of the given name as a path. If the resource can not be obtained because
+     * the grid file is inside a JAR file, declares the test as ignored instead than failed.
+     *
+     * @param  name  name of the resource to get.
+     * @return the requested resources.
+     */
+    static Path getResource(final String name) throws URISyntaxException {
+        final URL file = DatumShiftTestCase.class.getResource(name);
+        if (file == null) {
+            fail("Test file \"" + name + "\" not found.");
+        } else try {
+            return Paths.get(file.toURI());
+        } catch (FileSystemNotFoundException e) {
+            assumeFalse("Can not read grid data in a JAR file.", "jar".equals(file.getProtocol()));
+            throw e;
+        }
+        return null;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/DatumShiftTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
-import java.net.URL;
 import java.net.URISyntaxException;
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -29,7 +28,6 @@ import org.opengis.geometry.Envelope;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestStep;
 import org.junit.Test;
 
@@ -48,7 +46,7 @@ import static org.opengis.test.Assert.*;
  * @since 0.7
  * @module
  */
-public final strictfp class FranceGeocentricInterpolationTest extends TestCase {
+public final strictfp class FranceGeocentricInterpolationTest extends DatumShiftTestCase
{
     /**
      * Name of the file containing a small extract of the "{@code GR3DF97A.txt}" file.
      * The amount of data in this test file is less than 0.14% of the original file.
@@ -140,9 +138,7 @@ public final strictfp class FranceGeocen
     private static DatumShiftGridFile<Angle,Length> testGridAsFloats()
             throws URISyntaxException, IOException, FactoryException, TransformException
     {
-        final URL url = FranceGeocentricInterpolationTest.class.getResource(TEST_FILE);
-        assertNotNull("Test file \"" + TEST_FILE + "\" not found.", url);
-        final Path file = Paths.get(url.toURI());
+        final Path file = getResource(TEST_FILE);
         final DatumShiftGridFile.Float<Angle,Length> grid;
         try (BufferedReader in = Files.newBufferedReader(file)) {
             grid = FranceGeocentricInterpolation.load(in, file);
@@ -233,17 +229,15 @@ public final strictfp class FranceGeocen
     @Test
     @DependsOnMethod("testGrid")
     public void testGetOrLoad() throws URISyntaxException, FactoryException, TransformException
{
-        final URL file = FranceGeocentricInterpolationTest.class.getResource(TEST_FILE);
-        assertNotNull("Test file \"" + TEST_FILE + "\" not found.", file);
         final DatumShiftGridFile<Angle,Length> grid = FranceGeocentricInterpolation.getOrLoad(
-                Paths.get(file.toURI()), new double[] {
+                getResource(TEST_FILE), new double[] {
                         FranceGeocentricInterpolation.TX,
                         FranceGeocentricInterpolation.TY,
                         FranceGeocentricInterpolation.TZ},
                         FranceGeocentricInterpolation.PRECISION);
         verifyGrid(grid);
         assertSame("Expected a cached value.", grid, FranceGeocentricInterpolation.getOrLoad(
-                Paths.get(file.toURI()), new double[] {
+                getResource(TEST_FILE), new double[] {
                         FranceGeocentricInterpolation.TX,
                         FranceGeocentricInterpolation.TY,
                         FranceGeocentricInterpolation.TZ},

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -19,10 +19,8 @@ package org.apache.sis.internal.referenc
 import java.util.Locale;
 import java.io.BufferedWriter;
 import java.io.IOException;
-import java.net.URL;
 import java.net.URISyntaxException;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.nio.file.Files;
 import javax.measure.quantity.Angle;
 import org.opengis.geometry.Envelope;
@@ -32,7 +30,6 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.geometry.Envelope2D;
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.measure.Units;
-import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.opengis.test.Assert.*;
@@ -47,7 +44,7 @@ import static org.opengis.test.Assert.*;
  * @since   0.7
  * @module
  */
-public final strictfp class NADCONTest extends TestCase {
+public final strictfp class NADCONTest extends DatumShiftTestCase {
     /**
      * Returns the sample point for a step in the transformation from NAD27 to NAD83.
      * The sample point is the coordinate of Meades Ranch station, which was the point
@@ -102,12 +99,8 @@ public final strictfp class NADCONTest e
      */
     @Test
     public void testLoader() throws URISyntaxException, IOException, FactoryException, TransformException
{
-        final URL latitudeShifts  = NADCONTest.class.getResource(TEST_FILE + ".laa");
-        final URL longitudeShifts = NADCONTest.class.getResource(TEST_FILE + ".loa");
-        assertNotNull("Test file \"" + TEST_FILE + ".laa\" not found.", latitudeShifts);
-        assertNotNull("Test file \"" + TEST_FILE + ".loa\" not found.", longitudeShifts);
-        testNADCON(Paths.get(latitudeShifts.toURI()),
-                   Paths.get(longitudeShifts.toURI()),
+        testNADCON(getResource(TEST_FILE + ".laa"),     // Latitude shifts
+                   getResource(TEST_FILE + ".loa"),     // Longitude shifts
                    -99.75, -98.0, 37.5, 39.75);
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -16,13 +16,11 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
-import java.net.URL;
 import java.net.URISyntaxException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.nio.file.Files;
 import java.nio.file.StandardOpenOption;
 import java.nio.channels.WritableByteChannel;
@@ -35,7 +33,6 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.geometry.Envelope2D;
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.measure.Units;
-import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.opengis.test.Assert.*;
@@ -53,7 +50,7 @@ import static org.opengis.test.Assert.*;
  * @since 0.7
  * @module
  */
-public final strictfp class NTv2Test extends TestCase {
+public final strictfp class NTv2Test extends DatumShiftTestCase {
     /**
      * Name of the file containing a small extract of the "{@code NTF_R93.gsb}" file.
      * The amount of data in this test file is less than 0.14% of the original file.
@@ -76,9 +73,7 @@ public final strictfp class NTv2Test ext
      */
     @Test
     public void testLoader() throws URISyntaxException, IOException, FactoryException, TransformException
{
-        final URL url = NTv2Test.class.getResource(TEST_FILE);
-        assertNotNull("Test file \"" + TEST_FILE + "\" not found.", url);
-        testRGF93(Paths.get(url.toURI()),
+        testRGF93(getResource(TEST_FILE),
                  36000 - 360 * (72 + 5),    // Subgrid of RGF93 beginning at gridX = 72
                  36000 - 360 * (72),        // Subgrid uses 6 cells along longitude axis
                 147600 + 360 * (74),        // Subgrid of RGF93 beginning at gridY = 74

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -34,14 +34,13 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.junit.Test;
 
-import static org.opengis.test.Assert.*;
 
 
 /**
  * Tests {@link InterpolatedGeocentricTransform}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
  * @since   0.7
  * @module
  */
@@ -64,8 +63,7 @@ public strictfp class InterpolatedGeocen
      * Creates the transform using the given provider.
      */
     final void createGeodeticTransformation(final FranceGeocentricInterpolation provider)
throws FactoryException {
-        final URL file = FranceGeocentricInterpolationTest.class.getResource(FranceGeocentricInterpolationTest.TEST_FILE);
-        assertNotNull("Test file \"" + FranceGeocentricInterpolationTest.TEST_FILE + "\"
not found.", file);
+        final URL file = FranceGeocentricInterpolationTest.getResourceAsConvertibleURL(FranceGeocentricInterpolationTest.TEST_FILE);
         final Ellipsoid source = HardCodedDatum.NTF.getEllipsoid();     // Clarke 1880 (IGN)
         final Ellipsoid target = CommonCRS.ETRS89.ellipsoid();          // GRS 1980 ellipsoid
         final ParameterValueGroup values = provider.getParameters().createValue();

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -34,7 +34,6 @@ import org.apache.sis.test.DependsOnMeth
 import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
-import static org.junit.Assert.assertNotNull;
 
 
 /**
@@ -57,8 +56,7 @@ public final strictfp class Interpolated
      * @throws FactoryException if an error occurred while loading the grid.
      */
     private void createRGF93() throws FactoryException {
-        final URL file = NTv2Test.class.getResource(NTv2Test.TEST_FILE);
-        assertNotNull("Test file \"" + NTv2Test.TEST_FILE + "\" not found.", file);
+        final URL file = NTv2Test.getResourceAsConvertibleURL(NTv2Test.TEST_FILE);
         final NTv2 provider = new NTv2();
         final ParameterValueGroup values = provider.getParameters().createValue();
         values.parameter("Latitude and longitude difference file").setValue(file);    //
Automatic conversion from URL to Path.
@@ -73,10 +71,8 @@ public final strictfp class Interpolated
      * @throws FactoryException if an error occurred while loading the grid.
      */
     private void createNADCON() throws FactoryException {
-        final URL latitudeShifts  = NADCONTest.class.getResource(NADCONTest.TEST_FILE + ".laa");
-        final URL longitudeShifts = NADCONTest.class.getResource(NADCONTest.TEST_FILE + ".loa");
-        assertNotNull("Test file \"" + NADCONTest.TEST_FILE + ".laa\" not found.", latitudeShifts);
-        assertNotNull("Test file \"" + NADCONTest.TEST_FILE + ".loa\" not found.", longitudeShifts);
+        final URL latitudeShifts  = NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE
+ ".laa");
+        final URL longitudeShifts = NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE
+ ".loa");
         final NADCON provider = new NADCON();
         final ParameterValueGroup values = provider.getParameters().createValue();
         values.parameter("Latitude difference file").setValue(latitudeShifts);

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java?rev=1792396&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
(added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.io;
+
+import java.io.IOException;
+
+
+/**
+ * Thrown when an input stream or a channel can not modify its position to the given value.
+ * If may be because the given position is after the end of file, but not necessarily.
+ * This exception may also be thrown by implementations that cache a portion of a file
+ * and can only seek inside that portion.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ *
+ * @see java.nio.channels.SeekableByteChannel#position(long)
+ * @see java.io.InputStream#reset()
+ * @see javax.imageio.stream.ImageInputStream#reset()
+ *
+ * @since 0.8
+ * @module
+ */
+public class InvalidSeekException extends IOException {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -3327667930906602606L;
+
+    /**
+     * Constructs a new exception with no message.
+     */
+    public InvalidSeekException() {
+        super();
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message.
+     *
+     * @param message  the detail message, or {@code null} if none.
+     */
+    public InvalidSeekException(final String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message and cause.
+     *
+     * @param message  the detail message, or {@code null} if none.
+     * @param cause    the cause, or {@code null} if none.
+     */
+    public InvalidSeekException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/InvalidSeekException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8]
Sun Apr 23 21:38:29 2017
@@ -43,6 +43,7 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.Version;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.logging.LoggerFactory;
@@ -331,7 +332,7 @@ fill:   for (int i=0; ; i++) {
                     } catch (ClassNotFoundException e) {
                         recoverableException(Modules.STORAGE, e);       // sis-storage module
not in the classpath.
                     } catch (ReflectiveOperationException e) {
-                        value = e.toString();
+                        value = Exceptions.unwrap(e).toString();
                     }
                     nameKey = Vocabulary.Keys.DataFormats;
                     break;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8]
Sun Apr 23 21:38:29 2017
@@ -20,8 +20,13 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Locale;
 import java.sql.SQLException;
+import java.lang.reflect.InvocationTargetException;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.collection.BackingStoreException;
+
+// Branch-dependent imports
+import java.io.UncheckedIOException;
 
 
 /**
@@ -197,4 +202,41 @@ public final class Exceptions extends St
         }
         return false;
     }
+
+    /**
+     * If the given exception is a wrapper for another exception, returns the unwrapped exception.
+     * Otherwise returns the given argument unchanged. An exception is considered a wrapper
if:
+     *
+     * <ul>
+     *   <li>It is an instance of {@link InvocationTargetException} (could be wrapping
anything).</li>
+     *   <li>It is an instance of {@link BackingStoreException} (typically wrapping
a checked exception).</li>
+     *   <li>It is an instance of {@link UncheckedIOException} (wrapping a {@link java.io.IOException}).</li>
+     *   <li>It is a parent type of the cause. For example some JDBC drivers wrap {@link
SQLException}
+     *       in other {@code SQLException} without additional information.</li>
+     * </ul>
+     *
+     * This method uses only the exception class as criterion;
+     * it does not verify if the exception messages are the same.
+     *
+     * @param  exception  the exception to unwrap (may be {@code null}.
+     * @return the unwrapped exception (may be the given argument itself).
+     *
+     * @since 0.8
+     */
+    public static Exception unwrap(Exception exception) {
+        if (exception != null) {
+            while (exception instanceof InvocationTargetException ||
+                   exception instanceof BackingStoreException ||
+                   exception instanceof UncheckedIOException)
+            {
+                final Throwable cause = exception.getCause();
+                if (!(cause instanceof Exception)) break;
+                exception = (Exception) cause;
+            }
+            for (Throwable cause; exception.getClass().isInstance(cause = exception.getCause());)
{
+                exception = (Exception) cause;      // Should never fail because of isInstance(…)
check.
+            }
+        }
+        return exception;
+    }
 }

Modified: sis/branches/JDK8/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/pom.xml?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/pom.xml (original)
+++ sis/branches/JDK8/pom.xml Sun Apr 23 21:38:29 2017
@@ -24,10 +24,6 @@
          xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
                                http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
-  <prerequisites>
-    <maven>3.2.2</maven>
-  </prerequisites>
-
   <parent>
     <groupId>org.apache</groupId>
     <artifactId>apache</artifactId>

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -20,7 +20,9 @@ import java.util.Locale;
 import java.util.Collection;
 import org.apache.sis.storage.DataStores;
 import org.apache.sis.storage.DataStoreProvider;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.collection.BackingStoreException;
 
 // Branch-dependent imports
 import org.opengis.util.InternationalString;
@@ -97,10 +99,16 @@ public enum Capability {
              * Get a title for the format, followed by the short name between parenthesis
              * if it does not repeat the main title.
              */
-            String title = title(provider.getFormat().getFormatSpecificationCitation()).toString(locale);
-            final String abbreviation = provider.getShortName();
-            if (abbreviation != null && !abbreviation.equals(title)) {
-                title = resources.getString(Vocabulary.Keys.Parenthesis_2, title, abbreviation);
+            String title, complement;
+            try {
+                title = title(provider.getFormat().getFormatSpecificationCitation()).toString(locale);
+                complement = provider.getShortName();
+            } catch (BackingStoreException e) {
+                title = provider.getShortName();
+                complement = Exceptions.getLocalizedMessage(Exceptions.unwrap(e), locale);
+            }
+            if (complement != null && !complement.equals(title)) {
+                title = resources.getString(Vocabulary.Keys.Parenthesis_2, title, complement);
             }
             list[i++] = capabilities;
             list[i++] = title;

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -29,6 +29,7 @@ import java.nio.DoubleBuffer;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.SeekableByteChannel;
 import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.io.InvalidSeekException;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.Debug;
 
@@ -879,7 +880,7 @@ public class ChannelDataInput extends Ch
             /*
              * Requested position is before the current buffer limits and we can not seek.
              */
-            throw new IOException(Resources.format(Resources.Keys.StreamIsForwardOnly_1,
filename));
+            throw new InvalidSeekException(Resources.format(Resources.Keys.StreamIsForwardOnly_1,
filename));
         }
         clearBitOffset();
     }

Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java?rev=1792396&r1=1792395&r2=1792396&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] Sun Apr 23 21:38:29 2017
@@ -34,6 +34,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
+import static org.junit.Assume.*;
 import static org.opengis.test.Assert.*;
 
 
@@ -41,7 +42,7 @@ import static org.opengis.test.Assert.*;
  * Tests {@link StorageConnector}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
  * @since   0.3
  * @module
  */
@@ -179,7 +180,11 @@ public final strictfp class StorageConne
         /*
          * Request again the InputStream and read the same amount of bytes than above. The
intend of this test
          * is to verify that StorageConnector has reseted the InputStream position before
to return it.
+         * Note that this test requires InputStream implementations supporting mark/reset
operations
+         * (which is the case when the resource is an ordinary file, not an entry inside
a JAR file),
+         * otherwise the call to connection.getStorageAs(…) throws a DataStoreException.
          */
+        assumeTrue("Can not use a JAR file entry for this test.", in.markSupported());
         assertSame(in, connection.getStorageAs(InputStream.class));
         final byte[] actual = new byte[sample.length];
         assertEquals("Should read all requested bytes.", actual.length, in.read(actual));

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=1792396&r1=1792395&r2=1792396&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] Sun Apr 23 21:38:29 2017
@@ -46,6 +46,7 @@ import org.apache.sis.internal.util.Abst
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.Utilities;
 import org.apache.sis.io.wkt.WKTFormat;
+import org.apache.sis.io.InvalidSeekException;
 import org.apache.sis.storage.ConcurrentReadException;
 import org.apache.sis.storage.ConcurrentWriteException;
 import org.apache.sis.storage.DataStoreClosedException;
@@ -266,7 +267,7 @@ public abstract class StaxDataStore exte
      * @throws IOException if an error occurred while reseting the stream.
      */
     private boolean reset() throws IOException {
-        if (streamPosition >= 0) {
+        if (streamPosition >= 0) try {
             final Markable m = (Markable) stream;
             long p;
             do {
@@ -278,6 +279,8 @@ public abstract class StaxDataStore exte
                 state = START;
                 return true;
             }
+        } catch (InvalidSeekException e) {
+            listeners.warning(null, e);
         }
         return false;
     }



Mime
View raw message