use of com.sldeditor.extension.filesystem.file.raster.RasterFileHandler in project sldeditor by robward-scisys.
the class RasterFileHandlerTest method testGetSLDName.
/**
* Supply a folder name and retrieve all the sld files in it
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.raster.RasterFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDName() {
RasterFileHandler handler = new RasterFileHandler();
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.raster.RasterFileHandler in project sldeditor by robward-scisys.
the class RasterFileHandlerTest method testGetSLDContentsFile.
/**
* Single file
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.raster.RasterFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDContentsFile() {
assertNull(new RasterFileHandler().getSLDContents(null));
URL url = RasterFileHandlerTest.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");
RasterFileHandler handler = new RasterFileHandler();
List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
assertNull(sldDataList);
// Try with valid vector file
FileTreeNode fileTreeNode2 = new FileTreeNode(parent, "point_attribute.tif");
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