changes implementing fix for defect #16
This commit is contained in:
parent
31d4aae4a4
commit
76452fb5fe
@ -64,14 +64,30 @@ public class PropertyXMLEncoder extends XmlElement {
|
||||
}
|
||||
|
||||
protected void set(final String key, final String value) {
|
||||
if (key != null && value != null) {
|
||||
Element pp = null;
|
||||
if ((pp = contains(key)) == null)
|
||||
add(key, value);
|
||||
else {
|
||||
remove(pp);
|
||||
add(key, 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) {
|
||||
Element pp = null;
|
||||
if ((pp = contains(key)) == null)
|
||||
add(key, value);
|
||||
else {
|
||||
remove(pp);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
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 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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
public void testAll() {
|
||||
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