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);
}
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());
}
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
}
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);
}
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();
}
Aggregations