use of com.sldeditor.datasource.impl.DataSourceProperties in project sldeditor by robward-scisys.
the class DataSourcePropertiesTest method testDataSourcePropertiesNoConnector.
/**
* Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#DataSourceProperties(com.sldeditor.DataSourceConnectorInterface)}.
* Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#setPropertyMap(java.util.Map)}. Test
* method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#setFilename(java.lang.String)}. Test
* method for {@link com.sldeditor.datasource.impl.DataSourceProperties#getFilename()}. Test
* method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#getDataSourceConnector()}.
*/
@Test
public void testDataSourcePropertiesNoConnector() {
Map<String, Object> propertyMap = new HashMap<String, Object>();
propertyMap.put("field1", "value1");
propertyMap.put("field2", "value2");
propertyMap.put("field3", "value3");
DataSourceProperties dsp = new DataSourceProperties(null);
dsp.setPropertyMap(propertyMap);
Map<String, Object> actualPropertyMap = dsp.getConnectionProperties();
assertEquals(propertyMap, actualPropertyMap);
assertEquals(propertyMap, dsp.getAllConnectionProperties());
// Make sure filename key does not exist
assertFalse(actualPropertyMap.containsKey("url"));
String expectedFilename = "this is a filename";
dsp.setFilename(expectedFilename);
actualPropertyMap = dsp.getConnectionProperties();
assertTrue(actualPropertyMap.containsKey("url"));
assertEquals(expectedFilename, dsp.getFilename());
// Is empty
assertTrue(dsp.isEmpty());
}
use of com.sldeditor.datasource.impl.DataSourceProperties in project sldeditor by robward-scisys.
the class DataSourcePropertiesTest method testDataSourcePropertiesWithConnector.
/**
* Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#DataSourceProperties(com.sldeditor.DataSourceConnectorInterface)}.
* Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#setPropertyMap(java.util.Map)}. Test
* method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#getDataSourceConnector()}.
*/
@Test
public void testDataSourcePropertiesWithConnector() {
Map<String, Object> propertyMap = new HashMap<String, Object>();
propertyMap.put("field1", "value1");
propertyMap.put("field2", "value2");
propertyMap.put("field3", "value3");
DataSourceConnectorInterface dsc = new DataSourceConnector();
DataSourceProperties dsp = new DataSourceProperties(dsc);
dsp.setPropertyMap(propertyMap);
Map<String, Object> actualPropertyMap = dsp.getConnectionProperties();
assertEquals(propertyMap, actualPropertyMap);
assertEquals(propertyMap, dsp.getAllConnectionProperties());
// Is empty
assertFalse(dsp.isEmpty());
}
use of com.sldeditor.datasource.impl.DataSourceProperties in project sldeditor by robward-scisys.
the class DataSourcePropertiesTest method testEncodeDecodeXML.
/**
* Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#encodeXML(org.w3c.dom.Document,
* org.w3c.dom.Element, java.lang.String)}. Test method for {@link
* com.sldeditor.datasource.impl.DataSourceProperties#decodeXML(org.w3c.dom.Document,
* java.lang.String)}.
*/
@Test
public void testEncodeDecodeXML() {
Map<String, Object> propertyMap = new HashMap<String, Object>();
propertyMap.put("field1", "value1");
propertyMap.put("field2", "value2");
propertyMap.put("field3", "value3");
DataSourceConnectorInterface dsc = new DataSourceConnector();
DataSourceProperties dsp = new DataSourceProperties(dsc);
dsp.setPropertyMap(propertyMap);
dsp.setFilename("testfilename.shp");
dsp.setPassword("top secret password");
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = null;
try {
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
fail(e.getMessage());
}
Document doc = documentBuilder.newDocument();
String elementName = "test_data_source_properties";
Element root = doc.createElement("test");
doc.appendChild(root);
dsp.encodeXML(doc, root, elementName);
// Try null parameters
dsp.encodeXML(null, null, null);
assertNull(DataSourceProperties.decodeXML(null, null));
// Now decode XML
DataSourcePropertiesInterface decodeDSP = DataSourceProperties.decodeXML(doc, elementName);
assertEquals(dsp.getConnectionProperties(), decodeDSP.getConnectionProperties());
}
use of com.sldeditor.datasource.impl.DataSourceProperties in project sldeditor by robward-scisys.
the class MissingSLDAttributesTest method testCheckAttributes.
/**
* Test method for {@link
* com.sldeditor.datasource.checks.MissingSLDAttributes#checkAttributes(com.sldeditor.datasource.SLDEditorFileInterface)}.
*/
@Test
void testCheckAttributes() {
MissingSLDAttributes obj = new MissingSLDAttributes();
obj.checkAttributes(null);
DummyInternalSLDFile3 testSLD = new DummyInternalSLDFile3();
SLDDataInterface sldData = testSLD.getSLDData();
SLDEditorFile.destroyInstance();
SelectedSymbol.destroyInstance();
SelectedSymbol.getInstance().setSld(testSLD.getSLD());
SLDEditorFile editorFile = SLDEditorFile.getInstance();
Map<String, Object> propertyMap = new HashMap<String, Object>();
propertyMap.put("field1", "value1");
propertyMap.put("field2", "value2");
propertyMap.put("field3", "value3");
DataSourceConnectorInterface dsc = new DataSourceConnector();
DataSourceProperties dsp = new DataSourceProperties(dsc);
dsp.setPropertyMap(propertyMap);
List<DataSourceAttributeData> fieldList = new ArrayList<DataSourceAttributeData>();
fieldList.add(new DataSourceAttributeData("Field 1", String.class, null));
fieldList.add(new DataSourceAttributeData("Field 2", Double.class, null));
fieldList.add(new DataSourceAttributeData("Field 3", Double.class, null));
// Try when no fields have been specified
obj.checkAttributes(editorFile);
editorFile.setSLDData(sldData);
obj.checkAttributes(editorFile);
// Specify the field list
sldData.setFieldList(fieldList);
sldData.setDataSourceProperties(dsp);
editorFile.setDataSource(dsp);
obj.checkAttributes(editorFile);
// Tidy up
SLDEditorFile.destroyInstance();
SelectedSymbol.destroyInstance();
}
use of com.sldeditor.datasource.impl.DataSourceProperties in project sldeditor by robward-scisys.
the class DataSourceConnectorTest method testGetConnectionProperties.
/**
* Test method for {@link
* com.sldeditor.datasource.connector.instance.DataSourceConnector#getConnectionProperties(com.sldeditor.DataSourcePropertiesInterface)}.
*/
@Test
public void testGetConnectionProperties() {
DataSourceConnector dsc = new DataSourceConnector();
assertNull(dsc.getConnectionProperties(null));
Map<String, Object> expectedPropertyMap = new HashMap<String, Object>();
expectedPropertyMap.put("server", "localhost");
expectedPropertyMap.put("port", "5432");
expectedPropertyMap.put("database", "testdb");
expectedPropertyMap.put("user", "testuser");
expectedPropertyMap.put("password", "pasword123");
DataSourcePropertiesInterface dataSource = new DataSourceProperties(dsc);
dataSource.setPropertyMap(expectedPropertyMap);
assertEquals(expectedPropertyMap, dsc.getConnectionProperties(dataSource));
}
Aggregations