CSVDataStore extends ContentDataStore implements FileDataStore { @Override public SimpleFeatureSource getFeatureSource() throws IOException { return new CSVFeatureSource(this); } CSVDataStore(CSVFileState csvFileState, CSVStrategy csvStrategy); Name getTypeName(); @Override SimpleFeatureType getSchema(); @Override void updateSchema(SimpleFeatureType featureType); @Override SimpleFeatureSource getFeatureSource(); @Override FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Filter filter,
            Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(
            Transaction transaction); CSVStrategy getCSVStrategy(); @Override void createSchema(SimpleFeatureType featureType);  }
@Test public void testOffset() throws FileNotFoundException, IOException { Query query = new Query(Query.ALL); query.setStartIndex(3); SimpleFeatureSource rows = csvDataStore.getFeatureSource(); SimpleFeatureCollection matches = rows.getFeatures(query); List<String> offsetCities = Arrays.asList("Ottawa", "Minneapolis", "Lausanne", "Victoria", "Cape Town", "Sydney"); int count = 0; SimpleFeatureIterator iter = matches.features(); while(iter.hasNext()) { SimpleFeature f = iter.next(); assertTrue(offsetCities.contains(f.getAttribute("CITY"))); count++; } iter.close(); assertEquals(6, count); assertEquals(6, matches.size()); assertEquals(6, rows.getCount(query)); }
@Test public void testLimit() throws FileNotFoundException, IOException { Query query = new Query(Query.ALL); query.setMaxFeatures(3); SimpleFeatureSource rows = csvDataStore.getFeatureSource(); SimpleFeatureCollection matches = rows.getFeatures(query); List<String> limitCities = Arrays.asList("Trento", "St Paul", "Bangkok"); int count = 0; SimpleFeatureIterator iter = matches.features(); while(iter.hasNext()) { SimpleFeature f = iter.next(); assertTrue(limitCities.contains(f.getAttribute("CITY"))); count++; } iter.close(); assertEquals(3, count); assertEquals(3, matches.size()); assertEquals(3, rows.getCount(query)); }
@Test public void testLimitOffset() throws FileNotFoundException, IOException { Query query = new Query(Query.ALL); query.setMaxFeatures(3); query.setStartIndex(3); SimpleFeatureSource rows = csvDataStore.getFeatureSource(); SimpleFeatureCollection matches = rows.getFeatures(query); List<String> limitCities = Arrays.asList("Ottawa", "Minneapolis", "Lausanne"); int count = 0; SimpleFeatureIterator iter = matches.features(); while(iter.hasNext()) { SimpleFeature f = iter.next(); assertTrue(limitCities.contains(f.getAttribute("CITY"))); count++; } iter.close(); assertEquals(3, count); assertEquals(3, matches.size()); assertEquals(3, rows.getCount(query)); }