sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1651610 [6/6] - in /sis/branches/JDK6: ./ 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 Wed, 14 Jan 2015 09:53:55 GMT
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.shapefile.jdbc.sql;
 
-import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.AutoChecker;
@@ -25,6 +24,7 @@ import org.apache.sis.internal.shapefile
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.Function;
+import org.apache.sis.internal.jdk7.Objects;
 import org.apache.sis.util.Numbers;
 
 
@@ -116,26 +116,24 @@ public abstract class ClauseResolver ext
      * @throws SQLConnectionClosedException if the connection is closed.
      */
     public boolean isVerified(DBFRecordBasedResultSet rs) throws SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException {
-        switch(getOperator()) {
-            case "=" :
-                return compare(rs) == 0;
+        final String v = getOperator();
+        if (v.equals("="))
+            return compare(rs) == 0;
 
-            case ">" :
-                return compare(rs) > 0;
+        if (v.equals(">"))
+            return compare(rs) > 0;
 
-            case ">=" :
-                return compare(rs) >= 0;
+        if (v.equals(">="))
+            return compare(rs) >= 0;
 
-            case "<" :
-                return compare(rs) < 0;
+        if (v.equals("<"))
+            return compare(rs) < 0;
 
-            case "<=" :
-                return compare(rs) <= 0;
+        if (v.equals("<="))
+            return compare(rs) <= 0;
 
-            default :
-                 String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
-                 throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
-        }
+        String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
+        throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
     }
 
     /**
@@ -311,8 +309,11 @@ public abstract class ClauseResolver ext
         }
         else {
             // The string designs a field name, return its value.
-            try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL())) {
+            DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL());
+            try {
                 return valueOf(rs, field);
+            } finally {
+                field.close();
             }
         }
     }
@@ -331,52 +332,51 @@ public abstract class ClauseResolver ext
     private Object valueOf(DBFRecordBasedResultSet rs, DBFBuiltInMemoryResultSetForColumnsListing field) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLUnsupportedParsingFeatureException, SQLNotDateException {
         String columnName = field.getString("COLUMN_NAME");
 
-        switch(field.getString("TYPE_NAME")) {
-            case "AUTO_INCREMENT":
-                return rs.getInt(columnName);
-
-            case "CHAR":
-                return rs.getString(columnName);
+        final String v = field.getString("TYPE_NAME");
+        if (v.equals("AUTO_INCREMENT"))
+            return rs.getInt(columnName);
 
-            case "INTEGER":
-                return rs.getInt(columnName);
+        if (v.equals("CHAR"))
+            return rs.getString(columnName);
 
-            case "DATE":
-                return rs.getDate(columnName);
+        if (v.equals("INTEGER"))
+            return rs.getInt(columnName);
 
-            case "DOUBLE":
-                return rs.getDouble(columnName);
+        if (v.equals("DATE"))
+            return rs.getDate(columnName);
 
-            case "FLOAT":
-                return rs.getFloat(columnName);
+        if (v.equals("DOUBLE"))
+            return rs.getDouble(columnName);
 
+        if (v.equals("FLOAT"))
+            return rs.getFloat(columnName);
 
-            case "DECIMAL": {
-                // Choose Integer or Long type, if no decimal and that the field is not to big.
-                if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
-                    if (field.getInt("COLUMN_SIZE") <= 9)
-                        return rs.getInt(columnName);
-                    else
-                        return rs.getLong(columnName);
-                }
 
-                return rs.getDouble(columnName);
+        if (v.equals("DECIMAL")) {
+            // Choose Integer or Long type, if no decimal and that the field is not to big.
+            if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
+                if (field.getInt("COLUMN_SIZE") <= 9)
+                    return rs.getInt(columnName);
+                else
+                    return rs.getLong(columnName);
             }
 
-            case "BOOLEAN":
-            case "CURRENCY":
-            case "DATETIME":
-            case "TIMESTAMP":
-            case "MEMO":
-            case "PICTURE":
-            case "VARIFIELD":
-            case "VARIANT":
-            case "UNKNOWN":
-                String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
-                throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
+            return rs.getDouble(columnName);
+        }
 
-            default:
-                throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
+        if (v.equals("BOOLEAN") ||
+            v.equals("CURRENCY") ||
+            v.equals("DATETIME") ||
+            v.equals("TIMESTAMP") ||
+            v.equals("MEMO") ||
+            v.equals("PICTURE") ||
+            v.equals("VARIFIELD") ||
+            v.equals("VARIANT") ||
+            v.equals("UNKNOWN"))
+        {
+            String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
+            throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
         }
+        throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
     }
 }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -17,12 +17,15 @@
 package org.apache.sis.internal.shapefile.jdbc.sql;
 
 import java.io.File;
-import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
 import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * Simple and temporary SQL parser.
  * @author Marc LE BIHAN

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -293,7 +293,6 @@ abstract class AbstractStatement extends
     /**
      * Unsupported by default.
      */
-    @Override
     public void closeOnCompletion() throws SQLException {
         throw unsupportedOperation("closeOnCompletion");
     }
@@ -301,7 +300,6 @@ abstract class AbstractStatement extends
     /**
      * Unsupported by default.
      */
-    @Override
     public boolean isCloseOnCompletion() throws SQLException {
         throw unsupportedOperation("isCloseOnCompletion");
     }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -20,7 +20,6 @@ import java.io.File;
 import java.sql.*;
 import java.text.MessageFormat;
 import java.util.HashSet;
