#62 fix MetadataLink support - adding tests

This commit is contained in:
eblondel 2013-04-06 14:43:18 +02:00
parent 8adef995c2
commit b388298afb
4 changed files with 484 additions and 387 deletions

View File

@ -1,74 +1,92 @@
/*
* GeoBatch - Open Source geospatial batch processing system
* https://github.com/nfms4redd/nfms-geobatch
* Copyright (C) 2007-2012 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
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.Test;
import org.springframework.core.io.ClassPathResource;
/**
* @author DamianoG
*
*/
public class MetadataDecoderTest {
@Test
public void testMetadataDimensionInfo() throws IOException {
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
String coverageString = FileUtils.readFileToString(coverageFile);
RESTCoverage coverage = RESTCoverage.build(coverageString);
List<RESTDimensionInfo> list = coverage.getDimensionInfo();
Assert.assertEquals(list.size(),2);
for (RESTDimensionInfo el : list){
if(el.getKey().equals("time")){
Assert.assertEquals(el.getResolution(),null);
Assert.assertEquals(el.getPresentation(),"LIST");
Assert.assertEquals(el.getKey(),"time");
Assert.assertEquals(el.isEnabled(),true);
}
if(el.getKey().equals("elevation")){
Assert.assertEquals(el.getResolution(),"2");
Assert.assertEquals(el.getPresentation(),"DISCRETE_INTERVAL");
Assert.assertEquals(el.getKey(),"elevation");
Assert.assertEquals(el.isEnabled(),true);
}
}
}
}
/*
* GeoBatch - Open Source geospatial batch processing system
* https://github.com/nfms4redd/nfms-geobatch
* Copyright (C) 2007-2012 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadatalink.ResourceMetadataLinkInfo;
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.Test;
import org.springframework.core.io.ClassPathResource;
/**
* @author DamianoG
* @author eblondel
*
*/
public class MetadataDecoderTest {
@Test
public void testMetadataDimensionInfo() throws IOException {
File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile();
String coverageString = FileUtils.readFileToString(coverageFile);
RESTCoverage coverage = RESTCoverage.build(coverageString);
List<RESTDimensionInfo> list = coverage.getDimensionInfo();
Assert.assertEquals(list.size(),2);
for (RESTDimensionInfo el : list){
if(el.getKey().equals("time")){
Assert.assertEquals(el.getResolution(),null);
Assert.assertEquals(el.getPresentation(),"LIST");
Assert.assertEquals(el.getKey(),"time");
Assert.assertEquals(el.isEnabled(),true);
}
if(el.getKey().equals("elevation")){
Assert.assertEquals(el.getResolution(),"2");
Assert.assertEquals(el.getPresentation(),"DISCRETE_INTERVAL");
Assert.assertEquals(el.getKey(),"elevation");
Assert.assertEquals(el.isEnabled(),true);
}
}
}
@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(metadataLinkInfo1.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.type),"text/xml");
Assert.assertEquals(metadataLinkInfo1.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.metadataType),"ISO19115:2003");
Assert.assertEquals(metadataLinkInfo1.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.content),"http://www.organization.org/metadata1");
GSMetadataLinkInfoEncoder metadataLinkInfo2 = list.get(1);
Assert.assertEquals(metadataLinkInfo2.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.type),"text/html");
Assert.assertEquals(metadataLinkInfo2.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.metadataType),"ISO19115:2003");
Assert.assertEquals(metadataLinkInfo2.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.content),"http://www.organization.org/metadata2");
}
}

View File

