Search in sources :

Example 6 with GeoServerInput

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

the class GeoServerInputTest method testUpdateConnectionDetails.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#updateConnectionDetails(com.sldeditor.common.data.GeoServerConnection, com.sldeditor.common.data.GeoServerConnection)}.
 */
@Test
public void testUpdateConnectionDetails() {
    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 null parameters
    input.updateConnectionDetails(null, null);
    // Delete connection details
    List<GeoServerConnection> listToDelete = new ArrayList<GeoServerConnection>();
    listToDelete.add(connection1);
    input.deleteConnections(listToDelete);
    GeoServerConnection connection1Updated = new GeoServerConnection();
    connection1Updated.setConnectionName("update test connection 1");
    input.addNewConnection(connection1Updated);
    // Update the connection details
    input.updateConnectionDetails(connection1, connection1Updated);
    StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
    SLDData sldData = new SLDData(styleWrapper, "sld contents");
    sldData.setConnectionData(connection1);
    // Try and save with the old GeoServer connection details
    assertFalse(input.save(sldData));
    // Try and save with the new GeoServer connection details
    sldData.setConnectionData(connection1Updated);
    assertTrue(input.save(sldData));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 7 with GeoServerInput

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

the class GeoServerInputTest method testGetNodeTypes.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#getNodeTypes()}.
 */
@Test
public void testGetNodeTypes() {
    GeoServerInput input = new GeoServerInput(null);
    assertTrue(input.getNodeTypes().isEmpty());
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 8 with GeoServerInput

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

the class GeoServerInputTest method testDeleteConnections.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#deleteConnections(java.util.List)}.
 */
@Test
public void testDeleteConnections() {
    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 null parameters
    input.deleteConnections(null);
    // Populate some styles
    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);
    input.populateComplete(connection2, expectedStyleMap, expectedLayerMap);
    Map<String, List<StyleWrapper>> actualStyleMap = input.getStyleMap(connection1);
    assertEquals(expectedStyleMap, actualStyleMap);
    // Delete a GeoServer connection
    List<GeoServerConnection> connectionList = new ArrayList<GeoServerConnection>();
    connectionList.add(connection1);
    input.deleteConnections(connectionList);
    actualStyleMap = input.getStyleMap(connection1);
    assertTrue(actualStyleMap == null);
    // Check the other connection wasn't deleted
    actualStyleMap = input.getStyleMap(connection2);
    assertEquals(1, actualStyleMap.size());
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 9 with GeoServerInput

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

the class GeoServerInputTest method testUpdateLayerStyle.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#updateLayerStyle(com.sldeditor.common.data.StyleWrapper, java.util.List)}.
 */
@Test
public void testUpdateLayerStyle() {
    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 with null objects
    input.updateLayerStyle(null);
    // CHECKSTYLE:OFF
    GeoServerLayer[] geoServerLayers = { new GeoServerLayer("workspace", "style1"), new GeoServerLayer("workspace", "style2") };
    // CHECKSTYLE:ON
    List<GeoServerLayer> layerList = Arrays.asList(geoServerLayers);
    StyleWrapper updatedStyle = new StyleWrapper("workspace", "layer1");
    for (GeoServerLayer layer : layerList) {
        layer.setStyle(updatedStyle);
    }
    input.updateLayerStyle(layerList);
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 10 with GeoServerInput

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

the class GeoServerInputTest method testDisconnect.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#disconnect(java.util.List)}.
 */
@Test
public void testDisconnect() {
    PropertyManagerFactory.getInstance().setPropertyFile(configPropertiesFile);
    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 passing null
    input.disconnect(null);
    // Try disconnecting from one GeoServer
    List<GeoServerConnection> connectionList = new ArrayList<GeoServerConnection>();
    connectionList.add(connection1);
    input.disconnect(connectionList);
    // Try disconnecting from to 2
    connectionList.add(connection2);
    input.disconnect(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