Search in sources :

Example 16 with SLDData

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

the class SLDDataTest method testResourceLocator.

/**
 * Test resource locator.
 */
@Test
public void testResourceLocator() {
    SLDData data = new SLDData(null, null);
    assertNull(data.getResourceLocator());
    try {
        URL url = new URL("http://localhost:8080/geoserver");
        data.setResourceLocator(url);
        URL actualValue = data.getResourceLocator();
        assertTrue(url.toExternalForm().compareTo(actualValue.toExternalForm()) == 0);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Test(org.junit.Test)

Example 17 with SLDData

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

the class SLDDataTest method testOriginalFormat.

/**
 * Test original format.
 */
@Test
public void testOriginalFormat() {
    SLDData data = new SLDData(null, null);
    assertEquals(SLDOutputFormatEnum.SLD, data.getOriginalFormat());
    SLDOutputFormatEnum expected = SLDOutputFormatEnum.YSLD;
    data.setOriginalFormat(expected);
    assertEquals(expected, data.getOriginalFormat());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDOutputFormatEnum(com.sldeditor.common.output.SLDOutputFormatEnum) Test(org.junit.Test)

Example 18 with SLDData

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

the class SLDUtilsTest method testCreateSLDFromStringFile.

@Test
public void testCreateSLDFromStringFile() {
    StyleWrapper wrapper = new StyleWrapper();
    SLDData sldData = new SLDData(wrapper, expectedSld);
    String filename = "D:/tmp/test.sld";
    File file = new File(filename);
    sldData.setSLDFile(file);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
    assertNull(sld);
    sld = SLDUtils.createSLDFromString(sldData);
    StyledLayer[] styledLayers = sld.getStyledLayers();
    NamedLayer namedLayer = (NamedLayer) styledLayers[0];
    Style[] actualStyles = namedLayer.getStyles();
    PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
    assertEquals("circle", mark.getWellKnownName().toString());
    // Check resource locator
    try {
        URL url = file.getParentFile().toURI().toURL();
        String actualResourceLocator = sldData.getResourceLocator().toExternalForm();
        String expectedResourcelocator = url.toExternalForm();
        assertTrue(expectedResourcelocator.compareTo(actualResourceLocator) == 0);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) MalformedURLException(java.net.MalformedURLException) StyledLayer(org.geotools.styling.StyledLayer) MarkImpl(org.geotools.styling.MarkImpl) URL(java.net.URL) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyleWrapper(com.sldeditor.common.data.StyleWrapper) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) File(java.io.File) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 19 with SLDData

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

the class SelectedFilesTest method test.

@Test
public void test() {
    SelectedFiles selectedFiles = new SelectedFiles();
    assertTrue(selectedFiles.isDataSource() == false);
    assertTrue(selectedFiles.isFolder() == false);
    assertTrue(selectedFiles.getSldData().isEmpty());
    selectedFiles.setDataSource(true);
    assertTrue(selectedFiles.isDataSource());
    selectedFiles.setIsFolder(true);
    assertTrue(selectedFiles.isFolder());
    List<SLDDataInterface> actualSldData = new ArrayList<SLDDataInterface>();
    actualSldData.add(new SLDData(null, "test1"));
    actualSldData.add(new SLDData(null, "test2"));
    actualSldData.add(new SLDData(null, "test3"));
    selectedFiles.setSldData(actualSldData);
    assertTrue(selectedFiles.getSldData().size() == actualSldData.size());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with SLDData

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

the class SLDWriterImplTest method testEncodeSLD.

/**
 * Test method for {@link com.sldeditor.common.output.impl.SLDWriterImpl#encodeSLD(org.geotools.styling.StyledLayerDescriptor)}.
 */
@Test
public void testEncodeSLD() {
    SLDWriterImpl writer = new SLDWriterImpl();
    String result = writer.encodeSLD(null, null);
    assertEquals("", result);
    SLDData sldData = new SLDData(null, expectedSld);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    // No resource locator
    result = writer.encodeSLD(null, sld);
    assertTrue(!result.isEmpty());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDWriterImpl(com.sldeditor.common.output.impl.SLDWriterImpl) 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