/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.data.sqlserver;
import org.geotools.data.Query;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.jdbc.JDBCFeatureSourceOnlineTest;
import org.geotools.jdbc.JDBCTestSetup;
/**
*
*
* @source $URL$
*/
public class SQLServerFeatureSourceOnlineTest extends JDBCFeatureSourceOnlineTest {
@Override
protected JDBCTestSetup createTestSetup() {
return new SqlServerNativeSerializationTestSetup();
}
public void testGetFeaturesWithOffset() throws Exception {
SimpleFeatureSource featureSource = dataStore.getFeatureSource(tname("ft_from"));
Query q = new Query(featureSource.getSchema().getTypeName());
q.setPropertyNames(new String[] {aname("ORIGIN_FROM")});
q.setStartIndex(1);
q.setMaxFeatures(1);
SimpleFeatureCollection features = featureSource.getFeatures(q);
// check size
assertEquals(1, features.size());
// check actual iteration
SimpleFeatureIterator it = features.features();
int count = 0;
try {
assertTrue(it.hasNext());
it.next();
count++;
} finally {
it.close();
}
assertEquals(1, count);
}
}