Search in sources :

Example 46 with SLDData

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

the class SLDDataTest method testDataSourceProperties.

/**
 * Test data source properties.
 */
@Test
public void testDataSourceProperties() {
    DataSourcePropertiesInterface dataSourceProperties = new DummyDataSourceProperties();
    SLDData data = new SLDData(null, null);
    data.setDataSourceProperties(dataSourceProperties);
    assertEquals(dataSourceProperties, data.getDataSourceProperties());
    // Increase code coverage
    data.setDataSourceProperties(dataSourceProperties);
    assertEquals(dataSourceProperties, data.getDataSourceProperties());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) Test(org.junit.Test)

Example 47 with SLDData

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

the class SLDDataTest method testSLDFile.

/**
 * Test sld file.
 */
@Test
public void testSLDFile() {
    SLDData data = new SLDData(null, null);
    File sldFile = null;
    try {
        sldFile = File.createTempFile(getClass().getSimpleName(), ".txt");
    } catch (IOException e) {
        e.printStackTrace();
        fail("Failed to create test SLD file");
    }
    data.setSLDFile(sldFile);
    String expectedFile = sldFile.getAbsolutePath();
    String actualSldFile = data.getSLDFile().getAbsolutePath();
    assertEquals(expectedFile, actualSldFile);
    assertNull(data.getConnectionData());
    sldFile.delete();
}
Also used : SLDData(com.sldeditor.common.data.SLDData) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 48 with SLDData

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

the class SLDDataTest method testVendorOptionList.

/**
 * Test vendor option list.
 */
@Test
public void testVendorOptionList() {
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VersionData.getLatestVersion(this.getClass()));
    SLDData data = new SLDData(null, null);
    data.setVendorOptionList(vendorOptionList);
    assertEquals(vendorOptionList, data.getVendorOptionList());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 49 with SLDData

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

the class SLDDataTest method testSldEditorFile.

/**
 * Test sld editor file.
 */
@Test
public void testSldEditorFile() {
    SLDData data = new SLDData(null, null);
    File sldEditorFile = null;
    try {
        sldEditorFile = File.createTempFile(getClass().getSimpleName(), ".txt");
    } catch (IOException e) {
        e.printStackTrace();
        fail("Failed to create test SLD Editor file");
    }
    data.setSldEditorFile(sldEditorFile);
    assertEquals(sldEditorFile, data.getSldEditorFile());
    sldEditorFile.delete();
}
Also used : SLDData(com.sldeditor.common.data.SLDData) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 50 with SLDData

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

the class ExternalFilenamesTest method testGetText.

/**
 * Test method for {@link com.sldeditor.common.utils.ExternalFilenames#getText(java.net.URL)}.
 */
@Test
public void testGetText() {
    assertNull(ExternalFilenames.getText(null, null));
    SLDData sldData = new SLDData(new StyleWrapper("workspace", "style"), "contents");
    File tempSLDFile = null;
    try {
        tempSLDFile = File.createTempFile(getClass().getSimpleName(), ".sld");
    } catch (IOException e1) {
        e1.printStackTrace();
        fail("Couldn't create temp test file");
    }
    String expectedFilename = "test.tst";
    // Try it with no SLD file set
    assertNull(ExternalFilenames.getFile(sldData, expectedFilename));
    // Now set the SLD file
    sldData.setSLDFile(tempSLDFile);
    String rootFolder = tempSLDFile.getParent();
    String expectedResult = File.separator + expectedFilename;
    File file = new File(rootFolder + expectedResult);
    try {
        String actualResult = ExternalFilenames.getText(sldData, file.toURI().toURL());
        assertEquals(expectedResult, actualResult);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    String actualFilename2 = new File(expectedFilename).getAbsolutePath();
    File file2 = new File(actualFilename2);
    try {
        assertEquals(actualFilename2, ExternalFilenames.getText(sldData, file2.toURI().toURL()));
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    tempSLDFile.delete();
}
Also used : SLDData(com.sldeditor.common.data.SLDData) MalformedURLException(java.net.MalformedURLException) StyleWrapper(com.sldeditor.common.data.StyleWrapper) IOException(java.io.IOException) File(java.io.File) 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