@ -1,217 +1,231 @@
/*
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geoserver.rest.encoder.feature;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTResource;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.PresentationDiscrete;
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
import it.geosolutions.geoserver.rest.publisher.GeoserverRESTPublisherTest;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import org.jdom.Element;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
*
* @author ETj (etj at geo-solutions.it)
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
*/
public class GSFeatureEncoderTest extends GeoserverRESTPublisherTest {
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
@Test
public void testIntegration() throws IOException {
if (!enabled())
return;
deleteAll();
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
String storeName = "resttestshp";
String layerName = "cities";
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
fte.setName(layerName + "_NEW");
fte.setTitle("title");
// fte.addKeyword("TODO");
fte.setNativeCRS("EPSG:4326");
fte.setDescription("desc");
fte.setEnabled(true);
GSLayerEncoder layerEncoder = new GSLayerEncoder();
layerEncoder.setEnabled(true);
layerEncoder.setQueryable(true);
layerEncoder.setDefaultStyle("point");
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 testFeatureTypeEncoder() {
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
encoder.addKeyword("KEYWORD_1");
encoder.addKeyword("KEYWORD_2");
encoder.addKeyword("...");
encoder.addKeyword("KEYWORD_N");
encoder.setName("Layername");
encoder.setTitle("title");
encoder.addKeyword("TODO");
encoder.setNativeCRS("EPSG:4326");
encoder.setDescription("desc");
encoder.setEnabled(true);
GSAttributeEncoder attribute = new GSAttributeEncoder();
attribute.setAttribute(FeatureTypeAttribute.name, "NAME");
attribute.setAttribute(FeatureTypeAttribute.binding, "java.lang.String");
attribute.setAttribute(FeatureTypeAttribute.maxOccurs, "1");
attribute.setAttribute(FeatureTypeAttribute.minOccurs, "0");
attribute.setAttribute(FeatureTypeAttribute.nillable, "true");
encoder.setAttribute(attribute);
encoder.delAttribute("NAME");
attribute.setAttribute(FeatureTypeAttribute.name, "NEW_NAME");
encoder.setAttribute(attribute);
// TODO encoder.getAttribute("NAME");
GSFeatureDimensionInfoEncoder dim2 = new GSFeatureDimensionInfoEncoder("ELE");
encoder.addMetadata("elevation", dim2);
dim2.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL, BigDecimal.valueOf(10));
Element el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.PRESENTATION);
Assert.assertNotNull(el);
LOGGER.info("contains_key:" + el.toString());
dim2.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL, BigDecimal.valueOf(12));
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.RESOLUTION);
Assert.assertNotNull(el);
Assert.assertEquals("12", el.getText());
dim2.setPresentation(Presentation.CONTINUOUS_INTERVAL);
encoder.setMetadata("time", new GSFeatureDimensionInfoEncoder("time"));
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.PRESENTATION);
Assert.assertNotNull(el);
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.RESOLUTION);
Assert.assertNull(el);
el = ElementUtils.contains(encoder.getRoot(), GSResourceEncoder.METADATA);
Assert.assertNotNull(el);
LOGGER.info("contains_key:" + el.toString());
final boolean removed = ElementUtils.remove(encoder.getRoot(), el);
LOGGER.info("remove:" + removed);
Assert.assertTrue(removed);
el = ElementUtils.contains(encoder.getRoot(), "metadata");
Assert.assertNull(el);
if (el == null)
LOGGER.info("REMOVED");
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
assertEquals(encoder.getName(),"Layername");
}
@Test
public void testModifyFeature() {
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
encoder.addKeyword("KEYWORD_1");
encoder.addKeyword("KEYWORD_2");
encoder.addKeyword("...");
encoder.addKeyword("KEYWORD_N");
Assert.assertTrue(encoder.delKeyword("KEYWORD_2"));
Assert.assertFalse(encoder.delKeyword("KEYWORD_M"));
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
"elevation_field");
// if (LOGGER.isInfoEnabled())
// LOGGER.info(encoder.toString());
final String metadata = "elevation";
encoder.setMetadata(metadata, elevationDimension);
elevationDimension.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL,
BigDecimal.valueOf(10));
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
Assert.assertTrue(encoder.delMetadata(metadata));
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
final Element el = ElementUtils.contains(encoder.getRoot(),
GSDimensionInfoEncoder.DIMENSIONINFO);
Assert.assertNull(el);
if (el == null)
LOGGER.info("REMOVED");
}
}
/*
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geoserver.rest.encoder.feature;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTResource;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.PresentationDiscrete;
import it.geosolutions.geoserver.rest.encoder.metadata.GSFeatureDimensionInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.utils.ElementUtils;
import it.geosolutions.geoserver.rest.publisher.GeoserverRESTPublisherTest;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import org.jdom.Element;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
*
* @author ETj (etj at geo-solutions.it)
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
*/
public class GSFeatureEncoderTest extends GeoserverRESTPublisherTest {
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
@Test
public void testIntegration() throws IOException {
if (!enabled())
return;
deleteAll();
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
String storeName = "resttestshp";
String layerName = "cities";
GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder();
fte.setName(layerName + "_NEW");
fte.setTitle("title");
// fte.addKeyword("TODO");
fte.setNativeCRS("EPSG:4326");
fte.setDescription("desc");
fte.setEnabled(true);
//metadataLink
GSMetadataLinkInfoEncoder metadatalink = new GSMetadataLinkInfoEncoder();
metadatalink.setup("text/xml", "ISO19115:2003","http://www.organization.org/metadata1");
fte.addMetadataLinkInfo(metadatalink);
GSLayerEncoder layerEncoder = new GSLayerEncoder();
layerEncoder.setEnabled(true);
layerEncoder.setQueryable(true);
layerEncoder.setDefaultStyle("point");
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 testFeatureTypeEncoder() {
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
encoder.addKeyword("KEYWORD_1");
encoder.addKeyword("KEYWORD_2");
encoder.addKeyword("...");
encoder.addKeyword("KEYWORD_N");
encoder.setName("Layername");
encoder.setTitle("title");
encoder.addKeyword("TODO");
encoder.setNativeCRS("EPSG:4326");
encoder.setDescription("desc");
encoder.setEnabled(true);
GSAttributeEncoder attribute = new GSAttributeEncoder();
attribute.setAttribute(FeatureTypeAttribute.name, "NAME");
attribute.setAttribute(FeatureTypeAttribute.binding, "java.lang.String");
attribute.setAttribute(FeatureTypeAttribute.maxOccurs, "1");
attribute.setAttribute(FeatureTypeAttribute.minOccurs, "0");
attribute.setAttribute(FeatureTypeAttribute.nillable, "true");
encoder.setAttribute(attribute);
encoder.delAttribute("NAME");
attribute.setAttribute(FeatureTypeAttribute.name, "NEW_NAME");
encoder.setAttribute(attribute);
// TODO encoder.getAttribute("NAME");
GSFeatureDimensionInfoEncoder dim2 = new GSFeatureDimensionInfoEncoder("ELE");
encoder.addMetadata("elevation", dim2);
dim2.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL, BigDecimal.valueOf(10));
Element el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.PRESENTATION);
Assert.assertNotNull(el);
LOGGER.info("contains_key:" + el.toString());
dim2.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL, BigDecimal.valueOf(12));
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.RESOLUTION);
Assert.assertNotNull(el);
Assert.assertEquals("12", el.getText());
dim2.setPresentation(Presentation.CONTINUOUS_INTERVAL);
encoder.setMetadata("time", new GSFeatureDimensionInfoEncoder("time"));
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.PRESENTATION);
Assert.assertNotNull(el);
el = ElementUtils.contains(encoder.getRoot(), GSDimensionInfoEncoder.RESOLUTION);
Assert.assertNull(el);
el = ElementUtils.contains(encoder.getRoot(), GSResourceEncoder.METADATA);
Assert.assertNotNull(el);
LOGGER.info("contains_key:" + el.toString());
final boolean removed = ElementUtils.remove(encoder.getRoot(), el);
LOGGER.info("remove:" + removed);
Assert.assertTrue(removed);
el = ElementUtils.contains(encoder.getRoot(), "metadata");
Assert.assertNull(el);
if (el == null)
LOGGER.info("REMOVED");
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
assertEquals(encoder.getName(),"Layername");
}
@Test
public void testModifyFeature() {
GSFeatureTypeEncoder encoder = new GSFeatureTypeEncoder();
encoder.addKeyword("KEYWORD_1");
encoder.addKeyword("KEYWORD_2");
encoder.addKeyword("...");
encoder.addKeyword("KEYWORD_N");
Assert.assertTrue(encoder.delKeyword("KEYWORD_2"));
Assert.assertFalse(encoder.delKeyword("KEYWORD_M"));
//metadataLinkInfo
encoder.addMetadataLinkInfo("text/xml", "ISO19115:2003","http://www.organization.org/metadata1");
encoder.addMetadataLinkInfo("text/html", "ISO19115:2003","http://www.organization.org/metadata2");
Assert.assertTrue(encoder.delMetadataLinkInfo("http://www.organization.org/metadata2"));
Assert.assertFalse(encoder.delMetadataLinkInfo("http://www.organization.org/metadata3"));
//dimensions
final GSFeatureDimensionInfoEncoder elevationDimension = new GSFeatureDimensionInfoEncoder(
"elevation_field");
// if (LOGGER.isInfoEnabled())
// LOGGER.info(encoder.toString());
final String metadata = "elevation";
encoder.setMetadata(metadata, elevationDimension);
elevationDimension.setPresentation(PresentationDiscrete.DISCRETE_INTERVAL,
BigDecimal.valueOf(10));
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
Assert.assertTrue(encoder.delMetadata(metadata));
if (LOGGER.isInfoEnabled())
LOGGER.info(encoder.toString());
final Element el = ElementUtils.contains(encoder.getRoot(),
GSDimensionInfoEncoder.DIMENSIONINFO);
Assert.assertNull(el);
if (el == null)
LOGGER.info("REMOVED");
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2007 - 2011 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geoserver.rest.encoder.metadatalink;
import junit.framework.Assert;
import org.junit.Test;
/**
*
* @author eblondel
*
*/
public class GSMetadataLinkInfoEncoderTest {
@Test
public void metadataLinkInfoTest(){
GSMetadataLinkInfoEncoder encoder = new GSMetadataLinkInfoEncoder();
encoder.setup("text/xml", "ISO19115:2003","http://www.organization.org/metadata1");
Assert.assertEquals("text/xml", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.type));
Assert.assertEquals("ISO19115:2003", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.metadataType));
Assert.assertEquals("http://www.organization.org/metadata1", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.content));
Assert.assertTrue(encoder.delMetadataLinkInfoMember(ResourceMetadataLinkInfo.content));
Assert.assertNull(encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.content));
encoder.setMetadataLinkInfoMember(ResourceMetadataLinkInfo.type, "text/html");
encoder.setMetadataLinkInfoMember(ResourceMetadataLinkInfo.metadataType, "FGDC");
encoder.setMetadataLinkInfoMember(ResourceMetadataLinkInfo.content, "http://www.organization.org/metadata2");
Assert.assertEquals("text/html", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.type));
Assert.assertEquals("FGDC", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.metadataType));
Assert.assertEquals("http://www.organization.org/metadata2", encoder.getMetadataLinkInfoMember(ResourceMetadataLinkInfo.content));
}
}

