Merge pull request #97 from eblondel/1.5.x-95-keywords-decoder

1.5.x - #95 - keywords decoder
This commit is contained in:
Carlo Cancellieri 2013-09-30 05:25:46 -07:00
commit 539edf5429
4 changed files with 142 additions and 19 deletions

View File

@ -71,6 +71,22 @@ public class RESTResource {
public String getAbstract() {
return rootElem.getChildText("abstract");
}
public List<String> getKeywords(){
List<String> kwdsList = null;
final Element keywordsRoot = rootElem.getChild("keywords");
if(keywordsRoot != null){
final List<Element> keywords = keywordsRoot.getChildren();
if(keywords != null){
kwdsList = new ArrayList<String>(keywords.size());
for(Element keyword : keywords){
kwdsList.add(keyword.getValue());
}
}
}
return kwdsList;
}
public String getNameSpace() {
return rootElem.getChild("namespace").getChildText("name");

View File

@ -69,23 +69,4 @@ public class MetadataDecoderTest {
}
}
@Test
public void testMetadataLinkInfo() throws IOException{
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
String coverageString = FileUtils.readFileToString(coverageFile);
RESTCoverage coverage = RESTCoverage.build(coverageString);
List<GSMetadataLinkInfoEncoder> list = coverage.getEncodedMetadataLinkInfoList();
GSMetadataLinkInfoEncoder metadataLinkInfo1 = list.get(0);
Assert.assertEquals("text/xml", metadataLinkInfo1.getType());
Assert.assertEquals("ISO19115:2003", metadataLinkInfo1.getMetadataType());
Assert.assertEquals("http://www.organization.org/metadata1", metadataLinkInfo1.getContent());
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
Assert.assertEquals("text/html",metadataLinkInfo2.getType());
Assert.assertEquals("ISO19115:2003",metadataLinkInfo2.getMetadataType());
Assert.assertEquals("http://www.organization.org/metadata2",metadataLinkInfo2.getContent());
}
}

View File

@ -0,0 +1,120 @@
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
/**
* ResourceDecoderTest
*
* @author eblondel
*
*/
public class ResourceDecoderTest {
RESTCoverage coverage;
@Before
public void setup() throws IOException {
File coverageFile = new ClassPathResource(
"testdata/coverageExample.xml").getFile();
String coverageString = FileUtils.readFileToString(coverageFile);
coverage = RESTCoverage.build(coverageString);
}
@Test
public void testName() {
Assert.assertEquals(coverage.getName(), "granuleTestMosaic");
}
@Test
public void testNativeName() {
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
}
@Test
public void testTitle() {
Assert.assertEquals(coverage.getNativeName(), "granuleTestMosaic");
}
@Test
public void testAbstract() {
Assert.assertEquals(coverage.getAbstract(), "this is an abstract");
}
@Test
public void testKeywords() {
List<String> keywords = coverage.getKeywords();
Assert.assertEquals(keywords.get(0), "keyword1");
Assert.assertEquals(keywords.get(1), "keyword2");
Assert.assertEquals(keywords.get(2), "keyword3");
}
@Test
public void testNameSpace() {
Assert.assertEquals(coverage.getNameSpace(), "topp");
}
@Test
public void testStoreName() {
Assert.assertEquals(coverage.getStoreName(), "granuleTestMosaic");
}
@Test
public void testStoreType() {
Assert.assertEquals(coverage.getStoreType(), "coverageStore");
}
@Test
public void testStoreUrl() {
Assert.assertEquals(
coverage.getStoreUrl(),
"http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml");
}
@Test
public void testCRS() {
Assert.assertEquals(coverage.getCRS(), "EPSG:4326");
}
@Test
public void testBoundingBox() {
Assert.assertEquals(coverage.getMinX(), -180.0, 0);
Assert.assertEquals(coverage.getMaxX(), 180.0, 0);
Assert.assertEquals(coverage.getMinY(), -90, 0);
Assert.assertEquals(coverage.getMaxY(), 90, 0);
}
@Test
public void testMetadataLinkInfo() throws IOException {
List<GSMetadataLinkInfoEncoder> list = coverage
.getEncodedMetadataLinkInfoList();
GSMetadataLinkInfoEncoder metadataLinkInfo1 = list.get(0);
Assert.assertEquals("text/xml", metadataLinkInfo1.getType());
Assert.assertEquals("ISO19115:2003",
metadataLinkInfo1.getMetadataType());
Assert.assertEquals("http://www.organization.org/metadata1",
metadataLinkInfo1.getContent());
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
Assert.assertEquals("text/html", metadataLinkInfo2.getType());
Assert.assertEquals("ISO19115:2003",
metadataLinkInfo2.getMetadataType());
Assert.assertEquals("http://www.organization.org/metadata2",
metadataLinkInfo2.getContent());
}
}

View File

@ -2,11 +2,17 @@
<coverage>
<name>granuleTestMosaic</name>
<nativeName>granuleTestMosaic</nativeName>
<abstract>this is an abstract</abstract>
<namespace>
<name>topp</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/namespaces/topp.xml" type="application/xml"/>
</namespace>
<title>granuleTestMosaic</title>
<keywords>
<string>keyword1</string>
<string>keyword2</string>
<string>keyword3</string>
</keywords>
<metadataLinks>
<metadataLink>
<type>text/xml</type>