sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1651201 [5/5] - in /sis/branches/JDK7: ./ application/sis-webapp/src/main/java/org/apache/sis/index/tree/ core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources...
Date Mon, 12 Jan 2015 21:22:19 GMT
Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -16,71 +16,47 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.io.File;
+import java.sql.*;
 import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.LogRecord;
-import java.sql.Wrapper;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLWarning;
-import org.apache.sis.util.logging.Logging;
+
+import org.apache.sis.internal.shapefile.AutoChecker;
 
 
 /**
  * Base class for each JDBC class.
- *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-abstract class AbstractJDBC implements Wrapper {
-    /**
-     * The logger for JDBC operations. We use the {@code "org.apache.sis.storage.jdbc"} logger name instead than
-     * the package name because this package is internal and may move in any future SIS version. The logger name
-     * does not need to be the name of an existing package. The important thing is to not change it, because it
-     * can been seen as a kind of public API since user may want to control verbosity level by logger names.
-     */
-    static final Logger LOGGER = Logging.getLogger("org.apache.sis.storage.jdbc");
-
+public abstract class AbstractJDBC extends AutoChecker implements Wrapper {
     /**
      * Constructs a new instance of a JDBC interface.
      */
-    AbstractJDBC() {
+    public AbstractJDBC() {
     }
 
     /**
      * Returns the JDBC interface implemented by this class.
      * This is used for formatting error messages.
-     *
      * @return The JDBC interface implemented by this class.
      */
-    abstract Class<?> getInterface();
+    abstract protected Class<?> getInterface();
 
     /**
      * Unsupported by default.
-     *
-     * @param  iface the type of the wrapped object.
+     * @param iface the type of the wrapped object.
      * @return The wrapped object.
      */
     @Override
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        throw unsupportedOperation("unwrap");
-    }
-
-    /**
-     * Default to {@code false}, assuming that no non-standard features are handled.
-     *
-     * @param  iface the type of the wrapped object.
-     * @return {@code true} if this instance is a wrapper for the given type of object.
-     */
-    @Override
-    public boolean isWrapperFor(Class<?> iface) {
-        return false;
+        throw unsupportedOperation("unwrap", iface);
     }
 
     /**
      * Defaults to {@code null}.
+     * @return SQL Warning.
      */
     public SQLWarning getWarnings() {
         return null;
@@ -94,36 +70,91 @@ abstract class AbstractJDBC implements W
 
     /**
      * Returns an unsupported operation exception to be thrown.
-     *
-     * @param  methodOrWishedFeatureName The feature / call the caller attempted.
-     * @return The exception to throw.
-     */
-    final SQLException unsupportedOperation(final String methodOrWishedFeatureName) {
-        return new SQLFeatureNotSupportedException(Resources.format(Resources.Keys.UnsupportedDriverFeature_2,
-                getInterface(), methodOrWishedFeatureName));
+     * @param methodOrWishedFeatureName The feature / call the caller attempted.
+     * @return the not supported feature exception.
+     * @throws SQLFeatureNotSupportedException the not supported feature.
+     */
+    public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName) throws SQLFeatureNotSupportedException {
+        String message = format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName());
+        throw new SQLFeatureNotSupportedException(message);
+    }
+
+    /**
+     * Returns an unsupported operation exception to be thrown : this exception add parameters sent to the method that isn't implemented.
+     * @param methodOrWishedFeatureName The feature / call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     * @return the not supported feature exception.
+     * @throws SQLFeatureNotSupportedException the not supported feature.
+     */
+    public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName, Object... args) throws SQLFeatureNotSupportedException {
+        StringBuffer arguments = new StringBuffer();
+
+        for(Object arg : args) {
+            arguments.append(arguments.length() == 0 ? "" : ", ");   // Separator if needed.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+            arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+        }
+
+        String message = format(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName(), arguments.toString());
+        throw new SQLFeatureNotSupportedException(message);
+    }
+
+    /**
+     * log a function call in the driver : very verbose.
+     * @param methodName The call the caller attempted.
+     */
+    public void logStep(final String methodName) {
+        format(Level.FINER, "log.step", methodName, getClass().getSimpleName());
+    }
+
+    /**
+     * log a function call in the driver : very verbose.
+     * @param methodName The call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     */
+    public void logStep(final String methodName, Object... args) {
+        format(Level.FINER, "log.step_with_arguments", methodName, getClass().getSimpleName(), arguments(args));
     }
 
     /**
      * log an unsupported feature as a warning.
-     *
      * @param methodName The call the caller attempted.
      */
-    final void logUnsupportedOperation(final String methodName) {
-        logWarning(methodName, Resources.Keys.UnsupportedDriverFeature_2, getInterface(), methodName);
+    public void logUnsupportedOperation(final String methodName) {
+        format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName());
     }
 
     /**
-     * Logs a warning with the given resource keys and arguments.
-     *
-     * @param methodName  The name of the method which is emitting the warning.
-     * @param resourceKey One of the {@link org.apache.sis.internal.shapefile.jdbc.Resources.Keys} values.
-     * @param arguments   Arguments to be given to {@link java.text.MessageFormat}, or {@code null} if none.
-     */
-    final void logWarning(final String methodName, final short resourceKey, final Object... arguments) {
-        final LogRecord record = Resources.getResources(null).getLogRecord(Level.WARNING, resourceKey, arguments);
-        record.setSourceClassName(getClass().getCanonicalName());
-        record.setSourceMethodName(methodName);
-        record.setLoggerName(LOGGER.getName());
-        LOGGER.log(record);
+     * log an unsupported feature as a warning.
+     * @param methodName The call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     */
+    public void logUnsupportedOperation(final String methodName, Object... args) {
+        format(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodName, getClass().getSimpleName(), arguments(args));
+    }
+
+    /**
+     * Returns the Database File.
+     * @return Database File.
+     */
+    abstract protected File getFile();
+
+    /**
+     * Concat arguments in a StringBuffer.
+     * @param args arguments.
+     * @return Arguments.
+     */
+    private StringBuffer arguments(Object... args) {
+        StringBuffer arguments = new StringBuffer();
+
+        for(Object arg : args) {
+            arguments.append(arguments.length() == 0 ? "" : ", ");   // Separator if needed.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+            arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+        }
+
+        return arguments;
     }
 }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -16,13 +16,13 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.io.*;
 import java.sql.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.logging.Logger;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.system.Modules;
+import java.util.*;
+import java.util.logging.*;
+
+import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
+import org.apache.sis.internal.system.*;
 
 
 /**
@@ -41,11 +41,19 @@ public class DBFDriver extends AbstractJ
     }
 
     /**
+     * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+     */
+    @Override
+    public boolean isWrapperFor(Class<?> iface) {
+        return iface.isAssignableFrom(getInterface());
+    }
+
+    /**
      * Returns the JDBC interface implemented by this class.
      * This is used for formatting error messages.
      */
     @Override
-    final Class<?> getInterface() {
+    final protected Class<?> getInterface() {
         return Driver.class;
     }
 
@@ -55,17 +63,17 @@ public class DBFDriver extends AbstractJ
      * @param  url  The path to a {@code .dbf} file.
      * @param  info Ignored in current implementation.
      * @return A connection to the given DBF file.
-     * @throws SQLException if this method can not create a connection to the given file.
+     * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+     * @throws DbaseFileNotFoundException if the database file doesn't exist.
+     * @throws InvalidDbaseFileFormatException if the database file has a wrong format.
      */
     @Override
-    public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLException {
-        ArgumentChecks.ensureNonNull("url", url);
-        try {
-            return new DBFConnection(new File(url));
-        } catch (IOException e) {
-            throw new SQLNonTransientConnectionException(Resources.format(
-                    Resources.Keys.InvalidDBFFormatDescriptor_2, url, e.getLocalizedMessage()));
-        }
+    @SuppressWarnings("resource") // the function opens a connection.
+    public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws InvalidDbaseFileFormatException, DbaseFileNotFoundException {
+        Objects.requireNonNull(url, "the DBase3 url cannot be null");
+        File file = new File(url);
+
+        return new DBFConnection(file, new MappedByteReader(file));
     }
 
     /**
@@ -76,16 +84,24 @@ public class DBFDriver extends AbstractJ
         if (!url.endsWith(".dbf")) {
             return false;
         }
+
         final File datafile = new File(url);
         return datafile.isFile(); // Future version should check for magic number.
     }
 
     /**
+     * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getFile()
+     */
+    @Override protected File getFile() {
+        return null;
+    }
+
+    /**
      * Gets information about the possible properties for this driver.
      * The current version has none.
      */
     @Override
-    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
+    public DriverPropertyInfo[] getPropertyInfo(@SuppressWarnings("unused") String url, @SuppressWarnings("unused") Properties info) {
         return new DriverPropertyInfo[0];
     }
 
@@ -122,6 +138,6 @@ public class DBFDriver extends AbstractJ
      */
     @Override
     public Logger getParentLogger() {
-        return LOGGER;
+        return super.getLogger();
     }
 }

Copied: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java (from r1651177, sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java?p2=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java&p1=sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java&r1=1651177&r2=1651201&rev=1651201&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -99,7 +99,7 @@ public class DBase3FieldDescriptor exten
      * @return Decimal count.
      */
     public int getDecimalCount() {
-        return Byte.toUnsignedInt(this.fieldDecimalCount);
+        return this.fieldDecimalCount & 0xFF;
     }
 
     /**
@@ -107,7 +107,7 @@ public class DBase3FieldDescriptor exten
      * @return field length.
      */
     public int getLength() {
-        return Byte.toUnsignedInt(this.fieldLength);
+        return this.fieldLength & 0xFF;
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1651201&r1=1651177&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -22,7 +22,6 @@ import java.nio.charset.Charset;
 import java.sql.*;
 import java.util.*;
 import java.util.logging.Level;
-import java.util.stream.Collectors;
 
 import org.apache.sis.internal.shapefile.jdbc.*;
 import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
@@ -81,7 +80,7 @@ public class DBFConnection extends Abstr
             // Check if all the underlying connections that has been opened with this connection has been closed.
             // If not, we log a warning to help the developper.
             if (openedStatements.size() > 0) {
-                format(Level.WARNING, "log.statements_left_opened", openedStatements.size(), openedStatements.stream().map(DBFStatement::toString).collect(Collectors.joining(", ")));
+                format(Level.WARNING, "log.statements_left_opened", openedStatements.size(), openedStatements.toString());
             }
 
             byteReader.close();

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -16,8 +16,8 @@
  */
 
 /**
- * Allows access to {@link org.apache.sis.storage.shapefile} storage through JDBC driver.
- *
+ * Allows access to the DBase3 part of a shapefile through JDBC driver.
+ * Many exceptions are declared inside this package, to help trouble descriptions and permit precise unit tests.
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1651201&r1=1651177&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -26,7 +26,6 @@ import java.sql.SQLFeatureNotSupportedEx
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.Map;
-import java.util.function.Function;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
@@ -35,6 +34,10 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.sql.*;
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.Function;
+
+
 /**
  * A ResultSet based on a record.
  * @author Marc LE BIHAN
@@ -199,7 +202,11 @@ public class DBFRecordBasedResultSet ext
     public double getDouble(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         logStep("getDouble", columnLabel);
 
-        Double value = getNumeric(columnLabel, Double::parseDouble);
+        Double value = getNumeric(columnLabel, new Function<String,Double>() {
+            @Override public Double apply(final String value) {
+                return Double.parseDouble(value);
+            }
+        });
         wasNull = (value == null);
         return value != null ? value : 0.0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
@@ -227,7 +234,11 @@ public class DBFRecordBasedResultSet ext
     public float getFloat(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         logStep("getFloat", columnLabel);
 
-        Float value = getNumeric(columnLabel, Float::parseFloat);
+        Float value = getNumeric(columnLabel, new Function<String,Float>() {
+            @Override public Float apply(final String value) {
+                return Float.parseFloat(value);
+            }
+        });
         wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
@@ -255,7 +266,11 @@ public class DBFRecordBasedResultSet ext
     public int getInt(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         logStep("getInt", columnLabel);
 
-        Integer value = getNumeric(columnLabel, Integer::parseInt);
+        Integer value = getNumeric(columnLabel, new Function<String,Integer>() {
+            @Override public Integer apply(final String value) {
+                return Integer.parseInt(value);
+            }
+        });
         wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
@@ -283,7 +298,11 @@ public class DBFRecordBasedResultSet ext
     public long getLong(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         logStep("getLong", columnLabel);
 
-        Long value = getNumeric(columnLabel, Long::parseLong);
+        Long value = getNumeric(columnLabel, new Function<String,Long>() {
+            @Override public Long apply(final String value) {
+                return Long.parseLong(value);
+            }
+        });
         wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
@@ -405,7 +424,11 @@ public class DBFRecordBasedResultSet ext
     public short getShort(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         logStep("getShort", columnLabel);
 
-        Short value = getNumeric(columnLabel, Short::parseShort);
+        Short value = getNumeric(columnLabel, new Function<String,Short>() {
+            @Override public Short apply(final String value) {
+                return Short.parseShort(value);
+            }
+        });
         wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java?rev=1651201&r1=1651177&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -17,13 +17,17 @@
 package org.apache.sis.internal.shapefile.jdbc.sql;
 
 import java.util.Objects;
-import java.util.function.Function;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.AutoChecker;
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
 import org.apache.sis.internal.shapefile.jdbc.resultset.*;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.Function;
+import org.apache.sis.util.Numbers;
+
+
 /**
  * Base class for clause resolver.
  * @author Marc LE BIHAN
@@ -172,34 +176,21 @@ public abstract class ClauseResolver ext
         }
         else {
             // Else, attempt to promote their types to something equivalent on the two sides.
+            if (value1 instanceof Number && value2 instanceof Number) {
+                // Promote Short to Integer, Long, Float or Double.
+                final Class<? extends Number> widestClass = Numbers.widestClass(
+                        value1.getClass().asSubclass(Number.class),
+                        value2.getClass().asSubclass(Number.class));
+                Number n1 = Numbers.cast((Number) value1, widestClass);
+                Number n2 = Numbers.cast((Number) value2, widestClass);
+                return compare(rs, n1, n2);
+            }
 
-            // Promote Short to Integer, Long, Float or Double.
-            Integer compare = compareIfPromoted(rs, value1, value2, Short.class, Integer.class, Integer::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Long.class, Long::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Float.class, Float::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Double.class, Double::valueOf);
-
-            // Promote Integer to Long, Float or Double.
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Long.class, Long::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Float.class, Float::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Double.class, Double::valueOf);
-
-            // Promote Long to Float or Double.
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Long.class, Float.class, Float::valueOf);
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Long.class, Double.class, Double::valueOf);
-
-            // Promote Float to Double.
-            compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Float.class, Double.class, Double::valueOf);
-
-            // if we are here with still a null value in comparison result, we have found no matching at all.
+            // if we are here, we have found no matching at all.
             // Default to String comparison.
-            if (compare == null) {
-                String default1 = value1.toString();
-                String default2 = value2.toString();
-                return compare(rs, default1, default2);
-            }
-            else
-                return compare;
+            String default1 = value1.toString();
+            String default2 = value2.toString();
+            return compare(rs, default1, default2);
         }
     }
 

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java?rev=1651201&r1=1651177&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -22,7 +22,6 @@ import java.text.MessageFormat;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.logging.Level;
-import java.util.stream.Collectors;
 
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
 import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
@@ -164,7 +163,7 @@ public class DBFStatement extends Abstra
         // Check if all the underlying ResultSets that has been opened with this statement has been closed.
         // If not, we log a warning to help the developper.
         if (openedResultSets.size() > 0) {
-            format(Level.WARNING, "log.resultsets_left_opened", openedResultSets.size(), openedResultSets.stream().map(DBFResultSet::toString).collect(Collectors.joining(", ")));
+            format(Level.WARNING, "log.resultsets_left_opened", openedResultSets.size(), openedResultSets.toString());
         }
 
         isClosed = true;

Modified: sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -16,26 +16,15 @@
  */
 package org.apache.sis.storage.shapefile;
 
-import java.io.IOException;
-import java.nio.ByteOrder;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.io.FileInputStream;
-import java.util.HashMap;
-import java.util.Map;
+import java.io.File;
 import java.util.Objects;
-import java.text.MessageFormat;
-import com.esri.core.geometry.Point;
-import com.esri.core.geometry.Polygon;
-import com.esri.core.geometry.Polyline;
-import com.esri.core.geometry.Geometry;
-
-import org.apache.sis.feature.DefaultFeatureType;
-import org.apache.sis.feature.DefaultAttributeType;
-import org.apache.sis.storage.DataStoreException;
 
+import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
+import org.apache.sis.internal.shapefile.ShapefileNotFoundException;
+import org.apache.sis.internal.shapefile.jdbc.DbaseFileNotFoundException;
+import org.apache.sis.internal.shapefile.jdbc.InvalidDbaseFileFormatException;
+import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
 // Branch-dependent imports
-import org.opengis.feature.Feature;
 
 /**
  * Provides a ShapeFile Reader.
@@ -49,305 +38,37 @@ import org.opengis.feature.Feature;
  * @see <a href="http://ulisse.elettra.trieste.it/services/doc/dbase/DBFstruct.htm">dBASE III File Structure</a>
  */
 public class ShapeFile {
-    /** Name of the Geometry field. */
-    private static final String GEOMETRY_NAME = "geometry";
-
-    /** File code. */
-    public int FileCode; // big
-
-    /** File length. */
-    public int FileLength; // big // The value for file length is the total length of the file in 16-bit words
-
-    /** File version. */
-    public int Version; // little
-
-    /** Shapefile type. */
-    public ShapeTypeEnum ShapeType; // little
-
-    /** X Min. */
-    public double xmin; // little
-
-    /** Y Min. */
-    public double ymin; // little
-
-    /** X Max. */
-    public double xmax; // little
-
-    /** Y Max. */
-    public double ymax; // little
-
-    /** Z Min. */
-    public double zmin; // little
+    /** Shapefile. */
+    private File shapeFile;
 
-    /** Z Max. */
-    public double zmax; // little
-
-    /** M Min. */
-    public double mmin; // little
-
-    /** M Max. */
-    public double mmax; // little
-
-    /** Underlying databasefile content. */
-    private Database dbf;
-
-    /** Features existing in the shapefile. */
-    public Map<Integer, Feature> FeatureMap = new HashMap<>();
+    /** Database file. */
+    private File databaseFile;
 
     /**
      * Construct a Shapefile from a file.
      * @param shpfile file to read.
-     * @throws IOException if the file cannot be opened.
-     * @throws DataStoreException if the shapefile is not valid.
      */
-    public ShapeFile(String shpfile) throws IOException, DataStoreException {
+    public ShapeFile(String shpfile) {
         Objects.requireNonNull(shpfile, "The shapefile to load cannot be null.");
 
-        // Deduct database file name.
-        StringBuilder b = new StringBuilder(shpfile);
-        b.replace(shpfile.length() - 3, shpfile.length(), "dbf");
-
-        dbf = new Database(b.toString());
-
-        try (FileInputStream fis = new FileInputStream(shpfile); FileChannel fc = fis.getChannel();) {
-            int fsize = (int) fc.size();
-            MappedByteBuffer rf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fsize);
-
-            this.FileCode = rf.getInt();
-            rf.getInt();
-            rf.getInt();
-            rf.getInt();
-            rf.getInt();
-            rf.getInt();
-            this.FileLength = rf.getInt() * 2;
-
-            rf.order(ByteOrder.LITTLE_ENDIAN);
-            this.Version = rf.getInt();
-            this.ShapeType = ShapeTypeEnum.get(rf.getInt());
-            this.xmin = rf.getDouble();
-            this.ymin = rf.getDouble();
-            this.xmax = rf.getDouble();
-            this.ymax = rf.getDouble();
-            this.zmin = rf.getDouble();
-            this.zmax = rf.getDouble();
-            this.mmin = rf.getDouble();
-            this.mmax = rf.getDouble();
-            rf.order(ByteOrder.BIG_ENDIAN);
-
-            dbf.loadDescriptor();
-            final DefaultFeatureType featureType = getFeatureType(shpfile);
-
-            dbf.getByteBuffer().get(); // should be 0d for field terminator
-            loadFeatures(featureType, rf);
-        } finally {
-            dbf.close();
-        }
-    }
-
-    /**
-     * Returns the underlying database file.
-     * @return Underlying database file.
-     */
-    public Database getDatabase() {
-        return this.dbf;
-    }
-
-    /**
-     * Returns the feature count of the shapefile.
-     * @return Feature count.
-     */
-    public int getFeatureCount() {
-        return this.dbf.getRecordCount();
-    }
-
-    /**
-     * Load the features of a shapefile.
-     * @param featureType Features descriptor.
-     * @param rf byte buffer mapper.
-     * @throws DataStoreException if a validation problem occurs.
-     */
-    private void loadFeatures(DefaultFeatureType featureType, MappedByteBuffer rf) throws DataStoreException {
-        for (Integer i = 0; i < this.dbf.getRecordCount(); i++) {
-            // insert points into some type of list
-            int RecordNumber = rf.getInt();
-            @SuppressWarnings("unused")
-            int ContentLength = rf.getInt();
-
-            rf.order(ByteOrder.LITTLE_ENDIAN);
-            int iShapeType = rf.getInt();
-            final Feature f = featureType.newInstance();
-
-            ShapeTypeEnum type = ShapeTypeEnum.get(iShapeType);
-
-            if (type == null)
-                throw new DataStoreException(MessageFormat.format("The shapefile feature type {0} doesn''t match to any known feature type.", featureType));
-
-            switch (type) {
-            case Point:
-                loadPointFeature(rf, f);
-                break;
-
-            case Polygon:
-                loadPolygonFeature(rf, f);
-                break;
-
-            case PolyLine:
-                loadPolylineFeature(rf, f);
-                break;
+        shapeFile = new File(shpfile);
 
-            default:
-                throw new DataStoreException("Unsupported shapefile type: " + iShapeType);
-            }
-
-            rf.order(ByteOrder.BIG_ENDIAN);
-            // read in each Record and Populate the Feature
-
-            dbf.loadRowIntoFeature(f);
-
-            this.FeatureMap.put(RecordNumber, f);
-        }
-    }
-
-    /**
-     * Load point feature.
-     * @param rf Byte buffer.
-     * @param feature Feature to fill.
-     */
-    private void loadPointFeature(MappedByteBuffer rf, Feature feature) {
-        double x = rf.getDouble();
-        double y = rf.getDouble();
-        Point pnt = new Point(x, y);
-        feature.setPropertyValue(GEOMETRY_NAME, pnt);
-    }
-
-    /**
-     * Load polygon feature.
-     * @param rf Byte buffer.
-     * @param feature Feature to fill.
-     * @throws DataStoreException if the polygon cannot be handled.
-     */
-    private void loadPolygonFeature(MappedByteBuffer rf, Feature feature) throws DataStoreException {
-        /* double xmin = */rf.getDouble();
-        /* double ymin = */rf.getDouble();
-        /* double xmax = */rf.getDouble();
-        /* double ymax = */rf.getDouble();
-        int NumParts = rf.getInt();
-        int NumPoints = rf.getInt();
-
-        if (NumParts > 1) {
-            throw new DataStoreException("Polygons with multiple linear rings have not implemented yet.");
-        }
-
-        // read the one part
-        @SuppressWarnings("unused")
-        int Part = rf.getInt();
-        Polygon poly = new Polygon();
-
-        // create a line from the points
-        double xpnt = rf.getDouble();
-        double ypnt = rf.getDouble();
-        // Point oldpnt = new Point(xpnt, ypnt);
-        poly.startPath(xpnt, ypnt);
-
-        for (int j = 0; j < NumPoints - 1; j++) {
-            xpnt = rf.getDouble();
-            ypnt = rf.getDouble();
-            poly.lineTo(xpnt, ypnt);
-        }
-
-        feature.setPropertyValue(GEOMETRY_NAME, poly);
-    }
-
-    /**
-     * Load polyline feature.
-     * @param rf Byte buffer.
-     * @param feature Feature to fill.
-     */
-    private void loadPolylineFeature(MappedByteBuffer rf, Feature feature) {
-        /* double xmin = */rf.getDouble();
-        /* double ymin = */rf.getDouble();
-        /* double xmax = */rf.getDouble();
-        /* double ymax = */rf.getDouble();
-
-        int NumParts = rf.getInt();
-        int NumPoints = rf.getInt();
-
-        int[] NumPartArr = new int[NumParts + 1];
-
-        for (int n = 0; n < NumParts; n++) {
-            int idx = rf.getInt();
-            NumPartArr[n] = idx;
-        }
-        NumPartArr[NumParts] = NumPoints;
-
-        double xpnt, ypnt;
-        Polyline ply = new Polyline();
-
-        for (int m = 0; m < NumParts; m++) {
-            xpnt = rf.getDouble();
-            ypnt = rf.getDouble();
-            ply.startPath(xpnt, ypnt);
-
-            for (int j = NumPartArr[m]; j < NumPartArr[m + 1] - 1; j++) {
-                xpnt = rf.getDouble();
-                ypnt = rf.getDouble();
-                ply.lineTo(xpnt, ypnt);
-            }
-        }
-
-        feature.setPropertyValue(GEOMETRY_NAME, ply);
-    }
-
-    /**
-     * Create a feature descriptor.
-     * @param name Name of the field.
-     * @return The feature type.
-     */
-    private DefaultFeatureType getFeatureType(final String name) {
-        Objects.requireNonNull(name, "The feature name cannot be null.");
-
-        final int n = dbf.getFieldsDescriptor().size();
-        final DefaultAttributeType<?>[] attributes = new DefaultAttributeType<?>[n + 1];
-        final Map<String, Object> properties = new HashMap<>(4);
-
-        // Load data field.
-        for (int i = 0; i < n; i++) {
-            properties.put(DefaultAttributeType.NAME_KEY, dbf.getFieldsDescriptor().get(i).getName());
-            attributes[i] = new DefaultAttributeType<>(properties, String.class, 1, 1, null);
-        }
-
-        // Add geometry field.
-        properties.put(DefaultAttributeType.NAME_KEY, GEOMETRY_NAME);
-        attributes[n] = new DefaultAttributeType<>(properties, Geometry.class, 1, 1, null);
-
-        // Add name.
-        properties.put(DefaultAttributeType.NAME_KEY, name);
-        return new DefaultFeatureType(properties, false, null, attributes);
+        // Deduct database file name.
+        StringBuilder dbfFileName = new StringBuilder(shpfile);
+        dbfFileName.replace(shpfile.length() - 3, shpfile.length(), "dbf");
+        databaseFile = new File(dbfFileName.toString());
     }
 
     /**
-     * @see java.lang.Object#toString()
+     * Find features corresponding to an SQL request SELECT * FROM database.
+     * @return Features
+     * @throws SQLInvalidStatementException if the SQL statement is invalid.
+     * @throws DbaseFileNotFoundException if the database file has not been found.
+     * @throws ShapefileNotFoundException if the shapefile has not been found.
+     * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
      */
-    @Override
-    public String toString() {
-        StringBuilder s = new StringBuilder();
-        String lineSeparator = System.getProperty("line.separator", "\n");
-
-        s.append("FileCode: ").append(FileCode).append(lineSeparator);
-        s.append("FileLength: ").append(FileLength).append(lineSeparator);
-        s.append("Version: ").append(Version).append(lineSeparator);
-        s.append("ShapeType: ").append(ShapeType).append(lineSeparator);
-        s.append("xmin: ").append(xmin).append(lineSeparator);
-        s.append("ymin: ").append(ymin).append(lineSeparator);
-        s.append("xmax: ").append(xmax).append(lineSeparator);
-        s.append("ymax: ").append(ymax).append(lineSeparator);
-        s.append("zmin: ").append(zmin).append(lineSeparator);
-        s.append("zmax: ").append(zmax).append(lineSeparator);
-        s.append("mmin: ").append(mmin).append(lineSeparator);
-        s.append("mmax: ").append(mmax).append(lineSeparator);
-        s.append("------------------------").append(lineSeparator);
-        s.append(dbf.toString());
-
-        return s.toString();
+    public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, SQLInvalidStatementException, InvalidShapefileFormatException {
+        return new InputFeatureStream(shapeFile, databaseFile);
     }
 }

Copied: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java (from r1651177, sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java?p2=sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java&p1=sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java&r1=1651177&r2=1651201&rev=1651201&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -17,14 +17,14 @@ import org.apache.sis.util.logging.Loggi
 import org.junit.Before;
 
 /**
- * Base class to settle a common environment to all the JDBC tests : 
+ * Base class to settle a common environment to all the JDBC tests :
  * all these tests are currently based on the SignedBikeRoute_4326_clipped.dbf DBase 3 file.
  * @author Marc LE BIHAN
  */
 public abstract class AbstractTestBaseForInternalJDBC extends TestCase {
     /** Logger. */
     protected Logger log = Logging.getLogger(getClass().getName());
-    
+
     /** The database file to use for testing purpose.  */
     protected File dbfFile;
 
@@ -35,9 +35,9 @@ public abstract class AbstractTestBaseFo
      */
     public Connection connect() throws SQLException {
         final Driver driver = new DBFDriver();
-        return driver.connect(dbfFile.getAbsolutePath(), null);        
+        return driver.connect(dbfFile.getAbsolutePath(), null);
     }
-    
+
     /**
      * Test setup.
      * @throws URISyntaxException If an error occurred while getting the file to the test database.

Copied: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java (from r1651177, sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java?p2=sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java&p1=sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java&r1=1651177&r2=1651201&rev=1651201&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -48,7 +48,7 @@ public class DBFConnectionTest extends A
         assertTrue ("Connection should be closed", connection.isClosed());
         assertFalse("Connection should no more be valid", connection.isValid(0));
     }
-    
+
     /**
      * An attempt to use a closed connection must fail with the correct exception.
      * @throws SQLException if an error occurred while opening the database.
@@ -60,7 +60,7 @@ public class DBFConnectionTest extends A
         final Driver driver = new DBFDriver();
         final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
         connection.close();
-        
+
         // Then, attempt to use it.
         try {
             connection.createStatement();

Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -16,106 +16,189 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.sql.*;
-import java.io.File;
-import java.net.URL;
-import java.net.URISyntaxException;
-import org.apache.sis.storage.shapefile.Database;
-import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.test.TestCase;
-import org.junit.*;
+import java.text.MessageFormat;
+import java.util.ArrayList;
 
-import static org.junit.Assert.*;
+import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
+import org.apache.sis.test.DependsOnMethod;
+import org.junit.Test;
 
 
 /**
- * Tests {@link DBFResultSet}.
+ * Tests {@link DBFRecordBasedResultSet}.
  *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-public class DBFResultSetTest extends TestCase {
-    /**
-     * The database file to use for testing purpose.
-     */
-    private File dbfFile;
-
-    /**
-     * Test setup.
-     *
-     * @throws URISyntaxException If an error occurred while getting the file to the test database.
-     */
-    @Before
-    public void setup() throws URISyntaxException {
-        final URL url = Database.class.getResource("SignedBikeRoute_4326_clipped.dbf");
-        assertNotNull("The database file used for testing doesn't exist.", url);
-        dbfFile = new File(url.toURI());
-        assertTrue(dbfFile.isFile());
-    }
-
-    /**
-     * Open and close a connection.
-     *
-     * @throws SQLException if an error occurred while querying the database.
-     */
-    @Test
-    public void openCloseConnection() throws SQLException {
-        final Driver     driver     = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
-        assertFalse("Connection should be opened", connection.isClosed());
-        assertTrue ("Connection should be valid",  connection.isValid(0));
-
-        connection.close();
-        assertTrue ("Connection should be closed", connection.isClosed());
-        assertFalse("Connection should no more be valid", connection.isValid(0));
-    }
-
+public class DBFResultSetTest extends AbstractTestBaseForInternalJDBC {
     /**
      * Reads the first record.
-     *
      * @throws SQLException if an error occurred while querying the database.
      */
     @Test
-    @DependsOnMethod("openCloseConnection")
     public void readFirstRecord() throws SQLException {
-        final Driver     driver     = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
-        final Statement  stmt       = connection.createStatement();
-        final ResultSet  rs         = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
-        // We don't care currently of the request: we are returning everything each time.
-
-        rs.next();
-        assertEquals("getString(\"ST_NAME\")", "336TH ST", rs.getString("ST_NAME"));
-
-        rs.close();
-        stmt.close();
-        connection.close();
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+            rs.next();
+            assertEquals("getString(\"ST_NAME\")", "36TH ST", rs.getString("ST_NAME"));                                    // ST_NAME Character(29)
+            assertEquals("getInt(\"FNODE_\")", 1199, rs.getInt("FNODE_"));                                                 // FNODE_ Number(10, 0)
+            assertEquals("getDouble(\"SHAPE_LEN\")", 43.0881492571, rs.getDouble("SHAPE_LEN"), 0.1);                       // SHAPE_LEN Number(19, 11)
+            assertEquals("getBigDecimal(\"SHAPE_LEN\")", 43.0881492571, rs.getBigDecimal("SHAPE_LEN").doubleValue(), 0.1); // SHAPE_LEN Number(19, 11)
+            assertEquals("getDate(\"TR_DATE\")", null, rs.getDate("TR_DATE"));                       // TR_DATE Date(8)
+        }
     }
 
     /**
      * Read all the DBF records.
-     *
      * @throws SQLException if an error occurred while querying the database.
      */
     @Test
     @DependsOnMethod("readFirstRecord")
     public void readAllRecords() throws SQLException {
-        final Driver     driver     = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
-        final Statement  stmt       = connection.createStatement();
-        final ResultSet  rs         = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
-        // We don't care currently of the request: we are returning everything each time.
-
-        int count = 0;
-        while (rs.next()) {
-            count++;
-        }
-        assertTrue("Less than one record was readed.", count > 1);
-
-        rs.close();
-        stmt.close();
-        connection.close();
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+            int count = 0;
+
+            while(rs.next()) {
+                ArrayList<Object> record = new ArrayList<>();
+
+                record.add(rs.getLong("OBJECTID"));         // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("FNODE_"));           // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("TNODE_"));           // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("LPOLY_"));           // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("RPOLY_"));           // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("SCL_"));             // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("SCL_ID"));           // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("SCL_CODE"));         // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getString("DXF_LAYER"));      // Type : Character, Field length : 16, Decimal positions : 0
+                record.add(rs.getString("SIS_ID"));         // Type : Character, Field length : 12, Decimal positions : 0
+                record.add(rs.getString("QUAD_CODE"));      // Type : Character, Field length : 1, Decimal positions : 0
+                record.add(rs.getString("PRIME_ST"));       // Type : Character, Field length : 4, Decimal positions : 0
+                record.add(rs.getString("INT_SEQ"));        // Type : Character, Field length : 3, Decimal positions : 0
+                record.add(rs.getString("ST_NAME"));        // Type : Character, Field length : 29, Decimal positions : 0
+                record.add(rs.getString("FDPRE"));          // Type : Character, Field length : 2, Decimal positions : 0
+                record.add(rs.getString("FNAME"));          // Type : Character, Field length : 30, Decimal positions : 0
+                record.add(rs.getString("FTYPE"));          // Type : Character, Field length : 4, Decimal positions : 0
+                record.add(rs.getString("FDSUF"));          // Type : Character, Field length : 2, Decimal positions : 0
+                record.add(rs.getLong("LEFTRANGE1"));       // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("LEFTRANGE2"));       // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("RGTRANGE1"));        // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getLong("RGTRANGE2"));        // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getString("STREET"));         // Type : Character, Field length : 26, Decimal positions : 0
+                record.add(rs.getString("QUAD"));           // Type : Character, Field length : 2, Decimal positions : 0
+                record.add(rs.getString("FROM_ST"));        // Type : Character, Field length : 100, Decimal positions : 0
+                record.add(rs.getString("TO_ST"));          // Type : Character, Field length : 100, Decimal positions : 0
+                record.add(rs.getString("ODD_WARD"));       // Type : Character, Field length : 1, Decimal positions : 0
+                record.add(rs.getString("EVEN_WARD"));      // Type : Character, Field length : 1, Decimal positions : 0
+                record.add(rs.getString("WARD"));           // Type : Character, Field length : 3, Decimal positions : 0
+                record.add(rs.getString("FC"));             // Type : Character, Field length : 40, Decimal positions : 0
+                record.add(rs.getInt("NHS"));               // Type : Number, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("SIGNEDRTE1"));     // Type : Character, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("RTETYPE1"));       // Type : Character, Field length : 10, Decimal positions : 0
+                record.add(rs.getString("SIGNEDRTE2"));     // Type : Character, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("RTETYPE2"));       // Type : Character, Field length : 10, Decimal positions : 0
+                record.add(rs.getBigDecimal("AADT"));       // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("AADT_YEAR"));  // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("COM_SING_P")); // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("COM_SING_A")); // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("COM_COMB_P")); // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("COM_COMB_A")); // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getString("IS_ONEWAY"));      // Type : Number, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("TRAVEL_DIR"));     // Type : Character, Field length : 20, Decimal positions : 0
+                record.add(rs.getBigDecimal("LEN_MI"));     // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getLong("STUDY_NET"));        // Type : Number, Field length : 10, Decimal positions : 0
+                record.add(rs.getDate("TR_DATE"));          // Type : Date, Field length : 8, Decimal positions : 0
+                record.add(rs.getBigDecimal("AADT_2"));     // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("AADT_FINAL")); // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getBigDecimal("ROUTENET"));   // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getString("NOTES"));          // Type : Character, Field length : 50, Decimal positions : 0
+                record.add(rs.getBigDecimal("LENGTH_MI"));  // Type : Number, Field length : 19, Decimal positions : 8
+                record.add(rs.getInt("NET_MARCH"));         // Type : Number, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("SIGNED_JOI"));     // Type : Character, Field length : 5, Decimal positions : 0
+                record.add(rs.getString("SIGNED_FAC"));     // Type : Character, Field length : 30, Decimal positions : 0
+                record.add(rs.getString("NEW_USE"));        // Type : Character, Field length : 30, Decimal positions : 0
+                record.add(rs.getBigDecimal("SHAPE_LEN"));  // Type : Number, Field length : 19, Decimal positions : 11
+
+                count ++;
+                log.info(MessageFormat.format("Record {0,number} : {1}\n", count, record));
+            }
+
+            assertTrue("Less than one record was readed.", count > 1);
+        }
+    }
+
+    /**
+     * An attempt to use a closed resultSet must fail with the correct exception and message.
+     * @throws SQLException if an error occurred while opening the database, the statement or the resultset.
+     */
+    @Test
+    public void resultSetClosed() throws SQLException {
+        // 1) Open a connection, open a statement, open and close a ResultSet.
+        String sql = "SELECT * FROM SignedBikeRoute";
+
+        try(Connection connection = connect(); Statement stmt = connection.createStatement()) {
+            // Then, attempt to use it.
+            try {
+                ResultSet rs = stmt.executeQuery(sql);
+                rs.close();
+            }
+            catch(SQLConnectionClosedException e) {
+                assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
+                assertEquals("The SQL Query is exception is not well set.", e.getSQL(), sql);
+            }
+            catch(SQLException e) {
+                fail("Not the expected exception for using a closed ResultSet.");
+            }
+        }
+
+        // 2) Same, but we close the connection instead.
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        ResultSet rs = stmt.executeQuery(sql);
+
+        connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement and one ResultSet still opened.
+
+        // Then, attempt to use it.
+        try {
+            rs.next();
+        }
+        catch(SQLConnectionClosedException e) {
+            assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), dbfFile.getName());
+        }
+        catch(SQLException e) {
+            fail("Not the expected exception for using a closed ResultSet.");
+        }
+        finally {
+            rs.close();
+            stmt.close();
+        }
+
+        // 3) Same, but we close the statement instead .
+        try(Connection cnt = connect()) {
+            stmt = cnt.createStatement();
+            rs = stmt.executeQuery(sql);
+
+            stmt.close(); // At this time, you expect also a information message on the console, telling that the statement has closed its current ResultSet.
+
+            // Then, attempt to use it.
+            try {
+                rs.next();
+            }
+            catch(SQLConnectionClosedException e) {
+                assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), dbfFile.getName());
+            }
+            catch(SQLException e) {
+                fail("Not the expected exception for using a closed ResultSet.");
+            }
+            finally {
+                rs.close();
+                stmt.close();
+            }
+        }
     }
 }

Copied: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java (from r1651177, sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java?p2=sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java&p1=sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java&r1=1651177&r2=1651201&rev=1651201&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -40,16 +40,16 @@ public class DBFStatementTest extends Ab
     @Test
     public void openCloseStatement() throws SQLException {
         final Driver driver = new DBFDriver();
-        
+
         try(Connection connection = driver.connect(dbfFile.getAbsolutePath(), null)) {
             final Statement stmt = connection.createStatement();
             assertFalse("Statement should be opened", stmt.isClosed());
-    
+
             stmt.close();
             assertTrue ("Statement should be closed", stmt.isClosed());
         }
     }
-    
+
     /**
      * An attempt to use a closed statement must fail with the correct exception.
      * @throws SQLException if an error occurred while opening the database or the statement.
@@ -61,32 +61,32 @@ public class DBFStatementTest extends Ab
         try(Connection connection = connect()) {
             final Statement stmt = connection.createStatement();
             stmt.close();
-            
+
             // Then, attempt to use it.
             try {
                 stmt.executeQuery("Must detect that the statement is closed, and not try to parse this query.");
-            } 
+            }
             catch(SQLConnectionClosedException e) {
                 assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
-            } 
+            }
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed statement.");
             }
         }
-        
+
         // Same, but we close the connection instead.
         Connection connection = connect();
         final Statement stmt = connection.createStatement();
-        
+
         connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement still opened.
-        
+
         // Then, attempt to use it.
         try {
             stmt.executeQuery("Must detect that the statement is closed, and not try to parse this query.");
-        } 
+        }
         catch(SQLConnectionClosedException e) {
             assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
-        } 
+        }
         catch(SQLException e) {
             fail("Not the expected exception for using a closed statement.");
         }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java?rev=1651201&r1=1651177&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -22,47 +22,55 @@ public class WhereClauseTest extends Abs
     public void operators() throws SQLException {
         try(Connection connection = connect(); Statement stmt = connection.createStatement(); DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
             rs.next();
-            
+
             assertTrue("FNODE_ = 1199", new ConditionalClauseResolver("FNODE_", 1199L, "=").isVerified(rs));
             assertFalse("FNODE_ > 1199", new ConditionalClauseResolver("FNODE_", 1199L, ">").isVerified(rs));
             assertFalse("FNODE_ < 1199", new ConditionalClauseResolver("FNODE_", 1199L, "<").isVerified(rs));
             assertTrue("FNODE_ >= 1199", new ConditionalClauseResolver("FNODE_", 1199L, ">=").isVerified(rs));
             assertTrue("FNODE_ <= 1199", new ConditionalClauseResolver("FNODE_", 1199L, "<=").isVerified(rs));
-            
+
             assertTrue("FNODE_ > 1198", new ConditionalClauseResolver("FNODE_", 1198L, ">").isVerified(rs));
             assertFalse("FNODE_ < 1198", new ConditionalClauseResolver("FNODE_", 1198L, "<").isVerified(rs));
             assertTrue("FNODE_ >= 1198", new ConditionalClauseResolver("FNODE_", 1198L, ">=").isVerified(rs));
             assertFalse("FNODE_ <= 1198", new ConditionalClauseResolver("FNODE_", 1198L, "<=").isVerified(rs));
-            
+
             assertFalse("FNODE_ > 1200", new ConditionalClauseResolver("FNODE_", 1200L, ">").isVerified(rs));
             assertTrue("FNODE_ < 1200", new ConditionalClauseResolver("FNODE_", 1200L, "<").isVerified(rs));
             assertFalse("FNODE_ >= 1200", new ConditionalClauseResolver("FNODE_", 1200L, ">=").isVerified(rs));
             assertTrue("FNODE_ <= 1200", new ConditionalClauseResolver("FNODE_", 1200L, "<=").isVerified(rs));
-            
+
             assertTrue("ST_NAME = '36TH ST'", new ConditionalClauseResolver("ST_NAME", "'36TH ST'", "=").isVerified(rs));
-            
+
             assertTrue("SHAPE_LEN = 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "=").isVerified(rs));
             assertTrue("SHAPE_LEN > 43.088", new ConditionalClauseResolver("SHAPE_LEN", 43.088, ">").isVerified(rs));
             assertFalse("SHAPE_LEN < 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "<").isVerified(rs));
         }
     }
-    
+
     /**
      * Test where conditions : field [operator] integer.
      * @throws SQLException if a trouble occurs : all tests shall pass.
      */
     @Test
     public void whereCondition_field_literal_int() throws SQLException {
-        checkAndCount("FNODE_ < 2000", rs -> rs.getInt("FNODE_") < 2000, 3);
+        checkAndCount("FNODE_ < 2000", new ResultSetPredicate<ResultSet>() {
+            @Override public boolean test(ResultSet rs) throws SQLException {
+                return rs.getInt("FNODE_") < 2000;
+            }
+        }, 3);
     }
-    
+
     /**
      * Test where conditions : field [operator] integer.
      * @throws SQLException if a trouble occurs : all tests shall pass.
      */
     @Test
     public void whereCondition_field_literal_double() throws SQLException {
-        checkAndCount("SHAPE_LEN < 70.5", rs -> rs.getDouble("SHAPE_LEN") < 70.5, 3);
+        checkAndCount("SHAPE_LEN < 70.5", new ResultSetPredicate<ResultSet>() {
+            @Override public boolean test(ResultSet rs) throws SQLException {
+                return rs.getDouble("SHAPE_LEN") < 70.5;
+            }
+        }, 3);
     }
 
     /**
@@ -71,7 +79,11 @@ public class WhereClauseTest extends Abs
      */
     @Test
     public void whereCondition_field_literal_string() throws SQLException {
-        checkAndCount("FNAME = '36TH'", rs -> rs.getString("FNAME").equals("36TH"), 1);
+        checkAndCount("FNAME = '36TH'", new ResultSetPredicate<ResultSet>() {
+            @Override public boolean test(ResultSet rs) throws SQLException {
+                return rs.getString("FNAME").equals("36TH");
+            }
+        }, 1);
     }
 
     /**
@@ -80,15 +92,18 @@ public class WhereClauseTest extends Abs
      */
     @Test
     public void whereCondition_field_field() throws SQLException {
-        checkAndCount("FNODE_ < TNODE_", rs -> rs.getInt("FNODE_") < rs.getInt("TNODE_"), 1);
+        checkAndCount("FNODE_ < TNODE_", new ResultSetPredicate<ResultSet>() {
+            @Override public boolean test(ResultSet rs) throws SQLException {
+                return rs.getInt("FNODE_") < rs.getInt("TNODE_");
+            }
+        }, 1);
     }
-    
-    /** 
-     * Trick suggested by AdiGuba (Forum des développeurs) to avoid the exception thrown by ResultSet:getInt(), 
+
+    /**
+     * Trick suggested by AdiGuba (Forum des développeurs) to avoid the exception thrown by ResultSet:getInt(),
      * unhandlable by a simple Predicate.
-     * @param <T> Type used. 
-     */ 
-    @FunctionalInterface
+     * @param <T> Type used.
+     */
     public interface ResultSetPredicate<T> {
         /**
          * Test a condition.
@@ -98,7 +113,7 @@ public class WhereClauseTest extends Abs
          */
         boolean test(T condition) throws SQLException;
     }
-    
+
     /**
      * Check that all records match the conditions and count them.
      * @param whereCondition The where condition to add to a "SELECT * FROM SignedBikeRoute WHERE " statement.
@@ -108,15 +123,15 @@ public class WhereClauseTest extends Abs
      */
     private void checkAndCount(String whereCondition, ResultSetPredicate<ResultSet> condition, int countExpected) throws SQLException {
         String sql = "SELECT * FROM SignedBikeRoute WHERE " + whereCondition;
-        
+
         try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
             int count = 0;
-            
+
             while(rs.next()) {
                 count ++;
                 assertTrue(sql, condition.test(rs));
             }
-            
+
             if (countExpected != -1)
                 assertEquals("Wrong number of records red by : " + sql, countExpected, count);
         }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -17,13 +17,13 @@
 package org.apache.sis.storage.shapefile;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URISyntaxException;
-import org.apache.sis.storage.DataStoreException;
+import java.sql.SQLException;
+
+import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.opengis.feature.Feature;
 
 
 /**
@@ -48,36 +48,52 @@ public final strictfp class ShapeFileTes
     /**
      * Test polylines count.
      * @throws URISyntaxException if the resource name is incorrect.
-     * @throws IOException if the shapefile cannot be found or an I/O error occurs.
-     * @throws DataStoreException if the shapefile has a structure problem.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws SQLException if any SQL Exception occuring.
      */
     @Test
-    public void testPolyineCount() throws URISyntaxException, IOException, DataStoreException {
+    public void testPolyineCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
         ShapeFile shp = new ShapeFile(path("SignedBikeRoute_4326_clipped.shp"));
-        assertEquals(shp.FeatureMap.size(), shp.getFeatureCount());
+        readAll(shp);
     }
 
     /**
      * Test polygon count.
      * @throws URISyntaxException if the resource name is incorrect.
-     * @throws IOException if the shapefile cannot be found or an I/O error occurs.
-     * @throws DataStoreException if the shapefile has a structure problem.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws SQLException if any SQL Exception occuring.
      */
      @Test
-     public void testPolygonCount() throws URISyntaxException, IOException, DataStoreException {
+     public void testPolygonCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
         ShapeFile shp = new ShapeFile(path("ANC90Ply_4326.shp"));
-        assertEquals(shp.FeatureMap.size(), shp.getFeatureCount());
+        readAll(shp);
     }
 
      /**
       * Test point count.
       * @throws URISyntaxException if the resource name is incorrect.
-      * @throws IOException if the shapefile cannot be found or an I/O error occurs.
-      * @throws DataStoreException if the shapefile has a structure problem.
+      * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+      * @throws SQLException if any SQL Exception occuring.
       */
      @Test
-     public void testPointCount() throws URISyntaxException, IOException, DataStoreException {
+     public void testPointCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
         ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
-        assertEquals(shp.FeatureMap.size(), shp.getFeatureCount());
+        readAll(shp);
+     }
+
+    /**
+     * Read all the shapefile content.
+     * @param shp Shapefile to read.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws SQLException if any SQL Exception occuring.
+     */
+    private void readAll(ShapeFile shp) throws SQLException, InvalidShapefileFormatException {
+        try(InputFeatureStream is = shp.findAll()) {
+            Feature feature = is.readFeature();
+
+            while(feature != null) {
+                feature = is.readFeature();
+            }
+        }
     }
 }

Modified: sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java?rev=1651201&r1=1651200&r2=1651201&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] Mon Jan 12 21:22:17 2015
@@ -26,7 +26,10 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.storage.shapefile.ShapeFileTest.class,
-    org.apache.sis.internal.shapefile.jdbc.DBFResultSetTest.class
+    org.apache.sis.internal.shapefile.jdbc.DBFConnectionTest.class,
+    org.apache.sis.internal.shapefile.jdbc.DBFStatementTest.class,
+    org.apache.sis.internal.shapefile.jdbc.DBFResultSetTest.class,
+    org.apache.sis.internal.shapefile.jdbc.sql.WhereClauseTest.class
 })
 public final strictfp class ShapefileTestSuite extends TestSuite {
     /**



Mime
View raw message