Search in sources :

Example 11 with GeoServerInput

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));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HashMap(java.util.HashMap) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) ArrayList(java.util.ArrayList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Aggregations

GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)11 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)10 Test (org.junit.Test)10 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)9 StyleWrapper (com.sldeditor.common.data.StyleWrapper)7 ArrayList (java.util.ArrayList)7 SLDData (com.sldeditor.common.data.SLDData)4 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)3 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3 List (java.util.List)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)3 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)2 NodeInterface (com.sldeditor.common.NodeInterface)1 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)1 DatabaseInput (com.sldeditor.extension.filesystem.database.DatabaseInput)1 FileSystemInput (com.sldeditor.extension.filesystem.file.FileSystemInput)1