use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.
the class MapBoxToolTest method testGetPanel.
/**
* Test method for {@link com.sldeditor.tool.mapbox.MapBoxTool#getPanel()}.
*/
@Test
public void testGetPanel() {
MapBoxTool tool = new MapBoxTool();
assertTrue(tool.getPanel() != null);
}
use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.
the class MapBoxToolTest method testGetToolName.
/**
* Test method for {@link com.sldeditor.tool.mapbox.MapBoxTool#getToolName()}.
*/
@Test
public void testGetToolName() {
MapBoxTool tool = new MapBoxTool();
String toolName = tool.getToolName();
assertTrue(toolName.compareTo("com.sldeditor.tool.mapbox.MapBoxTool") == 0);
}
use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.
the class MapBoxToolTest method testSupports.
/**
* Test method for
* {@link com.sldeditor.tool.mapbox.MapBoxTool#supports(java.util.List, java.util.List, java.util.List)}.
*/
@Test
public void testSupports() {
MapBoxTool tool = new MapBoxTool();
assertFalse(tool.supports(null, null, null));
File testFile1 = null;
File testFile2 = null;
File testFile3 = null;
try {
testFile1 = File.createTempFile("invalid", ".tst");
testFile2 = File.createTempFile("valid", ".sld");
testFile3 = File.createTempFile("valid", ".json");
} catch (IOException e1) {
e1.printStackTrace();
}
// Try with invalid file
try {
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
assertNotNull(testFile1);
nodeTypeList.add(new FileTreeNode(testFile1.getParentFile(), testFile1.getName()));
assertFalse(tool.supports(null, nodeTypeList, null));
} catch (SecurityException | FileNotFoundException e) {
e.printStackTrace();
}
// Try with valid mapbox file
try {
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
nodeTypeList.add(new FileTreeNode(testFile3.getParentFile(), testFile3.getName()));
assertTrue(tool.supports(null, nodeTypeList, null));
} catch (SecurityException | FileNotFoundException e) {
e.printStackTrace();
}
// Try with several files
try {
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
nodeTypeList.add(new FileTreeNode(testFile1.getParentFile(), testFile1.getName()));
nodeTypeList.add(new FileTreeNode(testFile2.getParentFile(), testFile2.getName()));
nodeTypeList.add(new FileTreeNode(testFile3.getParentFile(), testFile3.getName()));
assertFalse(tool.supports(null, nodeTypeList, null));
} catch (SecurityException | FileNotFoundException e) {
e.printStackTrace();
}
testFile1.delete();
testFile2.delete();
testFile3.delete();
}
use of com.sldeditor.tool.mapbox.MapBoxTool in project sldeditor by robward-scisys.
the class MapBoxToolTest method testSetSelectedItems.
/**
* Test method for
* {@link com.sldeditor.tool.mapbox.MapBoxTool#setSelectedItems(java.util.List, java.util.List)}.
*/
@Test
public void testSetSelectedItems() {
MapBoxTool tool = new MapBoxTool();
JPanel panel = tool.getPanel();
ToolButton toSLD = null;
for (Component c : panel.getComponents()) {
if (c instanceof ToolButton) {
ToolButton button = (ToolButton) c;
String toolTipText = button.getToolTipText();
if (toolTipText.compareTo(Localisation.getString(MapBoxTool.class, "MapBoxTool.exportToSLD")) == 0) {
toSLD = button;
}
}
}
File testFile1 = null;
File testFile3 = null;
try {
testFile1 = File.createTempFile("invalid", ".tst");
testFile3 = File.createTempFile("valid", ".json");
} catch (IOException e1) {
e1.printStackTrace();
}
// Should both be disabled
assertFalse(toSLD.isEnabled());
tool.setSelectedItems(null, null);
// Invalid file
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
SLDData sldData1 = new SLDData(null, null);
sldData1.setSLDFile(testFile1);
sldDataList.add(sldData1);
tool.setSelectedItems(null, sldDataList);
// Should both be disabled
assertFalse(toSLD.isEnabled());
/*
* // Try with valid mapbox file sldDataList = new ArrayList<SLDDataInterface>(); SLDData
* sldData3 = getSLDDataFile("/point/mapbox/circleStyleTest.json");
* sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
*
* // SLD should be enabled assertTrue(toSLD.isEnabled()); toSLD.doClick();
*
* // Try with valid sld files sldDataList = new ArrayList<SLDDataInterface>();
* sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
*
* // SLD should be enabled assertTrue(toSLD.isEnabled());
*/
testFile1.delete();
testFile3.delete();
// tidyUpTempFiles(sldData3.getSLDFile());
}
Aggregations