use of com.sldeditor.datasource.connector.instance.DataSourceConnector 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));
}
use of com.sldeditor.datasource.connector.instance.DataSourceConnector 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.connector.instance.DataSourceConnector 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.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.
the class DataSourceConnectorTest method testGetDisplayName.
/**
* Test method for {@link com.sldeditor.datasource.connector.instance.DataSourceConnector#getDisplayName()}.
*/
@Test
public void testGetDisplayName() {
DataSourceConnector dsc = new DataSourceConnector();
assertEquals("Database", dsc.getDisplayName());
}
use of com.sldeditor.datasource.connector.instance.DataSourceConnector in project sldeditor by robward-scisys.
the class DataSourceConnectorTest method testGetPanel.
/**
* Test method for {@link com.sldeditor.datasource.connector.instance.DataSourceConnector#getPanel()}.
*/
@Test
public void testGetPanel() {
DataSourceConnector dsc = new DataSourceConnector();
assertTrue(dsc.getPanel() != null);
}
Aggregations