Search in sources :

Example 1 with CreateInlineDataSource

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

the class DataSourceImplTest method testConnectToInlineDataSource.

/**
 * Test method for {@link com.sldeditor.datasource.impl.DataSourceImpl#connect()}.
 */
@Test
public void testConnectToInlineDataSource() {
    DataSourceImpl ds = new DataSourceImpl();
    DummyInlineSLDFile editorFile = new DummyInlineSLDFile();
    DummyDataSourceUpdate dataSourceUpdateListener = new DummyDataSourceUpdate();
    ds.addListener(dataSourceUpdateListener);
    CreateDataSourceInterface internalDataSource = new DummyCreateDataSource();
    CreateDataSourceInterface externalDataSource = new DummyCreateDataSource();
    CreateDataSourceInterface inlineDataSource = new CreateInlineDataSource();
    ds.setDataSourceCreation(internalDataSource, externalDataSource, inlineDataSource);
    ds.connect("typeName", editorFile, null);
    assertTrue(dataSourceUpdateListener.hasBeenCalled());
    assertEquals(GeometryTypeEnum.UNKNOWN, dataSourceUpdateListener.geometryType);
    assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag);
    Collection<PropertyDescriptor> fieldList = ds.getPropertyDescriptorList();
    assertNull(fieldList);
    FeatureSource<SimpleFeatureType, SimpleFeature> exampleLayer = ds.getExampleFeatureSource();
    assertNull(exampleLayer);
    Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> userLayerMap = ds.getUserLayerFeatureSource();
    assertEquals(1, userLayerMap.size());
    assertFalse(dataSourceUpdateListener.hasBeenCalled());
    ds.updateUserLayers();
    assertTrue(dataSourceUpdateListener.hasBeenCalled());
    DataSourcePropertiesInterface dsi = ds.getDataConnectorProperties();
    assertNotNull(dsi);
}
Also used : FeatureSource(org.geotools.data.FeatureSource) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) DataSourceImpl(com.sldeditor.datasource.impl.DataSourceImpl) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) CreateInlineDataSource(com.sldeditor.datasource.impl.CreateInlineDataSource) UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Aggregations

DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)1 CreateInlineDataSource (com.sldeditor.datasource.impl.CreateInlineDataSource)1 DataSourceImpl (com.sldeditor.datasource.impl.DataSourceImpl)1 FeatureSource (org.geotools.data.FeatureSource)1 UserLayer (org.geotools.styling.UserLayer)1 Test (org.junit.Test)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1