Search in sources :

Example 1 with DataSourceInfo

use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.

the class CreateInternalDataSourceTest method testConnect.

/**
 * Test method for {@link
 * com.sldeditor.datasource.impl.CreateInternalDataSource#connect(com.sldeditor.datasource.SLDEditorFileInterface)}.
 */
@Test
public void testConnect() {
    CreateInternalDataSource ds = new CreateInternalDataSource();
    List<DataSourceInfo> dataSourceInfoList = ds.connect(null, null, null);
    DataSourceInfo dsInfo = dataSourceInfoList.get(0);
    assertTrue(dsInfo != null);
    assertNull(dsInfo.getDataStore());
    assertNull(dsInfo.getTypeName());
    SLDEditorFileInterface sldEditor = new DummyInternalSLDFile();
    dataSourceInfoList = ds.connect(null, null, sldEditor);
    dsInfo = dataSourceInfoList.get(0);
    assertTrue(dsInfo != null);
    assertTrue(dsInfo.getTypeName() != null);
    assertTrue(dsInfo.getDataStore() != null);
}
Also used : DataSourceInfo(com.sldeditor.datasource.impl.DataSourceInfo) CreateInternalDataSource(com.sldeditor.datasource.impl.CreateInternalDataSource) SLDEditorFileInterface(com.sldeditor.datasource.SLDEditorFileInterface) Test(org.junit.jupiter.api.Test)

Example 2 with DataSourceInfo

use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.

the class DataSourceInfoTest method testGetFeatures.

/**
 * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatures()}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatures() {
    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.getFeatures());
        dsInfo.setSchema(schema);
        assertNull(dsInfo.getFeatures());
        dsInfo.setDataStore(dataStore);
        assertTrue(dsInfo.getFeatures() != null);
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DataSourceInfo(com.sldeditor.datasource.impl.DataSourceInfo) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) HashMap(java.util.HashMap) SimpleFeatureSource(org.geotools.data.simple.SimpleFeatureSource) DataStore(org.geotools.data.DataStore) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 3 with DataSourceInfo

use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.

the class DataSourceInfoTest method testGetGeometryFieldName.

/**
 * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getGeometryFieldName()}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetGeometryFieldName() {
    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.getGeometryFieldName());
        dsInfo.setSchema(schema);
        assertEquals("the_geom", dsInfo.getGeometryFieldName());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DataSourceInfo(com.sldeditor.datasource.impl.DataSourceInfo) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) HashMap(java.util.HashMap) SimpleFeatureSource(org.geotools.data.simple.SimpleFeatureSource) DataStore(org.geotools.data.DataStore) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 4 with DataSourceInfo

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());
}
Also used : DataSourceInfo(com.sldeditor.datasource.impl.DataSourceInfo) Test(org.junit.jupiter.api.Test)

Example 5 with DataSourceInfo

use of com.sldeditor.datasource.impl.DataSourceInfo in project sldeditor by robward-scisys.

the class DataSourceInfoTest method testGetFeatureCollection.

/**
 * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureCollection()}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatureCollection() {
    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.getGeometryFieldName());
        dsInfo.setSchema(schema);
        assertEquals("the_geom", dsInfo.getGeometryFieldName());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : DataSourceInfo(com.sldeditor.datasource.impl.DataSourceInfo) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) HashMap(java.util.HashMap) SimpleFeatureSource(org.geotools.data.simple.SimpleFeatureSource) DataStore(org.geotools.data.DataStore) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Aggregations

DataSourceInfo (com.sldeditor.datasource.impl.DataSourceInfo)10 Test (org.junit.jupiter.api.Test)10 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 DataStore (org.geotools.data.DataStore)6 URL (java.net.URL)5 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)5 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)5 SLDEditorFileInterface (com.sldeditor.datasource.SLDEditorFileInterface)2 CreateExternalDataSource (com.sldeditor.datasource.impl.CreateExternalDataSource)1 CreateInternalDataSource (com.sldeditor.datasource.impl.CreateInternalDataSource)1 GeometryTypeEnum (com.sldeditor.datasource.impl.GeometryTypeEnum)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1