changes implementing fix for defect #16
This commit is contained in:
parent
2d928874a0
commit
b48b04be9c
@ -64,6 +64,11 @@ public class PropertyXMLEncoder extends XmlElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void set(final String key, final String value) {
|
protected void set(final String key, final String value) {
|
||||||
|
set(getRoot(), key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(final Element e, final String key, final String value){
|
||||||
|
if (!key.contains("/")) {
|
||||||
if (key != null && value != null) {
|
if (key != null && value != null) {
|
||||||
Element pp = null;
|
Element pp = null;
|
||||||
if ((pp = contains(key)) == null)
|
if ((pp = contains(key)) == null)
|
||||||
@ -73,6 +78,17 @@ public class PropertyXMLEncoder extends XmlElement {
|
|||||||
add(key, value);
|
add(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
final int i = key.indexOf("/");
|
||||||
|
final String childName = key.substring(0, i);
|
||||||
|
final String newkey = key.substring(i + 1);
|
||||||
|
|
||||||
|
Element child = e.getChild(childName);
|
||||||
|
if (child == null) {
|
||||||
|
child = new Element(childName);
|
||||||
|
}
|
||||||
|
set(child, newkey, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(Element e, String key, String value) {
|
private void add(Element e, String key, String value) {
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
package it.geosolutions.geoserver.rest.encoder;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class GSResourceEncoderTest {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package it.geosolutions.geoserver.rest.encoder.coverage;
|
package it.geosolutions.geoserver.rest.encoder.coverage;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
||||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
|
||||||
@ -43,6 +45,37 @@ public class GSCoverageEncoderTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
protected final static Logger LOGGER = Logger.getLogger(GSCoverageEncoderTest.class);
|
protected final static Logger LOGGER = Logger.getLogger(GSCoverageEncoderTest.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test set or reset of reprojection
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testReprojection(){
|
||||||
|
GSResourceEncoder<GSDimensionInfoEncoder> re=new GSCoverageEncoder();
|
||||||
|
|
||||||
|
re.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
|
||||||
|
Assert.assertNotNull(re.contains("projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
|
||||||
|
|
||||||
|
re.setProjectionPolicy(ProjectionPolicy.NONE);
|
||||||
|
Assert.assertNull(re.contains("projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
|
||||||
|
Assert.assertNotNull(re.contains("projectionPolicy",ProjectionPolicy.NONE.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test set or reset of BB
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testBB(){
|
||||||
|
GSResourceEncoder<GSDimensionInfoEncoder> re=new GSCoverageEncoder();
|
||||||
|
|
||||||
|
re.setLatLonBoundingBox(-180d, 90d, 180d, -90d, null);
|
||||||
|
Assert.assertNotNull(re.contains("minx","-180.0"));
|
||||||
|
|
||||||
|
re.setLatLonBoundingBox(-90d, 45d, 180d, -90d, null);
|
||||||
|
|
||||||
|
Assert.assertNull(re.contains("minx","-180.0"));
|
||||||
|
Assert.assertNotNull(re.contains("minx","-90.0"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAll() {
|
public void testAll() {
|
||||||
final GSCoverageEncoder encoder=new GSCoverageEncoder();
|
final GSCoverageEncoder encoder=new GSCoverageEncoder();
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
package it.geosolutions.geoserver.rest.encoder.coverage;
|
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class GSResourceEncoderTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test set or reset of reprojection
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testReprojection(){
|
|
||||||
GSResourceEncoder<GSDimensionInfoEncoder> re=new GSCoverageEncoder();
|
|
||||||
|
|
||||||
re.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
|
|
||||||
Assert.assertNotNull(re.contains("projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
|
|
||||||
|
|
||||||
re.setProjectionPolicy(ProjectionPolicy.NONE);
|
|
||||||
Assert.assertNull(re.contains("projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
|
|
||||||
Assert.assertNotNull(re.contains("projectionPolicy",ProjectionPolicy.NONE.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user