use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testConnect.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#connect(java.util.List)}.
*/
@Test
public void testConnect() {
DatabaseInput input = new DatabaseInput(null);
DatabaseConnection connection1 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(GeoPkgDataStoreFactory.DATABASE.key, "test.gpkg");
connection1.setConnectionDataMap(connectionDataMap);
// 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);
input.connect(null);
// Try connecting to one database
List<DatabaseConnection> connectionList = new ArrayList<DatabaseConnection>();
connectionList.add(connection1);
// Try passing null
input.connect(connectionList);
// Try connecting to 2
connectionList.add(connection2);
input.connect(connectionList);
assertTrue(input.isConnected(connection1));
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testUpdateConnectionDetails.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.database.DatabaseInput#updateConnectionDetails(com.sldeditor.common.data.DatabaseConnection, com.sldeditor.common.data.DatabaseConnection)}.
*/
@Test
public void testUpdateConnectionDetails() {
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.updateConnectionDetails(null, null);
// Delete connection details
List<DatabaseConnection> listToDelete = new ArrayList<DatabaseConnection>();
listToDelete.add(connection1);
input.deleteConnections(listToDelete);
DatabaseConnection connection1Updated = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap3 = new HashMap<String, String>();
connectionDataMap3.put(GeoPkgDataStoreFactory.DATABASE.key, "updated test.gpkg");
connection1Updated.setConnectionDataMap(connectionDataMap3);
input.addNewConnection(connection1Updated);
// Update the connection details
input.updateConnectionDetails(connection1, connection1Updated);
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseInputTest method testGetNodeTypes.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#getNodeTypes()}.
*/
@Test
public void testGetNodeTypes() {
DatabaseInput input = new DatabaseInput(null);
assertTrue(input.getNodeTypes().isEmpty());
}
use of com.sldeditor.extension.filesystem.database.DatabaseInput in project sldeditor by robward-scisys.
the class DatabaseConnectionToolTest method testDatabaseConnectionTool.
/**
* Test method for
* {@link com.sldeditor.tool.databaseconnection.DatabaseConnectionTool#DatabaseConnectionTool(com.sldeditor.tool.databaseconnection.DatabaseConnectStateInterface)}.
*/
@Test
public void testDatabaseConnectionTool() {
TestDatabaseConnectState state = new TestDatabaseConnectState();
TestDatabaseConnectionTool testObj = new TestDatabaseConnectionTool(state);
testObj.setSelectedItems(null, null);
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
DatabaseConnection connection = DatabaseConnectionFactory.createGeoPackage();
nodeTypeList.add(new DatabaseNode(new DatabaseInput(ToolManager.getInstance()), connection));
File parent = new File("");
String filename = "test.gpkg";
FileTreeNode fileTreeNode = null;
try {
fileTreeNode = new FileTreeNode(parent, filename);
fileTreeNode.setFileCategory(FileTreeNodeTypeEnum.DATABASE);
nodeTypeList.add(fileTreeNode);
} catch (SecurityException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
testObj.setSelectedItems(nodeTypeList, null);
testObj.populateComplete(null);
assertNotNull(testObj.getPanel());
List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
List<SLDDataInterface> sldDataList = null;
assertFalse(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
uniqueNodeTypeList.add(String.class);
assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
nodeTypeList.remove(0);
assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
testObj.testConnect();
testObj.testDisconnect();
}
Aggregations