Search in sources :

Example 1 with FileSystemExtension

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());
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with FileSystemExtension

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);
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with FileSystemExtension

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());
    }
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Test(org.junit.Test)

Example 4 with FileSystemExtension

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)));
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) SLDData(com.sldeditor.common.data.SLDData) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with FileSystemExtension

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));
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) PrefData(com.sldeditor.common.preferences.PrefData) PrefDataLastViewedEnum(com.sldeditor.common.preferences.PrefDataLastViewedEnum) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

FileSystemExtension (com.sldeditor.extension.filesystem.FileSystemExtension)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)7 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)1 SLDData (com.sldeditor.common.data.SLDData)1 PrefData (com.sldeditor.common.preferences.PrefData)1 PrefDataLastViewedEnum (com.sldeditor.common.preferences.PrefDataLastViewedEnum)1 File (java.io.File)1 IOException (java.io.IOException)1