use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class SelectedFilesTest method test.
@Test
public void test() {
SelectedFiles selectedFiles = new SelectedFiles();
assertTrue(selectedFiles.isDataSource() == false);
assertTrue(selectedFiles.isFolder() == false);
assertTrue(selectedFiles.getSldData().isEmpty());
selectedFiles.setDataSource(true);
assertTrue(selectedFiles.isDataSource());
selectedFiles.setIsFolder(true);
assertTrue(selectedFiles.isFolder());
List<SLDDataInterface> actualSldData = new ArrayList<SLDDataInterface>();
actualSldData.add(new SLDData(null, "test1"));
actualSldData.add(new SLDData(null, "test2"));
actualSldData.add(new SLDData(null, "test3"));
selectedFiles.setSldData(actualSldData);
assertTrue(selectedFiles.getSldData().size() == actualSldData.size());
}
use of com.sldeditor.common.SLDDataInterface 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.SLDDataInterface 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.SLDDataInterface in project sldeditor by robward-scisys.
the class FileSystemInputTest method testFileSystemInput.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.file.FileSystemInput#FileSystemInput(com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testFileSystemInput() {
FileSystemInput input = new FileSystemInput(null);
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("/point/sld/point_attribute.sld");
List<SLDDataInterface> sldDataList = input.open(url);
assertEquals(1, sldDataList.size());
File parent = null;
try {
parent = new File(url.toURI());
parent = parent.getParentFile();
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
FileTreeNode fileTreeNode = new FileTreeNode(parent, "point_attribute.sld");
List<SLDDataInterface> sldDataContentsList = input.getSLDContents(fileTreeNode).getSldData();
assertEquals(1, sldDataContentsList.size());
// Changes where the file is to be saved to
File saveFile = File.createTempFile(getClass().getSimpleName(), ".sld");
SLDData sldData = (SLDData) sldDataContentsList.get(0);
sldData.setSLDFile(saveFile);
assertFalse(input.save(null));
assertTrue(input.save(sldData));
saveFile.delete();
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class MapBoxFileHandlerTest method testGetSLDContents.
/**
* Test method for {@link com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
@Ignore
public void testGetSLDContents() {
assertNull(new MapBoxFileHandler().getSLDContents(null));
URL url = MapBoxFileHandlerTest.class.getResource("/point/mapbox");
File parent = null;
try {
parent = new File(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
try {
FileTreeNode fileTreeNode = new FileTreeNode(parent, "circleStyleTest.json");
MapBoxFileHandler handler = new MapBoxFileHandler();
List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
assertEquals(1, sldDataList.size());
// Changes where the file is to be saved to
File saveFile = File.createTempFile(getClass().getSimpleName(), ".json");
SLDData sldData = (SLDData) sldDataList.get(0);
sldData.setSLDFile(saveFile);
assertFalse(handler.save(null));
assertTrue(handler.save(sldData));
saveFile.delete();
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations