use of com.sldeditor.extension.filesystem.file.vector.VectorFileHandler in project sldeditor by robward-scisys.
the class VectorFileHandlerTest method testGetSLDName.
/**
* Supply a folder name and retrieve all the sld files in it
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.vector.VectorFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDName() {
VectorFileHandler handler = new VectorFileHandler();
assertTrue(handler.getSLDName(null).compareTo("") == 0);
SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), "sldContents");
String sldName = handler.getSLDName(sldData);
assertTrue(sldName.compareTo("layer.sld") == 0);
}
use of com.sldeditor.extension.filesystem.file.vector.VectorFileHandler in project sldeditor by robward-scisys.
the class VectorFileHandlerTest method testGetSLDContentsFile.
/**
* Single file
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.vector.VectorFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDContentsFile() {
assertNull(new VectorFileHandler().getSLDContents(null));
URL url = VectorFileHandlerTest.class.getResource("/point/sld");
File parent = null;
try {
parent = new File(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
try {
FileTreeNode fileTreeNode = new FileTreeNode(parent, "point_attribute.sld");
VectorFileHandler handler = new VectorFileHandler();
List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
assertNull(sldDataList);
// Try with valid vector file
FileTreeNode fileTreeNode2 = new FileTreeNode(parent, "point_attribute.shp");
sldDataList = handler.getSLDContents(fileTreeNode2);
assertTrue(sldDataList.isEmpty());
// Changes where the file is to be saved to
File saveFile = File.createTempFile(getClass().getSimpleName(), ".sld");
SLDData sldData = new SLDData(null, "");
sldData.setSLDFile(saveFile);
assertFalse(handler.save(null));
assertFalse(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