#106 master - fix tests to use GSVersionEncoder

This commit is contained in:
eblondel 2013-10-19 02:21:34 +02:00
parent a277d44e15
commit 80b1767cd1

View File

@ -23,6 +23,7 @@ import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoserverRESTTest; import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTLayer; import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTResource; import it.geosolutions.geoserver.rest.decoder.RESTResource;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder; import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21; import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder; import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
@ -90,50 +91,54 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
"http://www.organization.org/metadata1"); "http://www.organization.org/metadata1");
fte.addMetadataLinkInfo(metadatalink); fte.addMetadataLinkInfo(metadatalink);
GSLayerEncoder layerEncoder = null; GSLayerEncoder layerEncoder = null;
if(GeoserverRESTTest.VERSION != null){ if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
layerEncoder = new GSLayerEncoder(); GSVersionDecoder.VERSION.UNRECOGNIZED)) {
layerEncoder.setEnabled(true); layerEncoder = new GSLayerEncoder();
layerEncoder.setQueryable(true); layerEncoder = new GSLayerEncoder();
layerEncoder.setAdvertised(true); layerEncoder.setEnabled(true);
layerEncoder.setQueryable(true);
layerEncoder.setAdvertised(true);
layerEncoder.setDefaultStyle("point"); layerEncoder.setDefaultStyle("point");
layerEncoder.addStyle("point2"); layerEncoder.addStyle("point2");
layerEncoder.addStyle("point3"); layerEncoder.addStyle("point3");
// authorityURL // authorityURL
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder( GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
"authority1", "http://www.authority1.org"); "authority1", "http://www.authority1.org");
layerEncoder.addAuthorityURL(authorityURL); layerEncoder.addAuthorityURL(authorityURL);
// identifier // identifier
GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder( GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder(
"authority1", "identifier1"); "authority1", "identifier1");
layerEncoder.addIdentifier(identifier); layerEncoder.addIdentifier(identifier);
publisher.createWorkspace(DEFAULT_WS);
publisher.createWorkspace(DEFAULT_WS); File zipFile = new ClassPathResource("testdata/resttestshp.zip")
.getFile();
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile(); // test insert
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
layerName, zipFile);
assertTrue("publish() failed", published);
assertTrue(existsLayer(layerName));
// test insert publisher.publishStyle(new File(new ClassPathResource("testdata")
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile); .getFile(), "default_point.sld"));
assertTrue("publish() failed", published);
assertTrue(existsLayer(layerName));
publisher.publishStyle(new File(new ClassPathResource("testdata").getFile(), // optionally select the attributes to publish
"default_point.sld")); RESTLayer layer = reader.getLayer(layerName);
RESTResource resource = reader.getResource(layer);
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
assertNotNull(attrs);
for (GSAttributeEncoder enc : attrs) {
fte.setAttribute(enc);
}
// optionally select the attributes to publish assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
RESTLayer layer = reader.getLayer(layerName); layerEncoder));
RESTResource resource = reader.getResource(layer);
List<GSAttributeEncoder> attrs = resource.getEncodedAttributeList();
assertNotNull(attrs);
for (GSAttributeEncoder enc : attrs) {
fte.setAttribute(enc);
}
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder));
} }
} }
@ -167,15 +172,16 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
//use of GSLayerEncoder for GS 2.1 & before //use of GSLayerEncoder for GS 2.1 & before
GSLayerEncoder21 layerEncoder = null; GSLayerEncoder21 layerEncoder = null;
if(GeoserverRESTTest.VERSION == null){ if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
layerEncoder = new GSLayerEncoder21(); GSVersionDecoder.VERSION.UNRECOGNIZED)) {
layerEncoder.setEnabled(true); layerEncoder = new GSLayerEncoder21();
layerEncoder.setQueryable(true); layerEncoder.setEnabled(true);
layerEncoder.setAdvertised(true); layerEncoder.setQueryable(true);
layerEncoder.setAdvertised(true);
layerEncoder.setDefaultStyle("point"); layerEncoder.setDefaultStyle("point");
layerEncoder.addStyle("point2"); layerEncoder.addStyle("point2");
layerEncoder.addStyle("point3"); layerEncoder.addStyle("point3");
// authorityURL // authorityURL
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder( GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
@ -193,9 +199,10 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
layerEncoder.addIdentifier(identifier); layerEncoder.addIdentifier(identifier);
layerEncoder.addIdentifier(identifier2); layerEncoder.addIdentifier(identifier2);
publisher.createWorkspace(DEFAULT_WS); publisher.createWorkspace(DEFAULT_WS);
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte, layerEncoder)); assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
} layerEncoder));
}
} }