Search in sources :

Example 11 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.

the class GeoServerConnectionTest method getTestData.

/**
 * Gets the test data.
 *
 * @return the test data
 */
private GeoServerConnection getTestData() {
    try {
        url = new URL("http://www.example.com/dummy");
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName(connectionName);
    connection1.setUrl(url);
    connection1.setUserName(userName);
    connection1.setPassword(password);
    return connection1;
}
Also used : MalformedURLException(java.net.MalformedURLException) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL)

Example 12 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.

the class GeoServerConnectionTest method testUpdate.

/**
 * Test method for {@link com.sldeditor.common.data.GeoServerConnection#update(com.sldeditor.common.data.GeoServerConnection)}.
 */
@Test
public void testUpdate() {
    GeoServerConnection connection1 = getTestData();
    GeoServerConnection connection2 = new GeoServerConnection();
    connection2.update(connection1);
    assertEquals(connection1.getConnectionName(), connection2.getConnectionName());
    assertEquals(connection1.getPassword(), connection2.getPassword());
    assertEquals(connection1.getUserName(), connection2.getUserName());
    assertEquals(connection1.getUrl().toExternalForm(), connection2.getUrl().toExternalForm());
}
Also used : GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Example 13 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.

the class GeoServerConnectionTest method testDuplicate.

/**
 * Test method for {@link com.sldeditor.common.data.GeoServerConnection#duplicate()}.
 */
@Test
public void testDuplicate() {
    GeoServerConnection connection1 = getTestData();
    GeoServerConnection connection2 = connection1.duplicate();
    assertEquals("Copy of " + connection1.getConnectionName(), connection2.getConnectionName());
    assertEquals(connection1.getPassword(), connection2.getPassword());
    assertEquals(connection1.getUserName(), connection2.getUserName());
    assertEquals(connection1.getUrl().toExternalForm(), connection2.getUrl().toExternalForm());
}
Also used : GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Example 14 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.

the class GeoServerConnectionTest method testGetPassword.

/**
 * Test method for {@link com.sldeditor.common.data.GeoServerConnection#getPassword()}.
 * Test method for {@link com.sldeditor.common.data.GeoServerConnection#setPassword(java.lang.String)}.
 */
@Test
public void testGetPassword() {
    GeoServerConnection connection = new GeoServerConnection();
    String password = "not secret password";
    connection.setPassword(password);
    assertEquals(connection.getPassword(), password);
}
Also used : GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Example 15 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.

the class PrefManagerTest method testSetLastFolderViewed.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#setLastFolderViewed()}.
 */
@Test
public void testSetLastFolderViewed() {
    PrefManager.initialise(null);
    DummyPropertyManager propertyManager = new DummyPropertyManager();
    PrefManager.initialise(propertyManager);
    // Try with a null argument
    PrefManager.getInstance().setLastFolderViewed(null);
    PrefData actualPrefData = PrefManager.getInstance().getPrefData();
    assertFalse(actualPrefData.isSaveLastFolderView());
    assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
    assertNull(actualPrefData.getLastFolderViewed());
    // Try with an empty selected files object
    SelectedFiles selectedFiles = new SelectedFiles();
    PrefManager.getInstance().setLastFolderViewed(selectedFiles);
    actualPrefData = PrefManager.getInstance().getPrefData();
    assertFalse(actualPrefData.isSaveLastFolderView());
    assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
    assertNull(actualPrefData.getLastFolderViewed());
    // Set folder
    String expectedFolderName = "/tmp/test/abc";
    selectedFiles.setFolderName(expectedFolderName);
    PrefManager.getInstance().setLastFolderViewed(selectedFiles);
    actualPrefData = PrefManager.getInstance().getPrefData();
    assertFalse(actualPrefData.isSaveLastFolderView());
    assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
    assertEquals(expectedFolderName, actualPrefData.getLastFolderViewed());
    expectedFolderName = "c:/tmp/test/abc";
    selectedFiles.setFolderName(expectedFolderName);
    PrefManager.getInstance().setLastFolderViewed(selectedFiles);
    actualPrefData = PrefManager.getInstance().getPrefData();
    assertFalse(actualPrefData.isSaveLastFolderView());
    assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
    assertEquals(expectedFolderName, actualPrefData.getLastFolderViewed());
    actualPrefData.setSaveLastFolderView(true);
    PrefManager.getInstance().setPrefData(actualPrefData);
    actualPrefData = PrefManager.getInstance().getPrefData();
    assertTrue(actualPrefData.isSaveLastFolderView());
    // Set geoserver
    String expectedGeoServerName = "GeoServer test";
    GeoServerConnection connectionData = new GeoServerConnection();
    connectionData.setConnectionName(expectedGeoServerName);
    selectedFiles = new SelectedFiles();
    selectedFiles.setConnectionData(connectionData);
    PrefManager.getInstance().setLastFolderViewed(selectedFiles);
    actualPrefData = PrefManager.getInstance().getPrefData();
    assertTrue(actualPrefData.isSaveLastFolderView());
    assertEquals(PrefDataLastViewedEnum.GEOSERVER, actualPrefData.getLastViewedKey());
    assertEquals(expectedGeoServerName, actualPrefData.getLastFolderViewed());
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Aggregations

GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)50 Test (org.junit.Test)31 URL (java.net.URL)12 ArrayList (java.util.ArrayList)11 StyleWrapper (com.sldeditor.common.data.StyleWrapper)10 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)9 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)9 MalformedURLException (java.net.MalformedURLException)9 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)8 SLDData (com.sldeditor.common.data.SLDData)7 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)5 GeoServerOverallNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerOverallNode)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5 GeoServerReadProgress (com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress)5 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)5 HashMap (java.util.HashMap)5 List (java.util.List)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4