use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testSetTypeName.
/**
* Test method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#setTypeName(java.lang.String)}. Test
* method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getTypeName()}.
*/
@Test
public void testSetTypeName() {
DataSourceInfo ds = new DataSourceInfo();
String expectedTypeName = "test type name";
ds.setTypeName(expectedTypeName);
assertEquals(expectedTypeName, ds.getTypeName());
ds.reset();
assertNull(ds.getTypeName());
}
use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.
the class CreateExternalDataSourceTest method testConnect.
/**
* Test method for {@link com.sldeditor.datasource.impl.CreateExternalDataSource#connect(com.sldeditor.datasource.SLDEditorFileInterface)}.
*/
@Test
public void testConnect() {
CreateExternalDataSource ds = new CreateExternalDataSource();
List<DataSourceInfo> dataSourceInfoList = ds.connect(null, null, null);
DataSourceInfo dsInfo = dataSourceInfoList.get(0);
assertTrue(dsInfo != null);
assertNull(dsInfo.getDataStore());
assertNull(dsInfo.getTypeName());
DummyExternalSLDFile dummyExternalSLDFile = new DummyExternalSLDFile();
SLDEditorFileInterface sldEditor = dummyExternalSLDFile;
dataSourceInfoList = ds.connect(dummyExternalSLDFile.getTypeName(), null, sldEditor);
dsInfo = dataSourceInfoList.get(0);
assertTrue(dsInfo != null);
assertTrue(dsInfo.getTypeName() != null);
assertTrue(dsInfo.getDataStore() != null);
}
use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testDataStore.
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getDataStore()}. Test
* method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#setDataStore(org.geotools.data.DataStore)}.
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#unloadDataStore()}.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataStore() {
File file = new File("example.shp");
Map map = new HashMap();
try {
map.put("url", file.toURI().toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
fail(e.getMessage());
}
try {
DataStore dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo ds = new DataSourceInfo();
ds.setDataStore(dataStore);
assertEquals(dataStore, ds.getDataStore());
ds.unloadDataStore();
ds.reset();
assertNull(ds.getDataStore());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testGetFeatureStore.
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureStore()}. Test
* method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#setSchema(org.opengis.feature.type.FeatureType)}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatureStore() {
URL url = SLDEditorFile.class.getClassLoader().getResource("point/sld/shp/sld_cookbook_point.shp");
Map map = new HashMap();
map.put("url", url);
DataStore dataStore;
try {
dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo dsInfo = new DataSourceInfo();
String typeName = dataStore.getTypeNames()[0];
dsInfo.setTypeName(typeName);
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
dsInfo.setSchema(schema);
assertNull(dsInfo.getFeatureStore());
dsInfo.setDataStore(dataStore);
FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = dsInfo.getFeatureStore();
assertTrue(featureStore != null);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testGetPropertyDescriptorList.
/**
* Test method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#getPropertyDescriptorList()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetPropertyDescriptorList() {
URL url = SLDEditorFile.class.getClassLoader().getResource("point/sld/shp/sld_cookbook_point.shp");
Map map = new HashMap();
map.put("url", url);
DataStore dataStore;
try {
dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo dsInfo = new DataSourceInfo();
String typeName = dataStore.getTypeNames()[0];
dsInfo.setTypeName(typeName);
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
assertNull(dsInfo.getPropertyDescriptorList());
dsInfo.setSchema(schema);
Collection<PropertyDescriptor> fieldList = dsInfo.getPropertyDescriptorList();
assertTrue(fieldList.size() == 3);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations