use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testInitialise.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#initialise(com.sldeditor.common.LoadSLDInterface, com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testInitialise() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
fsExt.initialise(null, new DummyToolMgr());
}
use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testGetPanel.
/**
* Test method for {@link com.sldeditor.extension.filesystem.FileSystemExtension#getPanel()}.
*/
@Test
public void testGetPanel() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
assertTrue(fsExt.getPanel() != null);
}
use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testOpen.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#open(java.net.URL)}.
*/
@Test
public void testOpen() {
FileSystemExtension fsExt = new FileSystemExtension();
fsExt.initialise(null, null);
FileSystemExtensionFactory.override(null);
// Try null parameter
assertNull(fsExt.open(null));
FileSystemExtensionFactory.getFileExtensionList(null);
assertNull(fsExt.open(null));
// Try invalid url
try {
URL url = new URL("http://test.com/abc/xyz.notrecognised");
assertNull(fsExt.open(url));
} catch (MalformedURLException e) {
e.printStackTrace();
fail(e.getMessage());
}
// Try valid url
try {
URL url = new URL("http://test.com/abc/xyz.tst");
assertNull(fsExt.open(url));
} catch (MalformedURLException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testSave.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#save(com.sldeditor.common.SLDDataInterface)}.
*/
@Test
public void testSave() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
// Try null parameter
assertFalse(fsExt.save(null));
assertTrue(fsExt.save(new SLDData(null, null)));
}
use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testUpdateForPreferences.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#updateForPreferences(PrefData, List String)}.
*/
@Test
public void testUpdateForPreferences() {
FileSystemExtension fsExt = new FileSystemExtension();
FileSystemExtensionFactory.override(null);
fsExt.initialise(null, null);
fsExt.updateForPreferences(null, null);
// Set up with 'save last folder view' set to false
PrefData prefData = new PrefData();
String lastFolderViewed = null;
prefData.setLastFolderViewed(lastFolderViewed);
PrefDataLastViewedEnum lastViewedKey = PrefDataLastViewedEnum.FOLDER;
prefData.setLastViewedKey(lastViewedKey);
prefData.setSaveLastFolderView(false);
List<String> actualArgList = new ArrayList<String>();
fsExt.updateForPreferences(prefData, actualArgList);
assertTrue(actualArgList.isEmpty());
// Set up with 'save last folder view' set to true but no folder
prefData.setSaveLastFolderView(true);
fsExt.updateForPreferences(prefData, actualArgList);
assertTrue(actualArgList.isEmpty());
// Set up with 'save last folder view' set to true but with folder
lastFolderViewed = "last viewed";
prefData.setLastFolderViewed(lastFolderViewed);
fsExt.updateForPreferences(prefData, actualArgList);
assertEquals(1, actualArgList.size());
String expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "folder", lastFolderViewed);
assertEquals(expected, actualArgList.get(0));
// Set up with 'save last folder view' set to true but with GeoServer
actualArgList.clear();
lastViewedKey = PrefDataLastViewedEnum.GEOSERVER;
prefData.setLastViewedKey(lastViewedKey);
fsExt.updateForPreferences(prefData, actualArgList);
assertEquals(1, actualArgList.size());
expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", lastFolderViewed);
assertEquals(expected, actualArgList.get(0));
// Try and replace existing argument
// CHECKSTYLE:OFF
String previous = lastFolderViewed;
// CHECKSTYLE:ON
lastFolderViewed = "new folder";
prefData.setLastFolderViewed(lastFolderViewed);
fsExt.updateForPreferences(prefData, actualArgList);
assertEquals(1, actualArgList.size());
expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", previous);
assertEquals(expected, actualArgList.get(0));
}
Aggregations