use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testDeleteConnections.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#deleteConnections(java.util.List)}.
*/
@Test
public void testDeleteConnections() {
DatabaseInput input = new DatabaseInput(null);
// Add some database connections
DatabaseConnection connection1 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(GeoPkgDataStoreFactory.DATABASE.key, "test.gpkg");
connection1.setConnectionDataMap(connectionDataMap);
input.addNewConnection(connection1);
DatabaseConnection connection2 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap2 = new HashMap<String, String>();
connectionDataMap2.put(GeoPkgDataStoreFactory.DATABASE.key, "test2.gpkg");
connection2.setConnectionDataMap(connectionDataMap2);
input.addNewConnection(connection2);
// Try null parameters
input.deleteConnections(null);
// Populate some styles
List<String> featureClassList = new ArrayList<String>();
featureClassList.add("Feature Class 1");
featureClassList.add("Feature Class 2");
input.populateComplete(connection1, featureClassList);
List<String> featureClassList2 = new ArrayList<String>();
featureClassList2.add("Feature Class 3");
featureClassList2.add("Feature Class 4");
input.populateComplete(connection2, featureClassList2);
// Delete a delete connection
List<DatabaseConnection> connectionList = new ArrayList<DatabaseConnection>();
connectionList.add(connection1);
input.deleteConnections(connectionList);
List<DatabaseConnection> actual = input.getConnectionDetails();
assertEquals(1, actual.size());
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testDeleteNodes.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.database.DatabaseInput#deleteNodes(com.sldeditor.common.NodeInterface, java.util.List)}.
*/
@Test
public void testDeleteNodes() {
DatabaseInput input = new DatabaseInput(null);
input.deleteNodes(null, null);
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testCopyNodes.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#copyNodes(com.sldeditor.common.NodeInterface, java.util.Map)}.
*/
@Test
public void testCopyNodes() {
DatabaseInput input = new DatabaseInput(null);
assertFalse(input.copyNodes(null, null));
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testDatabaseInput.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#DatabaseInput(com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testDatabaseInput() {
DatabaseInput input = new DatabaseInput(ToolManager.getInstance());
input.readPropertyFile();
FSTree tree = new FSTree();
DefaultMutableTreeNode rootNode;
try {
rootNode = new DefaultMutableTreeNode("Root");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
input.populate(tree, model, rootNode);
List<SLDDataInterface> sldDataList = input.open(null);
assertNull(sldDataList);
DatabaseConnection connection1 = DatabaseConnectionFactory.createGeoPackage();
String featureClassName = "test feature class";
DatabaseFeatureClassNode fcTreeNode = new DatabaseFeatureClassNode(input, connection1, featureClassName);
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(GeoPkgDataStoreFactory.DATABASE.key, "test.gpkg");
connection1.setConnectionDataMap(connectionDataMap);
// Try with no known database connections
SelectedFiles actualSLDContents = input.getSLDContents(fcTreeNode);
assertNotNull(actualSLDContents);
assertTrue(actualSLDContents.isDataSource());
// Add some database connections
input.addNewConnection(connection1);
DatabaseConnection connection2 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap2 = new HashMap<String, String>();
connectionDataMap2.put(GeoPkgDataStoreFactory.DATABASE.key, "test2.gpkg");
connection2.setConnectionDataMap(connectionDataMap2);
input.addNewConnection(connection2);
input.addNewConnection(null);
List<SLDDataInterface> sldDataContentsList = input.getSLDContents(fcTreeNode).getSldData();
assertEquals(0, sldDataContentsList.size());
// Try saving a null object
assertFalse(input.save(null));
// Check how many connections we have
assertEquals(2, input.getConnectionDetails().size());
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testDisconnect.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#disconnect(java.util.List)}.
*/
@Test
public void testDisconnect() {
PropertyManagerFactory.getInstance().setPropertyFile(configPropertiesFile);
DatabaseInput input = new DatabaseInput(null);
// Add some database connections
DatabaseConnection connection1 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(GeoPkgDataStoreFactory.DATABASE.key, "test.gpkg");
connection1.setConnectionDataMap(connectionDataMap);
input.addNewConnection(connection1);
DatabaseConnection connection2 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap2 = new HashMap<String, String>();
connectionDataMap2.put(GeoPkgDataStoreFactory.DATABASE.key, "test2.gpkg");
connection2.setConnectionDataMap(connectionDataMap2);
input.addNewConnection(connection2);
// Try passing null
input.disconnect(null);
// Try disconnecting from one database
List<DatabaseConnection> connectionList = new ArrayList<DatabaseConnection>();
connectionList.add(connection1);
input.disconnect(connectionList);
// Try disconnecting from to 2
connectionList.add(connection2);
input.disconnect(connectionList);
}
Aggregations