Search in sources :

Example 1 with DataSourceConnector

use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.

the class DataSourceConnectorFactory method populate.

/**
 * Populate.
 */
private static void populate() {
    noDataSource = new DataSourceConnectorEmpty();
    dataSource = new DataSourceConnector();
    populate_internal(noDataSource);
    populate_internal(dataSource);
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) DataSourceConnectorEmpty(com.sldeditor.datasource.connector.instance.DataSourceConnectorEmpty)

Example 2 with DataSourceConnector

use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.

the class SLDEditorFileTest method testSLDData.

/**
 * Test method for {@link com.sldeditor.datasource.SLDEditorFile#getSLDData()}. Test method for
 * {@link com.sldeditor.datasource.SLDEditorFile#fileOpenedSaved()}. Test method for
 * {@link com.sldeditor.datasource.SLDEditorFile#getSldEditorFile()}. Test method for
 * {@link com.sldeditor.datasource.SLDEditorFile#addSLDEditorFileUpdateListener(com.sldeditor.datasource.SLDEditorDataUpdateInterface)}.
 * Test method for {@link com.sldeditor.datasource.SLDEditorFile#renderSymbol()}. Test method
 * for
 * {@link com.sldeditor.datasource.SLDEditorFile#setSLDData(com.sldeditor.common.SLDDataInterface)}.
 * Test method for {@link com.sldeditor.datasource.SLDEditorFile#setSldFile(java.io.File)}. Test
 * method for {@link com.sldeditor.datasource.SLDEditorFile#getDataSource()}. Test method for
 * {@link com.sldeditor.datasource.SLDEditorFile#setDataSource(com.sldeditor.DataSourcePropertiesInterface)}.
 * Test method for
 * {@link com.sldeditor.datasource.SLDEditorFile#setSldEditorFile(java.io.File)}.
 */
@Test
public void testSLDData() {
    // Start with a blank canvas
    SLDEditorFile.destroyInstance();
    SelectedSymbol.destroyInstance();
    assertNull(SLDEditorFile.getInstance().getSLD());
    assertNull(SLDEditorFile.getInstance().getSLDData());
    assertNull(SLDEditorFile.getInstance().getSldEditorFile());
    assertNull(SLDEditorFile.getInstance().getDataSource());
    SLDEditorFile.getInstance().setDataSource(null);
    assertNull(SLDEditorFile.getInstance().getDataSource());
    SLDEditorFile.getInstance().setSldEditorFile(null);
    assertNull(SLDEditorFile.getInstance().getSldEditorFile());
    SLDEditorFile.getInstance().setSldFile(null);
    assertNull(SLDEditorFile.getInstance().getSLDData());
    SLDEditorFile.getInstance().setSLDData(null);
    assertNull(SLDEditorFile.getInstance().getSLDData());
    DummyDataUpdate dataUpdateListener = new DummyDataUpdate();
    SLDEditorFile.getInstance().addSLDEditorFileUpdateListener(dataUpdateListener);
    // Set SLDData
    StyleWrapper styleWrapper = new StyleWrapper("workspace", "style");
    SLDData sldData = new SLDData(styleWrapper, "contents");
    SLDEditorFile.getInstance().setSLDData(sldData);
    SLDEditorFile.getInstance().fileOpenedSaved();
    assertEquals(sldData, SLDEditorFile.getInstance().getSLDData());
    assertFalse(dataUpdateListener.dataEditedFlag);
    // Sld file
    File sldFile = new File("test.txt");
    SLDEditorFile.getInstance().setSldFile(sldFile);
    assertEquals(sldFile.getAbsolutePath(), SLDEditorFile.getInstance().getSLDData().getSLDFile().getAbsolutePath());
    assertFalse(dataUpdateListener.dataEditedFlag);
    // Sld editor file
    File sldEditorFile = new File("editor.file");
    SLDEditorFile.getInstance().setSldEditorFile(sldEditorFile);
    assertEquals(sldEditorFile.getAbsolutePath(), SLDEditorFile.getInstance().getSldEditorFile().getAbsolutePath());
    assertFalse(dataUpdateListener.dataEditedFlag);
    // Data source properties
    SLDEditorFile.getInstance().setDataSource(null);
    assertFalse(dataUpdateListener.dataEditedFlag);
    DataSourcePropertiesInterface noDataSource = DataSourceConnectorFactory.getNoDataSource();
    assertEquals(noDataSource.getDebugConnectionString(), SLDEditorFile.getInstance().getDataSource().getDebugConnectionString());
    assertFalse(dataUpdateListener.dataEditedFlag);
    DataSourcePropertiesInterface fileDSProperties = new DataSourceProperties(new DataSourceConnector());
    assertEquals(fileDSProperties.getDebugConnectionString(), SLDEditorFile.getInstance().getDataSource().getDebugConnectionString());
    assertFalse(dataUpdateListener.dataEditedFlag);
    // Render symbol
    SLDEditorFile.getInstance().renderSymbol();
    assertTrue(dataUpdateListener.dataEditedFlag);
    // File saved
    SLDEditorFile.getInstance().fileOpenedSaved();
    assertFalse(dataUpdateListener.dataEditedFlag);
    assertNull(SLDEditorFile.getInstance().getRuleRenderOptions());
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) SLDData(com.sldeditor.common.data.SLDData) StyleWrapper(com.sldeditor.common.data.StyleWrapper) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) DataSourceProperties(com.sldeditor.datasource.impl.DataSourceProperties) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File) Test(org.junit.Test)

