use of com.sldeditor.common.data.GeoServerConnection 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);
}
use of com.sldeditor.common.data.GeoServerConnection 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);
}
use of com.sldeditor.common.data.GeoServerConnection 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());
}
}
use of com.sldeditor.common.data.GeoServerConnection 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);
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerReadProgressTest method testUpdateConnection.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress#updateConnection(com.sldeditor.common.data.GeoServerConnection, com.sldeditor.common.data.GeoServerConnection)}.
*/
@Test
public void testUpdateConnection() {
GeoServerReadProgress progress = new GeoServerReadProgress(null, null);
GeoServerOverallNode geoServerRootNode = new GeoServerOverallNode(null);
GeoServerConnection connection = new GeoServerConnection();
connection.setConnectionName("test connection 1");
GeoServerNode node = new GeoServerNode(null, connection);
geoServerRootNode.add(node);
progress.addNewConnectionNode(connection, node);
progress.updateConnection(null, null);
GeoServerConnection newConnectionDetails = new GeoServerConnection();
newConnectionDetails.setConnectionName("updated test connection 1");
progress.updateConnection(connection, newConnectionDetails);
}
Aggregations