Search in sources :

Example 6 with ExternalGraphicDetails

use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails in project sldeditor by robward-scisys.

the class ExternalGraphicDetailsTest method testPopulateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails#populateExpression(java.lang.String)}.
 */
@Test
public void testPopulateExpression() {
    DummyExternalGraphicUpdate callback = new DummyExternalGraphicUpdate();
    ExternalGraphicDetails panel = new ExternalGraphicDetails(callback);
    panel.populateExpression(null);
    String expectedString = "test.png";
    assertFalse(callback.isCalled());
    panel.populateExpression(expectedString);
    assertEquals(expectedString, panel.getExpression().toString());
    assertTrue(callback.isCalled());
}
Also used : ExternalGraphicDetails(com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Test(org.junit.Test)

Example 7 with ExternalGraphicDetails

use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails in project sldeditor by robward-scisys.

the class ExternalGraphicDetailsTest method testSetValueExternalGraphicImpl.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails#setValue(org.geotools.styling.ExternalGraphicImpl)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails#getSymbol()}.
 */
@Test
public void testSetValueExternalGraphicImpl() {
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    ExternalGraphicImpl externalGraphic = null;
    DummyExternalGraphicUpdate callback = new DummyExternalGraphicUpdate();
    ExternalGraphicDetails panel = new ExternalGraphicDetails(callback);
    assertNull(panel.getSymbol());
    panel.setValue(externalGraphic);
    String expectedString = "a/b/c/test.png";
    URL expectedURL = null;
    try {
        expectedURL = new File(expectedString).toURI().toURL();
        externalGraphic = (ExternalGraphicImpl) styleFactory.createExternalGraphic(expectedURL, "image/png");
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
    assertFalse(callback.isCalled());
    panel.setValue(externalGraphic);
    ExternalGraphicImpl actual = (ExternalGraphicImpl) panel.getSymbol();
    try {
        assertEquals(expectedURL.toExternalForm(), actual.getLocation().toExternalForm());
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
    assertTrue(callback.isCalled());
    expectedString = "http://example.com/test.png";
    externalGraphic = (ExternalGraphicImpl) styleFactory.createExternalGraphic(expectedString, "image/png");
    assertFalse(callback.isCalled());
    panel.setValue(externalGraphic);
    actual = (ExternalGraphicImpl) panel.getSymbol();
    assertTrue(callback.isCalled());
    try {
        assertEquals(externalGraphic.getLocation().toExternalForm(), actual.getLocation().toExternalForm());
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) ExternalGraphicDetails(com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 8 with ExternalGraphicDetails

use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails in project sldeditor by robward-scisys.

the class ExternalGraphicDetailsTest method testPopulate.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 */
@Test
public void testPopulate() {
    ExternalGraphicDetails panel = new ExternalGraphicDetails(null);
    panel.populate(null);
}
Also used : ExternalGraphicDetails(com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails) Test(org.junit.Test)

Example 9 with ExternalGraphicDetails

use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails in project sldeditor by robward-scisys.

the class ExternalGraphicDetailsTest method testSetValueString.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails#setValue(java.lang.String)}.
 */
@Test
public void testSetValueString() {
    DummyExternalGraphicUpdate callback = new DummyExternalGraphicUpdate();
    ExternalGraphicDetails panel = new ExternalGraphicDetails(callback);
    String expectedString = null;
    panel.setValue(expectedString);
    expectedString = "a/b/c/test.png";
    assertFalse(callback.isCalled());
    panel.setValue(expectedString);
    assertTrue(callback.isCalled());
    expectedString = "http://example.com/test.png";
    assertFalse(callback.isCalled());
    panel.setValue(expectedString);
    assertTrue(callback.isCalled());
}
Also used : ExternalGraphicDetails(com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Test(org.junit.Test)

Aggregations

ExternalGraphicDetails (com.sldeditor.ui.detail.config.symboltype.externalgraphic.ExternalGraphicDetails)9 Test (org.junit.Test)9 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ExternalGraphicImpl (org.geotools.styling.ExternalGraphicImpl)1 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)1