Search in sources :

Example 21 with DataSourcePropertiesInterface

use of com.sldeditor.common.DataSourcePropertiesInterface 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)21 Test (org.junit.Test)9 File (java.io.File)8 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)7 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)7 SLDDataInterface (com.sldeditor.common.SLDDataInterface)5 DataSourceConnector (com.sldeditor.datasource.connector.instance.DataSourceConnector)4 DataSourceProperties (com.sldeditor.datasource.impl.DataSourceProperties)4 HashMap (java.util.HashMap)4 SLDData (com.sldeditor.common.data.SLDData)3 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 VersionData (com.sldeditor.common.vendoroption.VersionData)2 DatabaseClientInterface (com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface)2 EnvVar (com.sldeditor.filter.v2.envvar.EnvVar)2 LegendOptionData (com.sldeditor.ui.legend.option.LegendOptionData)2