use of com.sldeditor.extension.filesystem.file.ysld.YSLDFileHandler in project sldeditor by robward-scisys.
the class YSLDFileHandlerTest method testGetSLDContentsFile.
/**
* Single file
* Test method for {@link com.sldeditor.extension.filesystem.file.ysld.YSLDFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDContentsFile() {
assertNull(new YSLDFileHandler().getSLDContents(null));
URL url = YSLDFileHandlerTest.class.getResource("/point/ysld");
File parent = null;
try {
parent = new File(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
try {
FileTreeNode fileTreeNode = new FileTreeNode(parent, "point_simplepoint.ysld");
YSLDFileHandler handler = new YSLDFileHandler();
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(), ".ysld");
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());
}
}
use of com.sldeditor.extension.filesystem.file.ysld.YSLDFileHandler in project sldeditor by robward-scisys.
the class YSLDFileHandlerTest method testGetSLDContentsFolder.
/**
* Supply a folder name and retrieve all the ysld files in it
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.ysld.YSLDFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDContentsFolder() {
assertNull(new YSLDFileHandler().getSLDContents(null));
URL url = SLDFileHandlerTest.class.getResource("/point/ysld");
String folderName = "";
File parent = null;
try {
parent = new File(url.toURI());
folderName = parent.getName();
parent = parent.getParentFile();
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
try {
FileTreeNode fileTreeNode = new FileTreeNode(parent, folderName);
YSLDFileHandler handler = new YSLDFileHandler();
List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
List<String> expectedLayerNameList = Arrays.asList("point_simplepoint.ysld");
assertEquals(expectedLayerNameList.size(), sldDataList.size());
for (SLDDataInterface sldData : sldDataList) {
assertTrue(expectedLayerNameList.contains(sldData.getLayerName()));
}
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.extension.filesystem.file.ysld.YSLDFileHandler in project sldeditor by robward-scisys.
the class YSLDFileHandlerTest method testGetSLDName.
/**
* Check SLD name
*
* <p>Test method for {@link com.sldeditor.extension.filesystem.file.sld.SLDFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
*/
@Test
public void testGetSLDName() {
YSLDFileHandler handler = new YSLDFileHandler();
assertTrue(handler.getSLDName(null).compareTo("") == 0);
SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.ysld"), "sldContents");
String sldName = handler.getSLDName(sldData);
assertTrue(sldName.compareTo("layer.ysld") == 0);
}
Aggregations