Search in sources :

Example 1 with GeoServerInput

use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput in project sldeditor by robward-scisys.

the class FileSystemExtensionFactory method populateExtensions.

/**
 * Populate default file extensions.
 *
 * @param toolMgr the tool manager
 */
private static void populateExtensions(ToolSelectionInterface toolMgr) {
    geoServerInput = new GeoServerInput(toolMgr);
    geoServerInput.readPropertyFile();
    extensionList.add(geoServerInput);
    databaseInput = new DatabaseInput(toolMgr);
    databaseInput.readPropertyFile();
    extensionList.add(databaseInput);
    fileSystemInput = new FileSystemInput(toolMgr);
    extensionList.add(fileSystemInput);
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DatabaseInput(com.sldeditor.extension.filesystem.database.DatabaseInput) FileSystemInput(com.sldeditor.extension.filesystem.file.FileSystemInput)

Example 2 with GeoServerInput

use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput in project sldeditor by robward-scisys.

the class GeoServerInputTest method testDeleteNodes.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#deleteNodes(com.sldeditor.common.NodeInterface, java.util.List)}.
 */
@Test
public void testDeleteNodes() {
    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
    // CHECKSTYLE:OFF
    GeoServerWorkspaceNode workspaceTreeNode = new GeoServerWorkspaceNode(input, connection1, "test workspace", false);
    // CHECKSTYLE:ON
    // Create test data
    List<SLDDataInterface> sldToDeleteList = new ArrayList<SLDDataInterface>();
    StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
    SLDData sldData = new SLDData(styleWrapper, "sld contents");
    sldData.setConnectionData(connection1);
    sldToDeleteList.add(sldData);
    input.deleteNodes(null, null);
    input.deleteNodes(workspaceTreeNode, null);
    input.deleteNodes(null, sldToDeleteList);
    // Try with valid parameters
    input.deleteNodes(workspaceTreeNode, sldToDeleteList);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) 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) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 3 with GeoServerInput

use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput in project sldeditor by robward-scisys.

the class GeoServerInputTest method testGetStyleMap.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#getStyleMap(com.sldeditor.common.data.GeoServerConnection)}.
 */
@Test
public void testGetStyleMap() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    // Add some GeoServer connections
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    input.addNewConnection(connection1);
    GeoServerConnection connection2 = new GeoServerConnection();
    connection2.setConnectionName("test connection 2");
    input.addNewConnection(connection2);
    // Try a null objects
    Map<String, List<StyleWrapper>> actualStyleMap = input.getStyleMap(null);
    assertNull(actualStyleMap);
    actualStyleMap = input.getStyleMap(connection2);
    assertNull(actualStyleMap);
    Map<String, List<StyleWrapper>> expectedStyleMap = new HashMap<String, List<StyleWrapper>>();
    // CHECKSTYLE:OFF
    StyleWrapper[] styleWrappers = { new StyleWrapper("workspace", "style1"), new StyleWrapper("workspace", "style2") };
    // CHECKSTYLE:ON
    expectedStyleMap.put("style1", Arrays.asList(styleWrappers));
    Map<String, List<GeoServerLayer>> expectedLayerMap = new HashMap<String, List<GeoServerLayer>>();
    // CHECKSTYLE:OFF
    GeoServerLayer[] geoServerLayers = { new GeoServerLayer("workspace", "style1"), new GeoServerLayer("workspace", "style2") };
    // CHECKSTYLE:ON
    expectedLayerMap.put("style1", Arrays.asList(geoServerLayers));
    input.populateComplete(connection1, expectedStyleMap, expectedLayerMap);
    actualStyleMap = input.getStyleMap(connection1);
    assertEquals(expectedStyleMap, actualStyleMap);
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) HashMap(java.util.HashMap) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 4 with GeoServerInput

use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput in project sldeditor by robward-scisys.

the class GeoServerInputTest method testGeoServerInput.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#GeoServerInput(com.sldeditor.common.ToolSelectionInterface)}.
 */
@Test
public void testGeoServerInput() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    FSTree tree = new FSTree();
    DefaultMutableTreeNode rootNode;
    try {
        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");
        StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
        GeoServerStyleNode styleTreeNode = new GeoServerStyleNode(input, connection1, styleWrapper);
        // Try with no known GeoServer connections
        assertNull(input.getSLDContents(styleTreeNode));
        // Add some GeoServer connections
        input.addNewConnection(connection1);
        GeoServerConnection connection2 = new GeoServerConnection();
        connection2.setConnectionName("test connection 2");
        input.addNewConnection(connection2);
        List<SLDDataInterface> sldDataContentsList = input.getSLDContents(styleTreeNode).getSldData();
        assertEquals(1, sldDataContentsList.size());
        SLDData sldData = (SLDData) sldDataContentsList.get(0);
        // Try saving a null object
        assertFalse(input.save(null));
        // Save valid sld data
        assertTrue(input.save(sldData));
        // Try and save to a connection that doe snot exists
        GeoServerConnection connection3 = new GeoServerConnection();
        connection2.setConnectionName("test connection 3");
        sldData.setConnectionData(connection3);
        assertFalse(input.save(sldData));
        // Check how many connections we have
        assertEquals(2, input.getConnectionDetails().size());
    } catch (SecurityException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 5 with GeoServerInput

use of com.sldeditor.extension.filesystem.geoserver.GeoServerInput in project sldeditor by robward-scisys.

the class GeoServerInputTest method testConnect.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#connect(java.util.List)}.
 */
@Test
public void testConnect() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    // Add some GeoServer connections
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    input.addNewConnection(connection1);
    GeoServerConnection connection2 = new GeoServerConnection();
    connection2.setConnectionName("test connection 2");
    input.addNewConnection(connection2);
    input.connect(null);
    // Try connecting to one GeoServer
    List<GeoServerConnection> connectionList = new ArrayList<GeoServerConnection>();
    connectionList.add(connection1);
    // Try passing null
    input.connect(connectionList);
    // Try connecting to 2
    connectionList.add(connection2);
    input.connect(connectionList);
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) 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