sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1792404 - in /sis/trunk: ./ 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/apache/sis/in...
Date Sun, 23 Apr 2017 21:50:55 GMT
Author: desruisseaux
Date: Sun Apr 23 21:50:55 2017
New Revision: 1792404

URL: http://svn.apache.org/viewvc?rev=1792404&view=rev
Log:
Merge from JDK7 branch.

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

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Apr 23 21:50:55 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1792304
-/sis/branches/JDK8:1584960-1792299
+/sis/branches/JDK7:1394913-1792398
+/sis/branches/JDK8:1584960-1792396
 /sis/branches/JDK9:1773327-1789983

Modified: sis/trunk/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/pom.xml?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/pom.xml (original)
+++ sis/trunk/core/sis-build-helper/pom.xml Sun Apr 23 21:50:55 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/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/CachedStatement.java
[UTF-8] Sun Apr 23 21:50:55 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/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Sun Apr 23 21:50:55 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;
@@ -41,7 +42,6 @@ import java.sql.Statement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLNonTransientException;
-import java.io.IOException;
 import java.sql.PreparedStatement;
 import org.opengis.annotation.UML;
 import org.opengis.util.CodeList;
@@ -67,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;
 
@@ -392,7 +393,11 @@ public class MetadataSource implements A
             final Installer installer = new Installer(connection);
             installer.run();
         } catch (IOException | SQLException e) {
-            throw new MetadataStoreException(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.
+             */
+            throw new MetadataStoreException(e.getLocalizedMessage(), Exceptions.unwrap(e));
         }
     }
 
@@ -778,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/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] Sun Apr 23 21:50:55 2017
@@ -459,7 +459,11 @@ public class EPSGFactory extends Concurr
             } catch (SQLException e2) {
                 e.addSuppressed(e2);
             }
-            exception = new UnavailableFactoryException(message(e), 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.
+             */
+            exception = new UnavailableFactoryException(message(e), Exceptions.unwrap(e));
         }
         exception.setUnavailableFactory(this);
         throw exception;

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolationTest.java
[UTF-8] Sun Apr 23 21:50:55 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;
@@ -28,7 +27,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;
 
@@ -46,7 +44,7 @@ import org.apache.sis.internal.jdk8.JDK8
  * @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.
@@ -138,9 +136,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 = JDK8.newBufferedReader(file)) {
             grid = FranceGeocentricInterpolation.load(in, file);
@@ -231,17 +227,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/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NADCONTest.java
[UTF-8] Sun Apr 23 21:50:55 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 javax.measure.quantity.Angle;
 import org.opengis.geometry.Envelope;
 import org.opengis.util.FactoryException;
@@ -31,7 +29,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.apache.sis.test.Assert.*;
@@ -49,7 +46,7 @@ import org.apache.sis.internal.jdk8.JDK8
  * @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
@@ -104,12 +101,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/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/NTv2Test.java
[UTF-8] Sun Apr 23 21:50:55 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.apache.sis.test.Assert.*;
@@ -49,7 +46,7 @@ import static org.apache.sis.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.
@@ -72,9 +69,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/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
[UTF-8] Sun Apr 23 21:50:55 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/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
[UTF-8] Sun Apr 23 21:50:55 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);

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Sun Apr
23 21:50:55 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Sun
Apr 23 21:50:55 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 org.apache.sis.internal.jdk8.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/trunk/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/pom.xml?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/pom.xml (original)
+++ sis/trunk/pom.xml Sun Apr 23 21:50:55 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/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Capability.java
[UTF-8] Sun Apr 23 21:50:55 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.metadata.distribution.Format;
@@ -98,14 +100,19 @@ public enum Capability {
              * if it does not repeat the main title.
              */
             final Format format = provider.getFormat();
-            String title = Types.toString(format.getSpecification(), locale);
-            final String abbreviation = Types.toString(format.getName(), locale);
-            if (abbreviation != null) {
+            String title, complement;
+            try {
+                title = Types.toString(format.getSpecification(), locale);
                 if (title == null) {
-                    title = abbreviation;
-                } else if (!abbreviation.equals(title)) {
-                    title = resources.getString(Vocabulary.Keys.Parenthesis_2, title, abbreviation);
+                    title = Types.toString(format.getName(), 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/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
[UTF-8] Sun Apr 23 21:50:55 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;
 
@@ -882,7 +883,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/trunk/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] Sun Apr 23 21:50:55 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/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1792404&r1=1792403&r2=1792404&view=diff
==============================================================================
--- sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] Sun Apr 23 21:50:55 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