#102 master - fix tests
This commit is contained in:
parent
80b1767cd1
commit
6689211b5d
@ -95,114 +95,54 @@ public class GSFeatureEncoderTest extends GeoserverRESTTest {
|
|||||||
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
if (!GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
||||||
layerEncoder = new GSLayerEncoder();
|
layerEncoder = new GSLayerEncoder();
|
||||||
layerEncoder = new GSLayerEncoder();
|
} else if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
||||||
layerEncoder.setEnabled(true);
|
|
||||||
layerEncoder.setQueryable(true);
|
|
||||||
layerEncoder.setAdvertised(true);
|
|
||||||
|
|
||||||
layerEncoder.setDefaultStyle("point");
|
|
||||||
layerEncoder.addStyle("point2");
|
|
||||||
layerEncoder.addStyle("point3");
|
|
||||||
|
|
||||||
// authorityURL
|
|
||||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
|
||||||
"authority1", "http://www.authority1.org");
|
|
||||||
layerEncoder.addAuthorityURL(authorityURL);
|
|
||||||
|
|
||||||
// identifier
|
|
||||||
GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder(
|
|
||||||
"authority1", "identifier1");
|
|
||||||
layerEncoder.addIdentifier(identifier);
|
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
publisher.publishStyle(new File(new ClassPathResource("testdata")
|
|
||||||
.getFile(), "default_point.sld"));
|
|
||||||
|
|
||||||
// optionally select the attributes to publish
|
|
||||||
RESTLayer layer = reader.getLayer(layerName);
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIntegration1() throws IOException {
|
|
||||||
|
|
||||||
if (!enabled())
|
|
||||||
return;
|
|
||||||
deleteAll();
|
|
||||||
|
|
||||||
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
|
|
||||||
|
|
||||||
String storeName = "resttestshp";
|
|
||||||
String layerName = "cities";
|
|
||||||
|
|
||||||
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
|
|
||||||
fte.setNativeName(layerName);
|
|
||||||
fte.setName(layerName + "_NEW2");
|
|
||||||
fte.setTitle("title");
|
|
||||||
fte.setNativeCRS("EPSG:4326");
|
|
||||||
fte.setDescription("desc");
|
|
||||||
fte.setEnabled(true);
|
|
||||||
|
|
||||||
//metadataLink
|
|
||||||
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder(
|
|
||||||
"text/xml", "ISO19115:2003",
|
|
||||||
"http://www.organization.org/metadata1");
|
|
||||||
fte.addMetadataLinkInfo(metadatalink);
|
|
||||||
|
|
||||||
//use of GSLayerEncoder for GS 2.1 & before
|
|
||||||
GSLayerEncoder21 layerEncoder = null;
|
|
||||||
if (GSVersionDecoder.VERSION.getVersion(VERSION).equals(
|
|
||||||
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
GSVersionDecoder.VERSION.UNRECOGNIZED)) {
|
||||||
layerEncoder = new GSLayerEncoder21();
|
layerEncoder = new GSLayerEncoder21();
|
||||||
layerEncoder.setEnabled(true);
|
|
||||||
layerEncoder.setQueryable(true);
|
|
||||||
layerEncoder.setAdvertised(true);
|
|
||||||
|
|
||||||
layerEncoder.setDefaultStyle("point");
|
|
||||||
layerEncoder.addStyle("point2");
|
|
||||||
layerEncoder.addStyle("point3");
|
|
||||||
|
|
||||||
// authorityURL
|
|
||||||
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
|
||||||
"authority1", "http://www.authority1.org");
|
|
||||||
GSAuthorityURLInfoEncoder authorityURL2 = new GSAuthorityURLInfoEncoder(
|
|
||||||
"authority2", "http://www.authority2.org");
|
|
||||||
layerEncoder.addAuthorityURL(authorityURL);
|
|
||||||
layerEncoder.addAuthorityURL(authorityURL2);
|
|
||||||
|
|
||||||
// identifier
|
|
||||||
GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder(
|
|
||||||
"authority1", "identifier1");
|
|
||||||
GSIdentifierInfoEncoder identifier2 = new GSIdentifierInfoEncoder(
|
|
||||||
"authority2", "identifier2");
|
|
||||||
layerEncoder.addIdentifier(identifier);
|
|
||||||
layerEncoder.addIdentifier(identifier2);
|
|
||||||
|
|
||||||
publisher.createWorkspace(DEFAULT_WS);
|
|
||||||
assertTrue(publisher.publishDBLayer(DEFAULT_WS, storeName, fte,
|
|
||||||
layerEncoder));
|
|
||||||
}
|
}
|
||||||
|
layerEncoder.setEnabled(true);
|
||||||
|
layerEncoder.setQueryable(true);
|
||||||
|
layerEncoder.setAdvertised(true);
|
||||||
|
|
||||||
|
layerEncoder.setDefaultStyle("point");
|
||||||
|
layerEncoder.addStyle("point2");
|
||||||
|
layerEncoder.addStyle("point3");
|
||||||
|
|
||||||
|
// authorityURL
|
||||||
|
GSAuthorityURLInfoEncoder authorityURL = new GSAuthorityURLInfoEncoder(
|
||||||
|
"authority1", "http://www.authority1.org");
|
||||||
|
layerEncoder.addAuthorityURL(authorityURL);
|
||||||
|
|
||||||
|
// identifier
|
||||||
|
GSIdentifierInfoEncoder identifier = new GSIdentifierInfoEncoder(
|
||||||
|
"authority1", "identifier1");
|
||||||
|
layerEncoder.addIdentifier(identifier);
|
||||||
|
|
||||||
|
publisher.createWorkspace(DEFAULT_WS);
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
publisher.publishStyle(new File(new ClassPathResource("testdata")
|
||||||
|
.getFile(), "default_point.sld"));
|
||||||
|
|
||||||
|
// optionally select the attributes to publish
|
||||||
|
RESTLayer layer = reader.getLayer(layerName);
|
||||||
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user