use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput 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));
}
Aggregations