Search in sources :

Example 1 with MapBoxFileHandler

use of com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler 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 2 with MapBoxFileHandler

use of com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler 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)

Aggregations

SLDData (com.sldeditor.common.data.SLDData)2 MapBoxFileHandler (com.sldeditor.extension.filesystem.file.mapbox.MapBoxFileHandler)2 Test (org.junit.Test)2 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Ignore (org.junit.Ignore)1