Search in sources :

Example 31 with SLDData

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

the class MapBoxFileHandlerTest method testGetSLDContents.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
 */
@Test
@Ignore
public void testGetSLDContents() {
    assertNull(new MapBoxFileHandler().getSLDContents(null));
    URL url = MapBoxFileHandlerTest.class.getResource("/point/mapbox");
    File parent = null;
    try {
        parent = new File(url.toURI());
    } catch (URISyntaxException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    try {
        FileTreeNode fileTreeNode = new FileTreeNode(parent, "circleStyleTest.json");
        MapBoxFileHandler handler = new MapBoxFileHandler();
        List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
        assertEquals(1, sldDataList.size());
        // Changes where the file is to be saved to
        File saveFile = File.createTempFile(getClass().getSimpleName(), ".json");
        SLDData sldData = (SLDData) sldDataList.get(0);
        sldData.setSLDFile(saveFile);
        assertFalse(handler.save(null));
        assertTrue(handler.save(sldData));
        saveFile.delete();
    } catch (SecurityException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDDataInterface(com.sldeditor.common.SLDDataInterface) FileNotFoundException(java.io.FileNotFoundException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) MapBoxFileHandler(com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 32 with SLDData

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

the class MapBoxFileHandlerTest method testGetSLDName.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler#getSLDName(com.sldeditor.common.SLDDataInterface)}.
 */
@Test
public void testGetSLDName() {
    MapBoxFileHandler handler = new MapBoxFileHandler();
    assertTrue(handler.getSLDName(null).compareTo("") == 0);
    SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), "sldContents");
    String sldName = handler.getSLDName(sldData);
    assertTrue(sldName.compareTo("layer.json") == 0);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyleWrapper(com.sldeditor.common.data.StyleWrapper) MapBoxFileHandler(com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler) Test(org.junit.Test)

Example 33 with SLDData

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

the class RasterFileHandlerTest method testGetSLDName.

/**
 * Supply a folder name and retrieve all the sld files in it
 *
 * <p>Test method for {@link com.sldeditor.extension.filesystem.file.raster.RasterFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
 */
@Test
public void testGetSLDName() {
    RasterFileHandler handler = new RasterFileHandler();
    assertTrue(handler.getSLDName(null).compareTo("") == 0);
    SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), "sldContents");
    String sldName = handler.getSLDName(sldData);
    assertTrue(sldName.compareTo("layer.sld") == 0);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyleWrapper(com.sldeditor.common.data.StyleWrapper) RasterFileHandler(com.sldeditor.extension.filesystem.file.raster.RasterFileHandler) Test(org.junit.Test)

Example 34 with SLDData

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

the class SLDFileEditorHandlerTest method testGetSLDContents.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.file.sldeditor.SLDEditorFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
 */
@Test
public void testGetSLDContents() {
    assertNull(new SLDEditorFileHandler().getSLDContents(null));
    URL url = SLDFileEditorHandlerTest.class.getResource("/point/sld");
    File parent = null;
    try {
        parent = new File(url.toURI());
    } catch (URISyntaxException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    System.out.println(url.toString());
    try {
        FileTreeNode fileTreeNode = new FileTreeNode(parent, "point_attribute.sld");
        SLDFileHandler handler = new SLDFileHandler();
        List<SLDDataInterface> sldDataList = handler.getSLDContents(fileTreeNode);
        assertEquals(1, sldDataList.size());
        // Changes where the file is to be saved to
        File sldEditorFile = File.createTempFile(getClass().getSimpleName(), ".sldeditor");
        SLDData sldData = (SLDData) sldDataList.get(0);
        sldData.setSldEditorFile(sldEditorFile);
        SLDEditorFileHandler editorFileHandler = new SLDEditorFileHandler();
        assertFalse(handler.save(null));
        assertTrue(editorFileHandler.save(sldData));
        SLDEditorFileHandler editorFileHandler2 = new SLDEditorFileHandler();
        List<SLDDataInterface> actualSldDataList = editorFileHandler2.open(sldEditorFile);
        assertEquals(1, actualSldDataList.size());
        FileTreeNode editorFileTreeNode = new FileTreeNode(sldEditorFile.getParentFile(), sldEditorFile.getName());
        List<SLDDataInterface> actualSldDataList2 = editorFileHandler2.getSLDContents(editorFileTreeNode);
        assertEquals(1, actualSldDataList2.size());
        sldEditorFile.delete();
    } catch (SecurityException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDDataInterface(com.sldeditor.common.SLDDataInterface) FileNotFoundException(java.io.FileNotFoundException) SLDEditorFileHandler(com.sldeditor.extension.filesystem.file.sldeditor.SLDEditorFileHandler) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) SLDFileHandler(com.sldeditor.extension.filesystem.file.sld.SLDFileHandler) File(java.io.File) URL(java.net.URL) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) Test(org.junit.Test)

Example 35 with SLDData

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

the class VectorFileHandlerTest method testGetSLDName.

/**
 * Supply a folder name and retrieve all the sld files in it
 *
 * <p>Test method for {@link com.sldeditor.extension.filesystem.file.vector.VectorFileHandler#getSLDContents(com.sldeditor.common.NodeInterface)}.
 */
@Test
public void testGetSLDName() {
    VectorFileHandler handler = new VectorFileHandler();
    assertTrue(handler.getSLDName(null).compareTo("") == 0);
    SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), "sldContents");
    String sldName = handler.getSLDName(sldData);
    assertTrue(sldName.compareTo("layer.sld") == 0);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyleWrapper(com.sldeditor.common.data.StyleWrapper) VectorFileHandler(com.sldeditor.extension.filesystem.file.vector.VectorFileHandler) Test(org.junit.Test)

Aggregations

SLDData (com.sldeditor.common.data.SLDData)68 Test (org.junit.Test)54 StyleWrapper (com.sldeditor.common.data.StyleWrapper)35 File (java.io.File)27 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)24 SLDDataInterface (com.sldeditor.common.SLDDataInterface)20 IOException (java.io.IOException)20 URL (java.net.URL)16 ArrayList (java.util.ArrayList)14 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)8 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)8 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)7 FileNotFoundException (java.io.FileNotFoundException)7 URISyntaxException (java.net.URISyntaxException)7 MalformedURLException (java.net.MalformedURLException)6 NamedLayer (org.geotools.styling.NamedLayer)6 Style (org.geotools.styling.Style)6 SLDWriterInterface (com.sldeditor.common.output.SLDWriterInterface)5 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)5 VersionData (com.sldeditor.common.vendoroption.VersionData)4