use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class GeoServerInputTest method testCopyNodes.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#copyNodes(com.sldeditor.common.NodeInterface, java.util.Map)}.
*/
@Test
public void testCopyNodes() {
GeoServerInput input = new GeoServerInput(null);
GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
FSTree tree = new FSTree();
DefaultMutableTreeNode rootNode;
rootNode = new DefaultMutableTreeNode("Root");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
input.populate(tree, model, rootNode);
URL url = SLDFileHandlerTest.class.getResource("/sld/point_attribute.sld");
List<SLDDataInterface> sldDataList = input.open(url);
assertNull(sldDataList);
GeoServerConnection connection1 = new GeoServerConnection();
connection1.setConnectionName("test connection 1");
// Add some GeoServer connections
input.addNewConnection(connection1);
// Try null parameters
assertFalse(input.copyNodes(null, null));
// Try with valid parameters
GeoServerWorkspaceNode workspaceTreeNode = new GeoServerWorkspaceNode(input, connection1, "test workspace", false);
// Create test data
Map<NodeInterface, List<SLDDataInterface>> copyDataMap = new HashMap<NodeInterface, List<SLDDataInterface>>();
List<SLDDataInterface> sldToCopyList = new ArrayList<SLDDataInterface>();
StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
SLDData sldData = new SLDData(styleWrapper, "sld contents");
sldData.setConnectionData(connection1);
sldToCopyList.add(sldData);
copyDataMap.put(workspaceTreeNode, sldToCopyList);
assertFalse(input.copyNodes(workspaceTreeNode, null));
assertFalse(input.copyNodes(null, copyDataMap));
// Try with valid parameters
assertTrue(input.copyNodes(workspaceTreeNode, copyDataMap));
}
use of com.sldeditor.common.SLDDataInterface 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