-import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
@@ -29,6 +28,9 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
 import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
 
 /**
  * DBF Statement.
@@ -42,7 +44,7 @@ public class DBFStatement extends Abstra
     private DBFConnection connection;
 
     /** ResultSets that are currently opened. */
-    private HashSet<DBFResultSet> openedResultSets = new HashSet<>();
+    private HashSet<DBFResultSet> openedResultSets = new HashSet<DBFResultSet>();
 
     /** The current result set, or {@code null} if none. */
     private DBFResultSet currentResultSet;

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -154,7 +154,8 @@ public class InputFeatureStream extends
             shapefileReader.completeFeature(feature);
             DBFDatabaseMetaData metadata = (DBFDatabaseMetaData)connection.getMetaData();
 
-            try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null)) {
+            DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null);
+            try {
                 while(rsDatabase.next()) {
                     String fieldName = rsDatabase.getString("COLUMN_NAME");
                     Object fieldValue = rs.getObject(fieldName);
@@ -189,6 +190,8 @@ public class InputFeatureStream extends
             catch(SQLNoResultException e) {
                 // This an internal trouble, if it occurs.
                 throw new RuntimeException(e.getMessage(), e);
+            } finally {
+                rsDatabase.close();
             }
         }
         catch(SQLNoResultException e) {

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,26 +16,17 @@
  */
 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.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 java.io.File;
 
-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.apache.sis.internal.jdk7.Objects;
-import org.opengis.feature.Feature;
+
 
 /**
  * Provides a ShapeFile Reader.
@@ -49,309 +40,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<Integer, Feature>();
+    /** 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());
-
-        FileInputStream fis = new FileInputStream(shpfile);
-        FileChannel fc = fis.getChannel();
-        try {
-            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();
-            fc.close();
-            fis.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<String, Object>(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<String>(properties, String.class, 1, 1, null);
-        }
-
-        // Add geometry field.
-        properties.put(DefaultAttributeType.NAME_KEY, GEOMETRY_NAME);
-        attributes[n] = new DefaultAttributeType<Geometry>(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);
     }
 }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,106 +16,210 @@
  */
 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();
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+        try {
+            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)
+        } finally {
+            rs.close();
+            stmt.close();
+            connection.close();
+        }
     }
 
     /**
      * 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();
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+        try {
+            int count = 0;
+
+            while(rs.next()) {
+                ArrayList<Object> record = new ArrayList<Object>();
+
+                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);
+        } finally {
+            rs.close();
+            stmt.close();
+            connection.close();
+        }
+    }
+
+    /**
+     * 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";
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        try {
+            // 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.");
+            }
+        } finally {
+            stmt.close();
+            connection.close();
+        }
+
+        // 2) Same, but we close the connection instead.
+        connection = connect();
+        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 .
+        Connection cnt = connect();
+        try {
+            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();
+            }
+        } finally {
+            cnt.close();
+        }
     }
 }

Copied: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -41,12 +41,15 @@ public class DBFStatementTest extends Ab
     public void openCloseStatement() throws SQLException {
         final Driver driver = new DBFDriver();
 
-        try(Connection connection = driver.connect(dbfFile.getAbsolutePath(), null)) {
+        Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        try {
             final Statement stmt = connection.createStatement();
             assertFalse("Statement should be opened", stmt.isClosed());
 
             stmt.close();
             assertTrue ("Statement should be closed", stmt.isClosed());
+        } finally {
+            connection.close();
         }
     }
 
@@ -58,7 +61,8 @@ public class DBFStatementTest extends Ab
     @DependsOnMethod("openCloseStatement")
     public void statementClosed() throws SQLException {
         // Open a connection, open and close a statement.
-        try(Connection connection = connect()) {
+        Connection connection = connect();
+        try {
             final Statement stmt = connection.createStatement();
             stmt.close();
 
@@ -72,10 +76,12 @@ public class DBFStatementTest extends Ab
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed statement.");
             }
+        } finally {
+            connection.close();
         }
 
         // Same, but we close the connection instead.
-        Connection connection = connect();
+        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.

Modified: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -36,7 +36,10 @@ public class WhereClauseTest extends Abs
      */
     @Test
     public void operators() throws SQLException {
-        try(Connection connection = connect(); Statement stmt = connection.createStatement(); DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+        try {
             rs.next();
 
             assertTrue("FNODE_ = 1199", new ConditionalClauseResolver("FNODE_", 1199L, "=").isVerified(rs));
@@ -60,6 +63,10 @@ public class WhereClauseTest extends Abs
             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));
+        } finally {
+            rs.close();
+            stmt.close();
+            connection.close();
         }
     }
 
@@ -140,7 +147,10 @@ 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)) {
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
+        ResultSet rs = stmt.executeQuery(sql);
+        try {
             int count = 0;
 
             while(rs.next()) {
@@ -150,6 +160,10 @@ public class WhereClauseTest extends Abs
 
             if (countExpected != -1)
                 assertEquals("Wrong number of records red by : " + sql, countExpected, count);
+        } finally {
+            rs.close();
+            stmt.close();
+            connection.close();
         }
     }
 }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Wed Jan 14 09:53:53 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,55 @@ 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 {
+        InputFeatureStream is = shp.findAll();
+        try {
+            Feature feature = is.readFeature();
+
+            while(feature != null) {
+                feature = is.readFeature();
+            }
+        } finally {
+            is.close();
+        }
     }
 }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] Wed Jan 14 09:53:53 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