Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,22 @@ public RESTLayerList getLayerList() {
}
}

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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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]);
}
}
}
47 changes: 47 additions & 0 deletions src/test/resources/testdata/layergroups.xml
Original file line number Diff line number Diff line change
@@ -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>