Commit 1cc2db6d authored by Marcus Sen's avatar Marcus Sen Committed by Jody Garnett
Browse files

[GEOS-7143] Add option to disable INSPIRE capabilities

parent a36373d3
......@@ -6,8 +6,11 @@
package org.geoserver.inspire;
public enum InspireMetadata {
LANGUAGE("inspire.language"), SERVICE_METADATA_URL("inspire.metadataURL"), SERVICE_METADATA_TYPE(
"inspire.metadataURLType"), SPATIAL_DATASET_IDENTIFIER_TYPE("inspire.spatialDatasetIdentifier");
CREATE_EXTENDED_CAPABILITIES("inspire.createExtendedCapabilities"),
LANGUAGE("inspire.language"),
SERVICE_METADATA_URL("inspire.metadataURL"),
SERVICE_METADATA_TYPE("inspire.metadataURLType"),
SPATIAL_DATASET_IDENTIFIER_TYPE("inspire.spatialDatasetIdentifier");
public String key;
......
<html xmlns:wicket="http://wicket.apache.org/">
<head></head>
<body>
<wicket:panel>
<ul>
<li>
<fieldset>
<legend><span><wicket:message key="inspire">INSPIRE</wicket:message></span></legend>
<ul>
<li>
<label for="language"><wicket:message key="language">Language</wicket:message></label>
<select wicket:id="language"></select>
</li>
<li>
<label for="metadataURL"><wicket:message key="metadataURL">Metadata URL</wicket:message></label>
<input type="text" wicket:id="metadataURL" size="50 "></input>
</li>
<li>
<label for="metadataURLType"><wicket:message key="metadataURLType">metadataURLType</wicket:message></label>
<select wicket:id="metadataURLType"></select>
</li>
<li wicket:id="datasetIdentifiersContainer">
<label for="spatialDatasetIdentifiers"><wicket:message key="spatialDatasetIdentifiers">spatialDatasetIdentifiers</wicket:message></label>
<div wicket:id="spatialDatasetIdentifiers"></div>
<li>
<input id="createExtendedCapabilities" class="field checkbox" type="checkbox" wicket:id="createExtendedCapabilities" />
<label class="choice">
<wicket:message key="createExtendedCapabilities">Create INSPIRE ExtendedCapabilities element</wicket:message>
</label>
</li>
<li wicket:id="container">
<div wicket:id="configs">
<ul>
<li>
<label for="language"><wicket:message key="language">Language</wicket:message></label>
<select wicket:id="language"></select>
</li>
<li>
<span wicket:id="border">
<label for="metadataURL"><wicket:message key="metadataURL">Metadata URL</wicket:message></label>
<input type="text" wicket:id="metadataURL" size="50 "></input>
</span>
</li>
<li>
<label for="metadataURLType"><wicket:message key="metadataURLType">metadataURLType</wicket:message></label>
<select wicket:id="metadataURLType"></select>
</li>
<li wicket:id="datasetIdentifiersContainer">
<label for="spatialDatasetIdentifiers"><wicket:message key="spatialDatasetIdentifiers">spatialDatasetIdentifiers</wicket:message></label>
<div wicket:id="spatialDatasetIdentifiers"></div>
</li>
</ul>
</div>
</li>
</ul>
</fieldset>
......@@ -30,4 +43,4 @@
</ul>
</wicket:panel>
</body>
</html>
\ No newline at end of file
</html>
......@@ -5,6 +5,7 @@
*/
package org.geoserver.inspire.web;
import static org.geoserver.inspire.InspireMetadata.CREATE_EXTENDED_CAPABILITIES;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_TYPE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_URL;
......@@ -16,10 +17,14 @@ import java.util.List;
import java.util.Map;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.ResourceModel;
......@@ -32,24 +37,76 @@ import org.geoserver.web.util.MetadataMapModel;
import org.geoserver.wfs.WFSInfo;
/**
* Panel for the service admin page to set the service INSPIRE extension preferences.
* Panel for the service admin page to set the service INSPIRE extension
* preferences.
*/
public class InspireAdminPanel extends AdminPagePanel {
private static final long serialVersionUID = -7670555379263411393L;
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
public InspireAdminPanel(final String id, final IModel<ServiceInfo> model) {
super(id, model);
MetadataMap serviceMetadata = model.getObject().getMetadata();
String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key);
String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key);
String language = (String) serviceMetadata.get(LANGUAGE.key);
boolean isWfs = model.getObject() instanceof WFSInfo;
UniqueResourceIdentifiers ids = null;
if (isWfs) {
ids = (UniqueResourceIdentifiers) serviceMetadata.get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
}
if (!serviceMetadata.containsKey(CREATE_EXTENDED_CAPABILITIES.key)) {
if (metadataURL == null
|| isWfs
&& (ids == null || ids.isEmpty())) {
serviceMetadata.put(CREATE_EXTENDED_CAPABILITIES.key, false);
} else {
serviceMetadata.put(CREATE_EXTENDED_CAPABILITIES.key, true);
}
}
PropertyModel<MetadataMap> metadata = new PropertyModel<MetadataMap>(model, "metadata");
add(new LanguageDropDownChoice("language", new MapModel(metadata, LANGUAGE.key)));
final CheckBox createInspireExtendedCapabilities
= new CheckBox("createExtendedCapabilities",
new MetadataMapModel(metadata, CREATE_EXTENDED_CAPABILITIES.key, Boolean.class));
add(createInspireExtendedCapabilities);
final WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
add(container);
final WebMarkupContainer configs = new WebMarkupContainer("configs");
configs.setOutputMarkupId(true);
configs.setVisible(createInspireExtendedCapabilities.getModelObject());
container.add(configs);
createInspireExtendedCapabilities.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
configs.setVisible(createInspireExtendedCapabilities.getModelObject());
target.addComponent(container);
}
});
TextField textField = new TextField("metadataURL", new MapModel(metadata,
if (!model.getObject().getMetadata().containsKey(LANGUAGE.key)) {
model.getObject().getMetadata().put(LANGUAGE.key, "eng");
}
configs.add(new LanguageDropDownChoice("language", new MapModel(metadata, LANGUAGE.key)));
TextField metadataUrlField = new TextField("metadataURL", new MapModel(metadata,
SERVICE_METADATA_URL.key));
add(textField);
textField.add(new AttributeModifier("title", true, new ResourceModel(
metadataUrlField.setRequired(true);
FormComponentFeedbackBorder metadataURLBorder = new FormComponentFeedbackBorder(
"border");
metadataURLBorder.add(metadataUrlField);
configs.add(metadataURLBorder);
metadataUrlField.add(new AttributeModifier("title", true, new ResourceModel(
"InspireAdminPanel.metadataURL.title")));
final Map<String, String> mdUrlTypes = new HashMap<String, String>();
......@@ -65,7 +122,7 @@ public class InspireAdminPanel extends AdminPagePanel {
@Override
public Object getDisplayValue(final String key) {
final String resourceKey = "InspireAdminPanel.metadataURLType." + key;// as found in
// GeoServerApplication.properties
// GeoServerApplication.properties
final String defaultValue = key;
final String displayValue = new ResourceModel(resourceKey, defaultValue)
.getObject();
......@@ -80,15 +137,15 @@ public class InspireAdminPanel extends AdminPagePanel {
List<String> urlTypeChoices = new ArrayList<String>(mdUrlTypes.keySet());
DropDownChoice<String> serviceMetadataRecordType = new DropDownChoice<String>(
"metadataURLType", urlTypeModel, urlTypeChoices, urlTypeChoiceRenderer);
serviceMetadataRecordType.setNullValid(true);
configs.add(serviceMetadataRecordType);
add(serviceMetadataRecordType);
// this is WFS specific, will appear only if the service is WFS
WebMarkupContainer identifiersContainer = new WebMarkupContainer(
"datasetIdentifiersContainer");
boolean isWfs = model.getObject() instanceof WFSInfo;
identifiersContainer.setVisible(isWfs);
add(identifiersContainer);
configs.add(identifiersContainer);
IModel<UniqueResourceIdentifiers> sdiModel = new MetadataMapModel(metadata, SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
UniqueResourceIdentifiersEditor identifiersEditor = new UniqueResourceIdentifiersEditor(
"spatialDatasetIdentifiers", sdiModel);
......
......@@ -5,9 +5,10 @@
*/
package org.geoserver.inspire.wfs;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireMetadata.CREATE_EXTENDED_CAPABILITIES;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_TYPE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_URL;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireMetadata.SPATIAL_DATASET_IDENTIFIER_TYPE;
import static org.geoserver.inspire.InspireSchema.COMMON_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.DLS_NAMESPACE;
......@@ -25,6 +26,7 @@ import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.NamespaceSupport;
import java.io.IOException;
import org.geoserver.catalog.MetadataMap;
public class WFSExtendedCapabilitiesProvider implements
org.geoserver.wfs.WFSExtendedCapabilitiesProvider {
......@@ -50,15 +52,19 @@ public class WFSExtendedCapabilitiesProvider implements
if ("1.0.0".equals(version)) {
return;
}
String metadataURL = (String) wfs.getMetadata().get(SERVICE_METADATA_URL.key);
String mediaType = (String) wfs.getMetadata().get(SERVICE_METADATA_TYPE.key);
String language = (String) wfs.getMetadata().get(LANGUAGE.key);
UniqueResourceIdentifiers ids = (UniqueResourceIdentifiers) wfs.getMetadata().get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
MetadataMap serviceMetadata = wfs.getMetadata();
Boolean createExtendedCapabilities = (Boolean) serviceMetadata.get(CREATE_EXTENDED_CAPABILITIES.key);
String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key);
String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key);
String language = (String) serviceMetadata.get(LANGUAGE.key);
UniqueResourceIdentifiers ids = (UniqueResourceIdentifiers) serviceMetadata.get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
//Don't create extended capabilities element if mandatory content not present
if (metadataURL == null) {
return;
}
if (ids == null || ids.isEmpty()) {
//or turned off
if (metadataURL == null
|| ids == null
|| ids.isEmpty()
|| createExtendedCapabilities != null
&& !createExtendedCapabilities) {
return;
}
......
......@@ -5,9 +5,10 @@
*/
package org.geoserver.inspire.wms;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireMetadata.CREATE_EXTENDED_CAPABILITIES;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_TYPE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_URL;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireSchema.COMMON_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.VS_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.VS_SCHEMA;
......@@ -18,6 +19,7 @@ import java.util.List;
import java.util.Set;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.MetadataMap;
import org.geoserver.wms.ExtendedCapabilitiesProvider;
import org.geoserver.wms.GetCapabilitiesRequest;
import org.geoserver.wms.WMS;
......@@ -70,13 +72,18 @@ public class WMSExtendedCapabilitiesProvider implements ExtendedCapabilitiesProv
if (!WMS.VERSION_1_3_0.equals(requestVersion)) {
return;
}
String metadataURL = (String) wms.getMetadata().get(SERVICE_METADATA_URL.key);
String mediaType = (String) wms.getMetadata().get(SERVICE_METADATA_TYPE.key);
String language = (String) wms.getMetadata().get(LANGUAGE.key);
MetadataMap serviceMetadata = wms.getMetadata();
Boolean createExtendedCapabilities = (Boolean) serviceMetadata.get(CREATE_EXTENDED_CAPABILITIES.key);
String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key);
//Don't create extended capabilities element if mandatory content not present
if (metadataURL == null) {
//or turned off
if (metadataURL == null
|| createExtendedCapabilities != null
&& !createExtendedCapabilities) {
return;
}
String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key);
String language = (String) serviceMetadata.get(LANGUAGE.key);
// IGN : INSPIRE SCENARIO 1
tx.start("inspire_vs:ExtendedCapabilities");
......
......@@ -7,6 +7,7 @@ InspireAdminPanel.metadataURLType=Service Metadata Type
InspireAdminPanel.metadataURLType.application/vnd.ogc.csw.GetRecordByIdResponse_xml=CSW GetRecord by ID request
InspireAdminPanel.metadataURLType.application/vnd.iso.19139+xml=Online ISO 19139 ServiceMetadata document
InspireAdminPanel.spatialDatasetIdentifiers=Spatial Dataset Identifiers
InspireAdminPanel.createExtendedCapabilities=Create INSPIRE ExtendedCapabilities element
UniqueResourceIdentifiersEditor.noIdentifiersSoFar=No identifiers so far
UniqueResourceIdentifiersEditor.th.code=Code
......@@ -15,4 +16,4 @@ UniqueResourceIdentifiersEditor.th.metadataURL=Metadata URL
UniqueResourceIdentifiersEditor.th.remove=
UniqueResourceIdentifiersEditor.addIdentifier=Add identifier
UniqueResourceIdentifiersEditor.remove=Remove
UniqueResourceIdentifiersEditor.noSpatialDatasetIdentifiers=The INSPIRE download service requires at least one identifier
\ No newline at end of file
UniqueResourceIdentifiersEditor.noSpatialDatasetIdentifiers=The INSPIRE download service requires at least one identifier
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.inspire;
import java.util.HashMap;
import java.util.Map;
import org.geoserver.catalog.MetadataMap;
import org.geoserver.config.ServiceInfo;
import static org.geoserver.inspire.InspireSchema.COMMON_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.DLS_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class InspireTestSupport {
public static void clearInspireMetadata(MetadataMap metadata) {
for (InspireMetadata item : InspireMetadata.values()) {
metadata.remove(item.key);
}
}
public static void assertSchemaLocationContains(String schemaLocation, String namespace, String url) {
assertTrue(schemaLocation.contains(namespace));
String[] schemaLocationParts = schemaLocation.split("\\s+");
for (int i = 0; i < schemaLocationParts.length; i++) {
if (schemaLocationParts[i].equals(namespace)) {
assertTrue(schemaLocationParts[i + 1].equals(url));
}
}
}
public static void assertInspireCommonScenario1Response(final Element extendedCapabilities,
final String metadataUrl, final String mediaType, final String language) {
NodeList nodeList = extendedCapabilities.getElementsByTagNameNS(COMMON_NAMESPACE, "MetadataUrl");
assertEquals("Number of MetadataUrl elements", 1, nodeList.getLength());
final Element mdUrl = (Element) nodeList.item(0);
assertInspireMetadataUrlResponse(mdUrl, metadataUrl, mediaType);
nodeList = extendedCapabilities.getElementsByTagNameNS(COMMON_NAMESPACE, "SupportedLanguages");
assertEquals("Number of SupportedLanguages elements", 1, nodeList.getLength());
final Element suppLangs = (Element) nodeList.item(0);
nodeList = suppLangs.getElementsByTagNameNS(COMMON_NAMESPACE, "DefaultLanguage");
assertEquals("Number of DefaultLanguage elements", 1, nodeList.getLength());
final Element defLang = (Element) nodeList.item(0);
nodeList = defLang.getElementsByTagNameNS(COMMON_NAMESPACE, "Language");
assertEquals("Number of DefaultLanguage/Language elements", 1, nodeList.getLength());
final Element defLangVal = (Element) nodeList.item(0);
assertEquals("DefaultLanguage/Language", language, defLangVal.getFirstChild().getNodeValue());
nodeList = extendedCapabilities.getElementsByTagNameNS(COMMON_NAMESPACE, "ResponseLanguage");
assertEquals("Number of ResponseLanguage elements", 1, nodeList.getLength());
final Element respLang = (Element) nodeList.item(0);
nodeList = respLang.getElementsByTagNameNS(COMMON_NAMESPACE, "Language");
assertEquals("Number of ResponseLanguage/Language elements", 1, nodeList.getLength());
final Element respLangVal = (Element) nodeList.item(0);
assertEquals("ResponseLanguage/Language", language, respLangVal.getFirstChild().getNodeValue());
}
public static void assertInspireMetadataUrlResponse(final Element mdUrl,
final String metadataUrl, final String mediaType) {
NodeList nodeList = mdUrl.getElementsByTagNameNS(COMMON_NAMESPACE, "URL");
assertEquals("Number of URL elements", 1, nodeList.getLength());
final Element url = (Element) nodeList.item(0);
assertEquals("MetadataUrl/URL", metadataUrl, url.getFirstChild().getNodeValue());
nodeList = mdUrl.getElementsByTagNameNS(COMMON_NAMESPACE, "MediaType");
if (mediaType == null) {
assertEquals("Number of MediaType elements", 0, nodeList.getLength());
} else {
assertEquals("Number of MediaType elements", 1, nodeList.getLength());
assertEquals("MediaType", mediaType, ((Element) nodeList.item(0)).getFirstChild().getNodeValue());
}
}
public static void assertInspireDownloadSpatialDataSetIdentifierResponse(
final Element extendedCapabilities, final UniqueResourceIdentifiers ids) {
final NodeList spatialDataSetIdentifiers = extendedCapabilities.getElementsByTagNameNS(DLS_NAMESPACE, "SpatialDataSetIdentifier");
assertEquals("Number of SpatialDataSetIdentifer elements", ids.size(), spatialDataSetIdentifiers.getLength());
final Map<String, UniqueResourceIdentifier> idMap = new HashMap<String, UniqueResourceIdentifier>();
for (UniqueResourceIdentifier id : ids) {
idMap.put(id.getCode(), id);
}
for (int i = 0; i < spatialDataSetIdentifiers.getLength(); i++) {
Element sdi = (Element) spatialDataSetIdentifiers.item(i);
NodeList nodeList = sdi.getElementsByTagNameNS(COMMON_NAMESPACE, "Code");
assertEquals("Number of Code elements", 1, nodeList.getLength());
String code = ((Element) nodeList.item(0)).getFirstChild().getNodeValue();
assertTrue("Should be an identifier with code " + code, idMap.containsKey(code));
nodeList = sdi.getElementsByTagNameNS(COMMON_NAMESPACE, "Namespace");
String expectedNamespace = idMap.get(code).getNamespace();
if (expectedNamespace == null) {
assertEquals("Number of Namespace elements for identifier with code " + code,
0, nodeList.getLength());
} else {
assertEquals("Number of Namespace elements for identifier with code " + code,
1, nodeList.getLength());
String actualNamespace = ((Element) nodeList.item(0)).getFirstChild().getNodeValue();
assertEquals("Namespace for identifier with code " + code,
expectedNamespace, actualNamespace);
}
String expectedMetadataUrl = idMap.get(code).getMetadataURL();
String actualMetadataUrl = sdi.getAttribute("metadataURL");
if (expectedMetadataUrl == null) {
expectedMetadataUrl = "";
}
assertEquals("metadataURL attribute for identifer with code" + code,
expectedMetadataUrl, actualMetadataUrl);
}
}
}
......@@ -4,12 +4,8 @@
*/
package org.geoserver.inspire.web;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNull;
import java.io.Serializable;
import java.util.List;
import org.apache.wicket.Component;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.markup.html.form.Form;
......@@ -22,6 +18,9 @@ import org.geoserver.web.FormTestPage;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.web.wicket.ParamResourceModel;
import org.geotools.util.Converters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
......
......@@ -5,17 +5,22 @@
*/
package org.geoserver.inspire.wms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.geoserver.inspire.InspireMetadata;
import org.geoserver.catalog.MetadataMap;
import org.geoserver.config.ServiceInfo;
import static org.geoserver.inspire.InspireMetadata.CREATE_EXTENDED_CAPABILITIES;
import static org.geoserver.inspire.InspireMetadata.LANGUAGE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_TYPE;
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_URL;
import static org.geoserver.inspire.InspireSchema.COMMON_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.VS_NAMESPACE;
import static org.geoserver.inspire.InspireSchema.VS_SCHEMA;
import static org.geoserver.inspire.InspireTestSupport.assertInspireCommonScenario1Response;
import static org.geoserver.inspire.InspireTestSupport.assertInspireMetadataUrlResponse;
import static org.geoserver.inspire.InspireTestSupport.assertSchemaLocationContains;
import static org.geoserver.inspire.InspireTestSupport.clearInspireMetadata;
import org.geoserver.test.GeoServerSystemTestSupport;
import org.geoserver.wms.WMSInfo;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
......@@ -26,144 +31,180 @@ public class WMSExtendedCapabilitiesTest extends GeoServerSystemTestSupport {
private static final String WMS_1_1_1_GETCAPREQUEST = "wms?request=GetCapabilities&service=WMS&version=1.1.1";
private static final String WMS_1_3_0_GETCAPREQUEST = "wms?request=GetCapabilities&service=WMS&version=1.3.0";
@Before
public void clearMetadata() {
WMSInfo wfs = getGeoServer().getService(WMSInfo.class);
wfs.getMetadata().clear();
getGeoServer().save(wfs);
@Test
public void testNoInspireSettings() throws Exception {
final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class);
final MetadataMap metadata = serviceInfo.getMetadata();
clearInspireMetadata(metadata);
getGeoServer().save(serviceInfo);
final Document dom = getAsDOM(WMS_1_3_0_GETCAPREQUEST);
final NodeList nodeList = dom.getElementsByTagNameNS(VS_NAMESPACE, "ExtendedCapabilities");
assertEquals("Number of INSPIRE ExtendedCapabilities elements", 0, nodeList.getLength());
}
@Test
public void testNoInspireElementWhenNoMetadata() throws Exception {
public void testCreateExtCapsOff() throws Exception {
final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class);
final MetadataMap metadata = serviceInfo.getMetadata();
clearInspireMetadata(metadata);
metadata.put(CREATE_EXTENDED_CAPABILITIES.key, false);
metadata.put(SERVICE_METADATA_URL.key, "http://foo.com?bar=baz");
metadata.put(SERVICE_METADATA_TYPE.key, "application/vnd.iso.19139+xml");
metadata.put(LANGUAGE.key, "fre");
getGeoServer().save(serviceInfo);
final Document dom = getAsDOM(WMS_1_3_0_GETCAPREQUEST);
final NodeList nodeList = dom.getElementsByTagNameNS(VS_NAMESPACE, "ExtendedCapabilities");
assertEquals(0, nodeList.getLength());
assertEquals("Number of INSPIRE ExtendedCapabilities elements", 0, nodeList.getLength());
}
@Test
public void testNoInspireElementWhenNoMetadataUrl() throws Exception {
WMSInfo wms = getGeoServer().getService(WMSInfo.class);
wms.getMetadata().put(InspireMetadata.LANGUAGE.key, "fre");
getGeoServer().save(wms);
public void testExtCaps130WithFullSettings() throws Exception {
final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class);