View File

@ -1,97 +1,109 @@
<coverage>
<name>granuleTestMosaic</name>
<nativeName>granuleTestMosaic</nativeName>
<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>
<nativeCRS>GEOGCS[&quot;WGS 84&quot;, &#xd;
DATUM[&quot;World Geodetic System 1984&quot;, &#xd;
SPHEROID[&quot;WGS 84&quot;, 6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]], &#xd;
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]], &#xd;
PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]], &#xd;
UNIT[&quot;degree&quot;, 0.017453292519943295], &#xd;
AXIS[&quot;Geodetic longitude&quot;, EAST], &#xd;
AXIS[&quot;Geodetic latitude&quot;, NORTH], &#xd;
AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]</nativeCRS>
<srs>EPSG:4326</srs>
<nativeBoundingBox>
<minx>-180.0</minx>
<maxx>180.0</maxx>
<miny>-90.0</miny>
<maxy>90.0</maxy>
<crs>EPSG:4326</crs>
</nativeBoundingBox>
<latLonBoundingBox>
<minx>-180.0</minx>
<maxx>180.0</maxx>
<miny>-90.0</miny>
<maxy>90.0</maxy>
<crs>EPSG:4326</crs>
</latLonBoundingBox>
<projectionPolicy>NONE</projectionPolicy>
<enabled>true</enabled>
<advertised>true</advertised>
<metadata>
<entry key="time">
<dimensionInfo>
<enabled>true</enabled>
<presentation>LIST</presentation>
</dimensionInfo>
</entry>
<entry key="elevation">
<dimensionInfo>
<enabled>true</enabled>
<presentation>DISCRETE_INTERVAL</presentation>
<resolution>2</resolution>
</dimensionInfo>
</entry>
</metadata>
<store class="coverageStore">
<name>granuleTestMosaic</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml" type="application/xml"/>
</store>
<grid dimension="2">
<range>
<low>0 0</low>
<high>540 270</high>
</range>
<transform>
<scaleX>0.6666666666666666</scaleX>
<scaleY>-0.6666666666666666</scaleY>
<shearX>0.0</shearX>
<shearY>0.0</shearY>
<translateX>-179.66666666666666</translateX>
<translateY>89.66666666666667</translateY>
</transform>
<crs>EPSG:4326</crs>
</grid>
<parameters>
<entry>
<string>AllowMultithreading</string>
<string>false</string>
</entry>
<entry>
<string>MaxAllowedTiles</string>
<string>2147483647</string>
</entry>
<entry>
<string>InputTransparentColor</string>
<string></string>
</entry>
<entry>
<string>SUGGESTED_TILE_SIZE</string>
<string>256,256</string>
</entry>
<entry>
<string>USE_JAI_IMAGEREAD</string>
<string>false</string>
</entry>
<entry>
<string>BackgroundValues</string>
<string>-1.0</string>
</entry>
</parameters>
<coverage>
<name>granuleTestMosaic</name>
<nativeName>granuleTestMosaic</nativeName>
<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>
<metadataLinks>
<metadataLink>
<type>text/xml</type>
<metadataType>ISO19115:2003</metadataType>
<content>http://www.organization.org/metadata1</content>
</metadataLink>
<metadataLink>
<type>text/html</type>
<metadataType>ISO19115:2003</metadataType>
<content>http://www.organization.org/metadata2</content>
</metadataLink>
</metadataLinks>
<nativeCRS>GEOGCS[&quot;WGS 84&quot;, &#xd;
DATUM[&quot;World Geodetic System 1984&quot;, &#xd;
SPHEROID[&quot;WGS 84&quot;, 6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]], &#xd;
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]], &#xd;
PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]], &#xd;
UNIT[&quot;degree&quot;, 0.017453292519943295], &#xd;
AXIS[&quot;Geodetic longitude&quot;, EAST], &#xd;
AXIS[&quot;Geodetic latitude&quot;, NORTH], &#xd;
AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]</nativeCRS>
<srs>EPSG:4326</srs>
<nativeBoundingBox>
<minx>-180.0</minx>
<maxx>180.0</maxx>
<miny>-90.0</miny>
<maxy>90.0</maxy>
<crs>EPSG:4326</crs>
</nativeBoundingBox>
<latLonBoundingBox>
<minx>-180.0</minx>
<maxx>180.0</maxx>
<miny>-90.0</miny>
<maxy>90.0</maxy>
<crs>EPSG:4326</crs>
</latLonBoundingBox>
<projectionPolicy>NONE</projectionPolicy>
<enabled>true</enabled>
<advertised>true</advertised>
<metadata>
<entry key="time">
<dimensionInfo>
<enabled>true</enabled>
<presentation>LIST</presentation>
</dimensionInfo>
</entry>
<entry key="elevation">
<dimensionInfo>
<enabled>true</enabled>
<presentation>DISCRETE_INTERVAL</presentation>
<resolution>2</resolution>
</dimensionInfo>
</entry>
</metadata>
<store class="coverageStore">
<name>granuleTestMosaic</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/topp/coveragestores/granuleTestMosaic.xml" type="application/xml"/>
</store>
<grid dimension="2">
<range>
<low>0 0</low>
<high>540 270</high>
</range>
<transform>
<scaleX>0.6666666666666666</scaleX>
<scaleY>-0.6666666666666666</scaleY>
<shearX>0.0</shearX>
<shearY>0.0</shearY>
<translateX>-179.66666666666666</translateX>
<translateY>89.66666666666667</translateY>
</transform>
<crs>EPSG:4326</crs>
</grid>
<parameters>
<entry>
<string>AllowMultithreading</string>
<string>false</string>
</entry>
<entry>
<string>MaxAllowedTiles</string>
<string>2147483647</string>
</entry>
<entry>
<string>InputTransparentColor</string>
<string></string>
</entry>
<entry>
<string>SUGGESTED_TILE_SIZE</string>
<string>256,256</string>
</entry>
<entry>
<string>USE_JAI_IMAGEREAD</string>
<string>false</string>
</entry>
<entry>
<string>BackgroundValues</string>
<string>-1.0</string>
</entry>
</parameters>
</coverage>