use of com.sldeditor.common.data.StyleWrapper in project sldeditor by robward-scisys.
the class ReloadManagerTest method testReloadSavedFile.
@Test
public void testReloadSavedFile() {
SLDData sldData = new SLDData(new StyleWrapper(), "");
ReloadManager.getInstance().sldDataUpdated(sldData, true);
DummyCallback callback = new DummyCallback();
ReloadManager.getInstance().addListener(callback);
assertEquals(0, callback.reloadCallbackCalled);
// Set loaded file - should match
File expectedFile = new File("/tmp/testFile.sld");
Path path = expectedFile.toPath();
sldData.setSLDFile(expectedFile);
ReloadManager.getInstance().sldDataUpdated(sldData, true);
// Mark as not saved
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(1, callback.reloadCallbackCalled);
// Mark as saved
callback.reloadCallbackCalled = 0;
ReloadManager.getInstance().setFileSaved();
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(0, callback.reloadCallbackCalled);
// Mark as not saved
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(1, callback.reloadCallbackCalled);
}
use of com.sldeditor.common.data.StyleWrapper 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.StyleWrapper 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.StyleWrapper 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.StyleWrapper in project sldeditor by robward-scisys.
the class GeoServerReadProgressTest method testGeoServerReadProgress.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress#GeoServerReadProgress(com.sldeditor.common.filesystem.FileSystemInterface, com.sldeditor.extension.filesystem.geoserver.GeoServerParseCompleteInterface)}.
*/
@Test
public void testGeoServerReadProgress() {
DummyProgressComplete complete = new DummyProgressComplete();
GeoServerReadProgress progress = new GeoServerReadProgress(null, complete);
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.startPopulating(null);
progress.startPopulating(connection);
progress.readLayersProgress(null, 0, 0);
assertFalse(complete.completed);
progress.readLayersProgress(connection, 0, 5);
progress.readLayersProgress(connection, 1, 5);
progress.readLayersProgress(connection, 2, 5);
progress.readLayersProgress(connection, 3, 5);
progress.readLayersProgress(connection, 4, 5);
progress.readLayersProgress(connection, 5, 5);
assertFalse(complete.completed);
progress.readLayersProgress(connection, 6, 5);
assertFalse(complete.completed);
progress.readStylesProgress(null, 0, 0);
progress.readStylesProgress(connection, 0, 3);
progress.readStylesProgress(connection, 1, 3);
progress.readStylesProgress(connection, 2, 3);
progress.readStylesProgress(connection, 3, 3);
progress.readStylesProgress(connection, 4, 3);
assertFalse(complete.completed);
Map<String, List<GeoServerLayer>> completedLayersMap = new HashMap<String, List<GeoServerLayer>>();
Map<String, List<StyleWrapper>> completedStyleMap = new HashMap<String, List<StyleWrapper>>();
progress.readLayersComplete(connection, completedLayersMap);
progress.readStylesComplete(connection, completedStyleMap, false);
assertTrue(complete.completed);
}
Aggregations