Example 3 with DataSourceConnector

use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.

the class DataSourceConnectorTest method testPopulate.

/**
 * Test method for
 * {@link com.sldeditor.datasource.connector.instance.DataSourceConnector#populate(com.sldeditor.DataSourcePropertiesInterface)}.
 */
@Test
public void testPopulate() {
    DataSourceConnector dsc = new DataSourceConnector();
    dsc.populate(null);
// Does nothing
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) Test(org.junit.Test)

Example 4 with DataSourceConnector

use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.

the class DataSourceConnectorTest method testGetDataSourceProperties.

/**
 * Test method for {@link com.sldeditor.datasource.connector.instance.DataSourceConnector#getDataSourceProperties(java.util.Map)}.
 */
@Test
public void testGetDataSourceProperties() {
    DataSourceConnector dsc = new DataSourceConnector();
    Map<String, Object> propertyMap = new HashMap<String, Object>();
    assertTrue(dsc.getDataSourceProperties(propertyMap) != null);
    assertTrue(dsc.getDataSourceProperties(null) != null);
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 5 with DataSourceConnector

use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.

the class DataSourceConnectorTest method testAccept.

/**
 * Test method for {@link com.sldeditor.datasource.connector.instance.DataSourceConnector#accept(java.util.Map)}.
 */
@Test
public void testAccept() {
    DataSourceConnector dsc = new DataSourceConnector();
    assertNull(dsc.accept((String) null));
    assertFalse(dsc.accept((Map<String, Object>) null));
    Map<String, Object> propertyMap = new HashMap<String, Object>();
    propertyMap.put("test", "filename");
    assertTrue(dsc.accept(propertyMap));
    // Valid file
    propertyMap.put("host", "localhost");
    propertyMap.put("port", "5432");
    propertyMap.put("database", "testdb");
    propertyMap.put("user", "testuser");
    propertyMap.put("schema", "public");
    propertyMap.put("passwd", "pasword123");
    propertyMap.put("featureClass", "testfc");
    assertTrue(dsc.accept(propertyMap));
    propertyMap.clear();
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

DataSourceConnector (com.sldeditor.datasource.connector.instance.DataSourceConnector)12 Test (org.junit.Test)11 DataSourceProperties (com.sldeditor.datasource.impl.DataSourceProperties)5 HashMap (java.util.HashMap)5 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)3 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)3 SLDData (com.sldeditor.common.data.SLDData)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)1 DataSourceConnectorEmpty (com.sldeditor.datasource.connector.instance.DataSourceConnectorEmpty)1 File (java.io.File)1 Map (java.util.Map)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1