This commit is contained in:
Deleted user 2019-07-05 22:27:38 +00:00 committed by GitHub
commit dd1dc5537b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 110 additions and 8 deletions

View File

@ -130,14 +130,22 @@ public class RESTLayerGroup {
}
}
public RESTPublishedList getPublishedList() {
if (rootElem.getChild("publishables") != null) {
return new RESTPublishedList(rootElem.getChild("publishables"));
} else {
return null;
}
}
public RESTPublishedList getPublishedList() {
if (rootElem.getChild("publishables") != null) {
return new RESTPublishedList(rootElem.getChild("publishables"));
} else {
return null;
}
}
public RESTStyleList getStyleList() {
if (rootElem.getChild("styles") != null) {
return new RESTStyleList(rootElem.getChild("styles"));
} else {
return null;
}
}
public String getCRS() {
Element bounds = rootElem.getChild("bounds");
return bounds.getChildText("crs");

View File

@ -0,0 +1,47 @@
package it.geosolutions.geoserver.rest.decoder;
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.Test;
public class RESTLayerGroupTest {
@Test
public void parseLayerGroup() throws IOException{
InputStream is = RESTFeatureTypeListTest.class.getResourceAsStream("/testdata/layergroups.xml");
String response = IOUtils.toString(is);
RESTLayerGroup lg = RESTLayerGroup.build(response);
String[] expected_layers=new String[]{
"layer001",
"layer002",
"layer003",
"geo:lg001",
"geo:lg002"
};
String[] expected_styles=new String[]{
"grass",
null,
"raster",
null,
null
};
RESTPublishedList children = lg.getPublishedList();
RESTStyleList styles = lg.getStyleList();
for (int i=0;i<children.size();i++){
RESTPublished child = children.get(i);
NameLinkElem style = styles.get(i);
Assert.assertEquals(child.getName(), expected_layers[i]);
Assert.assertEquals(style.getName(), expected_styles[i]);
}
}
}

View File

@ -0,0 +1,47 @@
<layerGroup>
<name>lg003</name>
<mode>SINGLE</mode>
<workspace>
<name>geo</name>
</workspace>
<publishables>
<published type="layer">
<name>layer001</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost/geoserver/rest/layers/layer001.xml" type="application/xml"/>
</published>
<published type="layer">
<name>layer002</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost/geoserver/rest/layers/layer002.xml" type="application/xml"/>
</published>
<published type="layer">
<name>layer003</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost/geoserver/rest/layers/layer003.xml" type="application/xml"/>
</published>
<published type="layerGroup">
<name>geo:lg001</name>
</published>
<published type="layerGroup">
<name>geo:lg002</name>
</published>
</publishables>
<styles>
<style>
<name>grass</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost/geoserver/rest/styles/grass.xml" type="application/xml"/>
</style>
<style/>
<style>
<name>raster</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost/geoserver/rest/styles/raster.xml" type="application/xml"/>
</style>
<style/>
<style/>
</styles>
<bounds>
<minx>-2.00375083428E7</minx>
<maxx>2.00375083428E7</maxx>
<miny>-2.00375083428E7</miny>
<maxy>2.00375083428E7</maxy>
<crs class="projected">EPSG:3857</crs>
</bounds>
</layerGroup>