Search in sources :

Example 6 with FileSystemExtension

use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testCreateMenus.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#createMenus(javax.swing.JMenu)}.
 */
@Test
public void testCreateMenus() {
    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.createMenus(null);
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with FileSystemExtension

use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testGetExtensionArgPrefix.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#getExtensionArgPrefix()}.
 */
@Test
public void testGetExtensionArgPrefix() {
    FileSystemExtension fsExt = new FileSystemExtension();
    DummyExtension dummyExtension = new DummyExtension();
    List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
    overrideExtensionList.add(dummyExtension);
    FileSystemExtensionFactory.override(overrideExtensionList);
    fsExt.initialise(null, null);
    assertEquals("file", fsExt.getExtensionArgPrefix());
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with FileSystemExtension

use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testGetName.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.FileSystemExtension#getName()}.
 */
@Test
public void testGetName() {
    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.getName() != null);
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with FileSystemExtension

use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testGetTooltip.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.FileSystemExtension#getTooltip()}.
 */
@Test
public void testGetTooltip() {
    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.getTooltip() != null);
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with FileSystemExtension

use of com.sldeditor.extension.filesystem.FileSystemExtension in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testSetArguments.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#setArguments(java.util.List)}.
 */
@Test
public void testSetArguments() {
    File configPropertiesFile = new File("./FileSystemExtensionTest.properties");
    PropertyManagerFactory.getInstance().setPropertyFile(configPropertiesFile);
    FileSystemExtension fsExt = new FileSystemExtension();
    FileSystemExtensionFactory.override(null);
    fsExt.initialise(null, new DummyToolMgr());
    // Handle null argument
    fsExt.setArguments(null);
    List<String> extensionArgList = new ArrayList<String>();
    extensionArgList.add("invalid1");
    extensionArgList.add("in.val.id2");
    extensionArgList.add("in.va.li.d3.");
    extensionArgList.add("invalid4=abc");
    String actual = fsExt.setArguments(extensionArgList);
    assertNull(actual);
    // File does not exist
    extensionArgList.clear();
    String expectedFile = "folder=X:\\asdef";
    extensionArgList.add(expectedFile);
    actual = fsExt.setArguments(extensionArgList);
    assertNull(actual);
    // Valid file
    extensionArgList.clear();
    File f = null;
    try {
        f = File.createTempFile(getClass().getSimpleName(), ".tmp");
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
    expectedFile = "folder=" + f.getParent();
    extensionArgList.add(expectedFile);
    actual = fsExt.setArguments(extensionArgList);
    assertEquals(expectedFile, actual);
    f.delete();
    // Invalid GeoServer
    extensionArgList.clear();
    String expectedGeoServer = "geoserver=unknown";
    extensionArgList.add(expectedGeoServer);
    actual = fsExt.setArguments(extensionArgList);
    assertNull(actual);
    // Valid GeoServer
    GeoServerConnection geoServerConnection = new GeoServerConnection();
    geoServerConnection.setConnectionName("GeoServer connection");
    try {
        geoServerConnection.setUrl(new URL("http://localhost/geoserver"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
    geoServerConnection.setUserName("username");
    geoServerConnection.setPassword("password");
    GeoServerConnectionManager.getInstance().addNewConnection(null, geoServerConnection);
    GeoServerConnectionManager.getInstance().updateList();
    extensionArgList.clear();
    expectedGeoServer = "geoserver=" + geoServerConnection.getConnectionName();
    extensionArgList.add(expectedGeoServer);
    actual = fsExt.setArguments(extensionArgList);
    assertEquals(expectedGeoServer, actual);
    configPropertiesFile.delete();
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) 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