Search in sources :

Example 71 with SLDDataInterface

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

the class GeoServerInputTest method testCopyNodes.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#copyNodes(com.sldeditor.common.NodeInterface, java.util.Map)}.
 */
@Test
public void testCopyNodes() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    FSTree tree = new FSTree();
    DefaultMutableTreeNode rootNode;
    rootNode = new DefaultMutableTreeNode("Root");
    DefaultTreeModel model = new DefaultTreeModel(rootNode);
    input.populate(tree, model, rootNode);
    URL url = SLDFileHandlerTest.class.getResource("/sld/point_attribute.sld");
    List<SLDDataInterface> sldDataList = input.open(url);
    assertNull(sldDataList);
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    // Add some GeoServer connections
    input.addNewConnection(connection1);
    // Try null parameters
    assertFalse(input.copyNodes(null, null));
    // Try with valid parameters
    GeoServerWorkspaceNode workspaceTreeNode = new GeoServerWorkspaceNode(input, connection1, "test workspace", false);
    // Create test data
    Map<NodeInterface, List<SLDDataInterface>> copyDataMap = new HashMap<NodeInterface, List<SLDDataInterface>>();
    List<SLDDataInterface> sldToCopyList = new ArrayList<SLDDataInterface>();
    StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
    SLDData sldData = new SLDData(styleWrapper, "sld contents");
    sldData.setConnectionData(connection1);
    sldToCopyList.add(sldData);
    copyDataMap.put(workspaceTreeNode, sldToCopyList);
    assertFalse(input.copyNodes(workspaceTreeNode, null));
    assertFalse(input.copyNodes(null, copyDataMap));
    // Try with valid parameters
    assertTrue(input.copyNodes(workspaceTreeNode, copyDataMap));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HashMap(java.util.HashMap) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) ArrayList(java.util.ArrayList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 72 with SLDDataInterface

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

the class DatabaseConnectionToolTest method testDatabaseConnectionTool.

/**
 * Test method for
 * {@link com.sldeditor.tool.databaseconnection.DatabaseConnectionTool#DatabaseConnectionTool(com.sldeditor.tool.databaseconnection.DatabaseConnectStateInterface)}.
 */
@Test
public void testDatabaseConnectionTool() {
    TestDatabaseConnectState state = new TestDatabaseConnectState();
    TestDatabaseConnectionTool testObj = new TestDatabaseConnectionTool(state);
    testObj.setSelectedItems(null, null);
    List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
    DatabaseConnection connection = DatabaseConnectionFactory.createGeoPackage();
    nodeTypeList.add(new DatabaseNode(new DatabaseInput(ToolManager.getInstance()), connection));
    File parent = new File("");
    String filename = "test.gpkg";
    FileTreeNode fileTreeNode = null;
    try {
        fileTreeNode = new FileTreeNode(parent, filename);
        fileTreeNode.setFileCategory(FileTreeNodeTypeEnum.DATABASE);
        nodeTypeList.add(fileTreeNode);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    testObj.setSelectedItems(nodeTypeList, null);
    testObj.populateComplete(null);
    assertNotNull(testObj.getPanel());
    List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
    List<SLDDataInterface> sldDataList = null;
    assertFalse(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    uniqueNodeTypeList.add(String.class);
    assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    nodeTypeList.remove(0);
    assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
    testObj.testConnect();
    testObj.testDisconnect();
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) DatabaseInput(com.sldeditor.extension.filesystem.database.DatabaseInput) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test)

Aggregations

SLDDataInterface (com.sldeditor.common.SLDDataInterface)72 File (java.io.File)34 IOException (java.io.IOException)21 SLDData (com.sldeditor.common.data.SLDData)20 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)20 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)17 URL (java.net.URL)17 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)14 StyleWrapper (com.sldeditor.common.data.StyleWrapper)12 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)12 FileNotFoundException (java.io.FileNotFoundException)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 URISyntaxException (java.net.URISyntaxException)10 NodeInterface (com.sldeditor.common.NodeInterface)9 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)6 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)5 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5