Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit f56822e2 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

eDelivery 'OASIS' SMP 3.0 initial commit - Previous history is in CIPA-EDELIVERY-legacy repository

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 1287 additions and 0 deletions
common/cipa-commons-busdox/target/
common/cipa-edelivery-common/target/classes/eu/europa/ec/cipa/common/business/AbstractBusinessImpl.class
common/cipa-edelivery-common/target/classes/eu/europa/ec/cipa/common/exception/BusinessException.class
common/cipa-edelivery-common/target/classes/eu/europa/ec/cipa/common/logging/ILogEvent.class
common/cipa-edelivery-common/target/classes/eu/europa/ec/cipa/common/logging/impl/AbstractLoggerImpl.class
common/cipa-edelivery-common/target/classes/eu/europa/ec/cipa/common/logging/impl/LoggingServiceImpl.class
common/cipa-edelivery-common/target/
common/cipa-peppol-types/target/
sml/cipa-sml-client-library/target/
sml/cipa-sml-server-library/target/
sml/cipa-sml-webapp/target/
smp/.idea/libraries/Maven__com_sun_jersey_jersey_client_1_17_1.xml
smp/.idea/libraries/
smp/cipa-smp-client-library/target/
smp/cipa-smp-full-webapp/target/
smp/cipa-smp-readonly-webapp/target/
smp/cipa-smp-server-library/target/
smp/.idea/
smp-api/target/
smp-api/.idea/copyright/profiles_settings.xml
smp-api/.idea/libraries/Maven__junit_junit_4_12.xml
smp-api/.idea/libraries/
smp-api/.idea/
*.iml
addons/cipa-sml-util/.idea/
addons/cipa-sml-util/target/
addons/cipa-sml-migration/target/test-classes/global-truststore.jks
addons/cipa-sml-migration/target/classes/
addons/cipa-sml-migration/target/
addons/cipa-sml-migration/.idea/
File added
# Service Metadata Publishing
## Continous Integration
[https://webgate.ec.europa.eu/CITnet/bamboo/browse/EDELIVERY-SMPDEV]
## Building SMP
SMP requires Maven 3.0 and Java 1.7.
Integration tests included into build process require access to DB. By default it is a local instance of MySQL with preconfigured schema:
[https://ec.europa.eu/cefdigital/code/projects/EDELIVERY/repos/smp/browse/smp-server-library/database]
Any remote DB with preconfigured schema might be used as well. Sample build command:
mvn clean install \
-Djdbc.driver=oracle.jdbc.OracleDriver \
-Djdbc.url=jdbc:oracle:thin:<HOST_AND_PORT_AND_SERVICENAME> \
-Djdbc.user=<USERNAME> \
-Djdbc.password=<PASSWORD> \
-Dtarget-database=Oracle \
-Djdbc.read-connections.max=10
## Source code history
This is a continuation of CIPA SMP Joinup repository, which was migrated here to GIT on 07.12.2016:
[https://joinup.ec.europa.eu/svn/cipaedelivery/trunk]
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017 European Commission | CEF eDelivery
~
~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~
~ You may obtain a copy of the Licence at:
~ https://joinup.ec.europa.eu/software/page/eupl
~ or file: LICENCE-EUPL-v1.1.pdf
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the Licence for the specific language governing permissions and limitations under the Licence.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.europa.ec</groupId>
<artifactId>smp</artifactId>
<packaging>pom</packaging>
<name>SMP Builder POM</name>
<version>3.0.0-SNAPSHOT</version>
<modules>
<module>smp-parent-pom</module>
<module>smp-api</module>
<module>smp-server-library</module>
<module>smp-webapp</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017 European Commission | CEF eDelivery
~
~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~
~ You may obtain a copy of the Licence at:
~ https://joinup.ec.europa.eu/software/page/eupl
~ or file: LICENCE-EUPL-v1.1.pdf
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the Licence for the specific language governing permissions and limitations under the Licence.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.europa.ec.cipa</groupId>
<artifactId>smp-parent-pom</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../smp-parent-pom/pom.xml</relativePath>
</parent>
<artifactId>smp-api</artifactId>
<name>smp-api</name>
<dependencies>
<!-- Generated equals() methods need it in runtime -->
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf.xjc-utils/cxf-xjc-runtime -->
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>cxf-xjc-runtime</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xvalue-constructor</arg><!-- generates value constructors -->
<arg>-Xequals</arg><!-- generates equals() metods -->
</args>
<plugins>
<!-- generates value constructors -->
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-value-constructor</artifactId>
<version>3.0</version>
</plugin>
<!-- generates equals() methods -->
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.11.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2017 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* or file: LICENCE-EUPL-v1.1.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.smp.api;
import eu.europa.ec.smp.api.exceptions.MalformedIdentifierException;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.DocumentIdentifier;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ParticipantIdentifierType;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ProcessIdentifier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Factory and utility methods for API classes generated from OASIS XSD.
*
* Created by gutowpa on 12/01/2017.
*/
public class Identifiers {
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^(?<scheme>.+?)::(?<value>.+)$");
public static ParticipantIdentifierType asParticipantId(String doubleColonDelimitedId) {
String scheme = extract(doubleColonDelimitedId, "scheme");
String value = extract(doubleColonDelimitedId, "value");
return new ParticipantIdentifierType(value, scheme);
}
public static DocumentIdentifier asDocumentId(String doubleColonDelimitedId) {
String scheme = extract(doubleColonDelimitedId, "scheme");
String value = extract(doubleColonDelimitedId, "value");
return new DocumentIdentifier(value, scheme);
}
public static ProcessIdentifier asProcessId(String doubleColonDelimitedId) {
String scheme = extract(doubleColonDelimitedId, "scheme");
String value = extract(doubleColonDelimitedId, "value");
return new ProcessIdentifier(value, scheme);
}
private static String extract(String doubleColonDelimitedId, String groupName) {
try {
Matcher m = IDENTIFIER_PATTERN.matcher(doubleColonDelimitedId);
m.matches();
return m.group(groupName);
}catch(Exception e){
throw new MalformedIdentifierException(doubleColonDelimitedId, e);
}
}
}
/*
* Copyright 2017 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* or file: LICENCE-EUPL-v1.1.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.smp.api.exceptions;
/**
* Thrown when used identifier does not fulfill requirements specified in OASIS SMP specs:
* http://docs.oasis-open.org/bdxr/bdx-smp/v1.0/bdx-smp-v1.0.html
*
* Created by gutowpa on 12/01/2017.
*/
public class MalformedIdentifierException extends IllegalArgumentException {
private static String buildMessage(String malformedId){
return "Malformed identifier, scheme and id should be delimited by double colon: "+malformedId;
}
public MalformedIdentifierException(String malformedId, Exception cause){
super(buildMessage(malformedId), cause);
}
}
/*
* Copyright 2017 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* or file: LICENCE-EUPL-v1.1.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.smp.api.exceptions;
/**
* Created by migueti on 19/01/2017.
*/
public class XmlInvalidAgainstSchemaException extends Exception {
public XmlInvalidAgainstSchemaException(String message, Exception e) {
super(message, e);
}
}
/*
* Copyright 2017 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* or file: LICENCE-EUPL-v1.1.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.smp.api.validators;
import eu.europa.ec.smp.api.exceptions.XmlInvalidAgainstSchemaException;
import org.xml.sax.SAXException;
import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
/**
* Created by migueti on 19/01/2017.
*/
public class BdxSmpOasisValidator {
private static final Validator validator;
static {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL xsdFilePath = BdxSmpOasisValidator.class.getResource("/bdx-smp-201605.xsd");
try {
Schema schema = schemaFactory.newSchema(xsdFilePath);
validator = schema.newValidator();
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
} catch (SAXException e) {
throw new RuntimeException("Unable to initialize BDX SMP OASIS XSD schema validator.", e);
}
}
public static void validateXSD(String xmlBody) throws XmlInvalidAgainstSchemaException {
try {
validator.validate(new StreamSource(new StringReader(xmlBody)));
} catch (SAXException | IOException e) {
throw new XmlInvalidAgainstSchemaException(e.getMessage(), e);
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Service Metadata Publishing (SMP) Version 1.0
Committee Specification 03
30 June 2016
Copyright (c) OASIS Open 2016. All Rights Reserved.
Source: http://docs.oasis-open.org/bdxr/bdx-smp/v1.0/cs03/schemas/
Latest version of the specification: http://docs.oasis-open.org/bdxr/bdx-smp/v1.0/bdx-smp-v1.0.html
TC IPR Statement: https://www.oasis-open.org/committees/bdxr/ipr.php
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified" targetNamespace="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05" id="ServiceMetadataPublishing">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
<xs:element name="ServiceGroup" type="ServiceGroupType"/>
<xs:element name="ServiceMetadata" type="ServiceMetadataType"/>
<xs:element name="SignedServiceMetadata" type="SignedServiceMetadataType"/>
<xs:complexType name="SignedServiceMetadataType">
<xs:sequence>
<xs:element ref="ServiceMetadata"/>
<xs:element ref="ds:Signature"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceMetadataType">
<xs:choice>
<xs:element name="ServiceInformation" type="ServiceInformationType"/>
<xs:element name="Redirect" type="RedirectType"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="ServiceInformationType">
<xs:sequence>
<xs:element ref="ParticipantIdentifier"/>
<xs:element ref="DocumentIdentifier"/>
<xs:element name="ProcessList" type="ProcessListType"/>
<xs:element name="Extension" type="ExtensionType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProcessListType">
<xs:sequence>
<xs:element name="Process" type="ProcessType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProcessType">
<xs:sequence>
<xs:element ref="ProcessIdentifier"/>
<xs:element name="ServiceEndpointList" type="ServiceEndpointList"/>
<xs:element name="Extension" type="ExtensionType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceEndpointList">
<xs:sequence>
<xs:element name="Endpoint" type="EndpointType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EndpointType">
<xs:sequence>
<xs:element name="EndpointURI" type="xs:anyURI"/>
<xs:element name="RequireBusinessLevelSignature" type="xs:boolean" minOccurs="0" default="false"/>
<xs:element name="MinimumAuthenticationLevel" type="xs:string" minOccurs="0"/>
<xs:element name="ServiceActivationDate" type="xs:dateTime" minOccurs="0"/>
<xs:element name="ServiceExpirationDate" type="xs:dateTime" minOccurs="0"/>
<xs:element name="Certificate" type="xs:base64Binary"/>
<xs:element name="ServiceDescription" type="xs:string"/>
<xs:element name="TechnicalContactUrl" type="xs:anyURI"/>
<xs:element name="TechnicalInformationUrl" type="xs:anyURI" minOccurs="0"/>
<xs:element name="Extension" type="ExtensionType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="transportProfile" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="ServiceGroupType">
<xs:sequence>
<xs:element ref="ParticipantIdentifier"/>
<xs:element name="ServiceMetadataReferenceCollection" type="ServiceMetadataReferenceCollectionType"/>
<xs:element name="Extension" type="ExtensionType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceMetadataReferenceCollectionType">
<xs:sequence>
<xs:element name="ServiceMetadataReference" type="ServiceMetadataReferenceType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceMetadataReferenceType">
<xs:attribute name="href" type="xs:anyURI"/>
</xs:complexType>
<xs:complexType name="RedirectType">
<xs:sequence>
<xs:element name="CertificateUID" type="xs:string"/>
<xs:element name="Extension" type="ExtensionType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="href" type="xs:anyURI" use="required"/>
</xs:complexType>
<xs:element name="ParticipantIdentifier" type="ParticipantIdentifierType"/>
<xs:element name="DocumentIdentifier" type="DocumentIdentifierType"/>
<xs:element name="ProcessIdentifier" type="ProcessIdentifierType"/>
<xs:element name="RecipientIdentifier" type="ParticipantIdentifierType"/>
<xs:element name="SenderIdentifier" type="ParticipantIdentifierType"/>
<xs:complexType name="ParticipantIdentifierType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="scheme" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="DocumentIdentifierType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="scheme" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ProcessIdentifierType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="scheme" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ExtensionType">
<xs:annotation>
<xs:documentation>
A single extension for private use.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionID" type="xs:token">
<xs:annotation>
<xs:documentation>
An identifier for the Extension assigned by the creator of the extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionName" type="xs:string">
<xs:annotation>
<xs:documentation>
A name for the Extension assigned by the creator of the extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionAgencyID" type="xs:string">
<xs:annotation>
<xs:documentation>
An agency that maintains one or more Extensions.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionAgencyName" type="xs:string">
<xs:annotation>
<xs:documentation>
The name of the agency that maintains the Extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionAgencyURI" type="xs:anyURI">
<xs:annotation>
<xs:documentation>
A URI for the Agency that maintains the Extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionVersionID" type="xs:normalizedString">
<xs:annotation>
<xs:documentation>
The version of the Extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionURI" type="xs:anyURI">
<xs:annotation>
<xs:documentation>
A URI for the Extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionReasonCode" type="xs:token">
<xs:annotation>
<xs:documentation>
A code for reason the Extension is being included.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="ExtensionReason" type="xs:string">
<xs:annotation>
<xs:documentation>
A description of the reason for the Extension.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright 2017 European Commission | CEF eDelivery
~
~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~
~ You may obtain a copy of the Licence at:
~ https://joinup.ec.europa.eu/software/page/eupl
~ or file: LICENCE-EUPL-v1.1.pdf
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the Licence for the specific language governing permissions and limitations under the Licence.
-->
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xjc:simple />
<jaxb:javaType
name="java.util.Date"
xmlType="xs:dateTime"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime"
/>
<jaxb:javaType
name="java.util.Date"
xmlType="xs:date"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate"
/>
</jaxb:globalBindings>
</jaxb:bindings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017 European Commission | CEF eDelivery
~
~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~
~ You may obtain a copy of the Licence at:
~ https://joinup.ec.europa.eu/software/page/eupl
~ or file: LICENCE-EUPL-v1.1.pdf
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the Licence for the specific language governing permissions and limitations under the Licence.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ec:services:SMP:1.0" targetNamespace="ec:services:SMP:1.0"
elementFormDefault="qualified" id="ServiceMetadataPublishing">
<xs:element name="ErrorResponse" type="ErrorResponseType"/>
<xs:complexType name="ErrorResponseType">
<xs:sequence>
<xs:element name="BusinessCode" type="xs:string"/>
<xs:element name="ErrorDescription" type="xs:string" minOccurs="0"/>
<xs:element name="ErrorUniqueId" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017 European Commission | CEF eDelivery
~
~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~
~ You may obtain a copy of the Licence at:
~ https://joinup.ec.europa.eu/software/page/eupl
~ or file: LICENCE-EUPL-v1.1.pdf
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the Licence for the specific language governing permissions and limitations under the Licence.
-->
<!--
This file specifies the custom output package for the default one:
"org.w3._2001.xmlschema" -> "org.w3._2001.xmlschema.custom"
There was a collision issue between generated class-names and other dependencies (genarated classes names are Adapter1.java Adapter2.java, ...)
Solution described here:
https://jaxb.java.net/guide/Customizing_Java_packages.html#Tip__get_rid_of_the_org_w3__2001_xmlschema_package
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0">
<annotation><appinfo>
<jaxb:schemaBindings>
<jaxb:package name="org.w3._2001.xmlschema.custom"/>
</jaxb:schemaBindings>
</appinfo></annotation>
</schema>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd" [
<!ATTLIST schema
xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
<!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
<!ENTITY % p ''>
<!ENTITY % s ''>
]>
-->
<!-- Schema for XML Signatures
http://www.w3.org/2000/09/xmldsig#
$Revision: 1.1 $ on $Date: 2002/02/08 20:32:26 $ by $Author: reagle $
Copyright 2001 The Internet Society and W3C (Massachusetts Institute
of Technology, Institut National de Recherche en Informatique et en
Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
This document is governed by the W3C Software License [1] as described
in the FAQ [2].
[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1" elementFormDefault="qualified">
<!-- Basic Types Defined for Signatures -->
<simpleType name="CryptoBinary">
<restriction base="base64Binary">
</restriction>
</simpleType>
<!-- Start Signature -->
<element name="Signature" type="ds:SignatureType"/>
<complexType name="SignatureType">
<sequence>
<element ref="ds:SignedInfo"/>
<element ref="ds:SignatureValue"/>
<element ref="ds:KeyInfo" minOccurs="0"/>
<element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureValue" type="ds:SignatureValueType"/>
<complexType name="SignatureValueType">
<simpleContent>
<extension base="base64Binary">
<attribute name="Id" type="ID" use="optional"/>
</extension>
</simpleContent>
</complexType>
<!-- Start SignedInfo -->
<element name="SignedInfo" type="ds:SignedInfoType"/>
<complexType name="SignedInfoType">
<sequence>
<element ref="ds:CanonicalizationMethod"/>
<element ref="ds:SignatureMethod"/>
<element ref="ds:Reference" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
<complexType name="CanonicalizationMethodType" mixed="true">
<sequence>
<any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) namespace -->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<element name="SignatureMethod" type="ds:SignatureMethodType"/>
<complexType name="SignatureMethodType" mixed="true">
<sequence>
<element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace -->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<!-- Start Reference -->
<element name="Reference" type="ds:ReferenceType"/>
<complexType name="ReferenceType">
<sequence>
<element ref="ds:Transforms" minOccurs="0"/>
<element ref="ds:DigestMethod"/>
<element ref="ds:DigestValue"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
<attribute name="URI" type="anyURI" use="optional"/>
<attribute name="Type" type="anyURI" use="optional"/>
</complexType>
<element name="Transforms" type="ds:TransformsType"/>
<complexType name="TransformsType">
<sequence>
<element ref="ds:Transform" maxOccurs="unbounded"/>
</sequence>
</complexType>
<element name="Transform" type="ds:TransformType"/>
<complexType name="TransformType" mixed="true">
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
<element name="XPath" type="string"/>
</choice>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<!-- End Reference -->
<element name="DigestMethod" type="ds:DigestMethodType"/>
<complexType name="DigestMethodType" mixed="true">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<element name="DigestValue" type="ds:DigestValueType"/>
<simpleType name="DigestValueType">
<restriction base="base64Binary"/>
</simpleType>
<!-- End SignedInfo -->
<!-- Start KeyInfo -->
<element name="KeyInfo" type="ds:KeyInfoType"/>
<complexType name="KeyInfoType" mixed="true">
<choice maxOccurs="unbounded">
<element ref="ds:KeyName"/>
<element ref="ds:KeyValue"/>
<element ref="ds:RetrievalMethod"/>
<element ref="ds:X509Data"/>
<element ref="ds:PGPData"/>
<element ref="ds:SPKIData"/>
<element ref="ds:MgmtData"/>
<any processContents="lax" namespace="##other"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</choice>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="KeyName" type="string"/>
<element name="MgmtData" type="string"/>
<element name="KeyValue" type="ds:KeyValueType"/>
<complexType name="KeyValueType" mixed="true">
<choice>
<element ref="ds:DSAKeyValue"/>
<element ref="ds:RSAKeyValue"/>
<any namespace="##other" processContents="lax"/>
</choice>
</complexType>
<element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
<complexType name="RetrievalMethodType">
<sequence>
<element ref="ds:Transforms" minOccurs="0"/>
</sequence>
<attribute name="URI" type="anyURI"/>
<attribute name="Type" type="anyURI" use="optional"/>
</complexType>
<!-- Start X509Data -->
<element name="X509Data" type="ds:X509DataType"/>
<complexType name="X509DataType">
<sequence maxOccurs="unbounded">
<choice>
<element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
<element name="X509SKI" type="base64Binary"/>
<element name="X509SubjectName" type="string"/>
<element name="X509Certificate" type="base64Binary"/>
<element name="X509CRL" type="base64Binary"/>
<any namespace="##other" processContents="lax"/>
</choice>
</sequence>
</complexType>
<complexType name="X509IssuerSerialType">
<sequence>
<element name="X509IssuerName" type="string"/>
<element name="X509SerialNumber" type="integer"/>
</sequence>
</complexType>
<!-- End X509Data -->
<!-- Begin PGPData -->
<element name="PGPData" type="ds:PGPDataType"/>
<complexType name="PGPDataType">
<choice>
<sequence>
<element name="PGPKeyID" type="base64Binary"/>
<element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<sequence>
<element name="PGPKeyPacket" type="base64Binary"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</choice>
</complexType>
<!-- End PGPData -->
<!-- Begin SPKIData -->
<element name="SPKIData" type="ds:SPKIDataType"/>
<complexType name="SPKIDataType">
<sequence maxOccurs="unbounded">
<element name="SPKISexp" type="base64Binary"/>
<any namespace="##other" processContents="lax" minOccurs="0"/>
</sequence>
</complexType>
<!-- End SPKIData -->
<!-- End KeyInfo -->
<!-- Start Object (Manifest, SignatureProperty) -->
<element name="Object" type="ds:ObjectType"/>
<complexType name="ObjectType" mixed="true">
<sequence minOccurs="0" maxOccurs="unbounded">
<any namespace="##any" processContents="lax"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
<attribute name="MimeType" type="string" use="optional"/> <!-- add a grep facet -->
<attribute name="Encoding" type="anyURI" use="optional"/>
</complexType>
<element name="Manifest" type="ds:ManifestType"/>
<complexType name="ManifestType">
<sequence>
<element ref="ds:Reference" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
<complexType name="SignaturePropertiesType">
<sequence>
<element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureProperty" type="ds:SignaturePropertyType"/>
<complexType name="SignaturePropertyType" mixed="true">
<choice maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (1,unbounded) namespaces -->
</choice>
<attribute name="Target" type="anyURI" use="required"/>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<!-- End Object (Manifest, SignatureProperty) -->
<!-- Start Algorithm Parameters -->
<simpleType name="HMACOutputLengthType">
<restriction base="integer"/>
</simpleType>
<!-- Start KeyValue Element-types -->
<element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
<complexType name="DSAKeyValueType">
<sequence>
<sequence minOccurs="0">
<element name="P" type="ds:CryptoBinary"/>
<element name="Q" type="ds:CryptoBinary"/>
</sequence>
<element name="G" type="ds:CryptoBinary" minOccurs="0"/>
<element name="Y" type="ds:CryptoBinary"/>
<element name="J" type="ds:CryptoBinary" minOccurs="0"/>
<sequence minOccurs="0">
<element name="Seed" type="ds:CryptoBinary"/>
<element name="PgenCounter" type="ds:CryptoBinary"/>
</sequence>
</sequence>
</complexType>
<element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
<complexType name="RSAKeyValueType">
<sequence>
<element name="Modulus" type="ds:CryptoBinary"/>
<element name="Exponent" type="ds:CryptoBinary"/>
</sequence>
</complexType>
<!-- End KeyValue Element-types -->
<!-- End Signature -->
</schema>
\ No newline at end of file
package eu.europa.ec.smp.api;
import org.junit.Test;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.DocumentIdentifier;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ParticipantIdentifierType;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ProcessIdentifier;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ServiceGroup;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.InputStream;
import static org.junit.Assert.*;
/**
* Created by gutowpa on 17/01/2017.
*/
public class GeneratedCodeTest {
private static final String SCHEME = "The sample Identifier Scheme";
private static final String VALUE = "The sample Identifier Value";
@Test
public void testValueConstructorWasGeneratedForParticipantId() {
//when
ParticipantIdentifierType id = new ParticipantIdentifierType(VALUE, SCHEME);
//then
assertEquals(SCHEME, id.getScheme());
assertEquals(VALUE, id.getValue());
}
@Test
public void testValueConstructorWasGeneratedForDocumentId() {
//when
DocumentIdentifier id = new DocumentIdentifier(VALUE, SCHEME);
//then
assertEquals(SCHEME, id.getScheme());
assertEquals(VALUE, id.getValue());
}
@Test
public void testValueConstructorWasGeneratedForProcessId() {
//when
ProcessIdentifier id = new ProcessIdentifier(VALUE, SCHEME);
//then
assertEquals(SCHEME, id.getScheme());
assertEquals(VALUE, id.getValue());
}
@Test
public void testGeneratedEqualsIsNotAwareOfWhitespaceAndCommentChanges() throws JAXBException {
//given
ServiceGroup serviceGroupA = loadServiceGroup("/ServiceGroupA.xml");
ServiceGroup serviceGroupB = loadServiceGroup("/ServiceGroupB.xml");
//when-then
assertTrue(serviceGroupA.equals(serviceGroupB));
}
@Test
public void testGeneratedEqualsIsAwareOfContentChanges() throws JAXBException {
//given
ServiceGroup serviceGroupA = loadServiceGroup("/ServiceGroupA.xml");
ServiceGroup serviceGroupC = loadServiceGroup("/ServiceGroupC.xml");
//when-then
assertFalse(serviceGroupA.equals(serviceGroupC));
}
public static ServiceGroup loadServiceGroup(String path) throws JAXBException {
InputStream inputStream = IdentifiersTest.class.getResourceAsStream(path);
JAXBContext jaxbContext = JAXBContext.newInstance(ServiceGroup.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Object serviceGroup = unmarshaller.unmarshal(inputStream);
return (ServiceGroup) serviceGroup;
}
}
package eu.europa.ec.smp.api;
import eu.europa.ec.smp.api.exceptions.MalformedIdentifierException;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.DocumentIdentifier;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ParticipantIdentifierType;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ProcessIdentifier;
import static org.junit.Assert.*;
/**
* Created by gutowpa on 12/01/2017.
*/
@RunWith(JUnitParamsRunner.class)
public class IdentifiersTest {
public static final String MALFORMED_INPUT_MSG = "Malformed identifier, scheme and id should be delimited by double colon: ";
private static final Object[] testCases() {
return new Object[][]{
{"a::b", "a", "b"},
{"a::b::c", "a", "b::c"},
{"a:b::c", "a:b", "c"},
{"ehealth-actorid-qns::urn:poland:ncpb", "ehealth-actorid-qns", "urn:poland:ncpb"},
{"ehealth-resid-qns::urn::epsos##services:extended:epsos::51", "ehealth-resid-qns", "urn::epsos##services:extended:epsos::51"},
{"iso6523-actorid-upis::0002:gutek", "iso6523-actorid-upis", "0002:gutek"},
{"ehealth-actorid-qns::urn:ehealth:hr:ncpb-idp","ehealth-actorid-qns","urn:ehealth:hr:ncpb-idp"},
{"scheme::urn:ehealth:pt:ncpb-idp","scheme","urn:ehealth:pt:ncpb-idp"},
{"otherscheme::urn:ehealth:be:ncpb-idp","otherscheme","urn:ehealth:be:ncpb-idp"},
{"ehealth-resid-qns::urn:ehealth:IdentityService::XCPD::CrossGatewayPatientDiscovery##ITI-55","ehealth-resid-qns","urn:ehealth:IdentityService::XCPD::CrossGatewayPatientDiscovery##ITI-55"},
{"ehealth-resid-qns::urn:XCPD::CrossGatewayPatientDiscovery","ehealth-resid-qns","urn:XCPD::CrossGatewayPatientDiscovery"},
{"ehealth-resid-qns::urn:ehealth:PatientService::XCA::CrossGatewayQuery##ITI-38","ehealth-resid-qns","urn:ehealth:PatientService::XCA::CrossGatewayQuery##ITI-38"},
{"ehealth-resid-qns::urn:XCA::CrossGatewayQuery","ehealth-resid-qns","urn:XCA::CrossGatewayQuery"},
{"ehealth-resid-qns::urn:ehealth:OrderService::XCA::CrossGatewayQuery##ITI-38","ehealth-resid-qns","urn:ehealth:OrderService::XCA::CrossGatewayQuery##ITI-38"},
{"ehealth-resid-qns::urn:ehealth:DispensationService:Initialize::XDR::ProvideandRegisterDocumentSet-b##ITI-41","ehealth-resid-qns","urn:ehealth:DispensationService:Initialize::XDR::ProvideandRegisterDocumentSet-b##ITI-41"},
{"ehealth-resid-qns::urn:XDR::ProvideandRegisterDocumentSet-b","ehealth-resid-qns","urn:XDR::ProvideandRegisterDocumentSet-b"},
{"ehealth-resid-qns::urn:ehealth:DispensationService:Discard::XDR::ProvideandRegisterDocumentSet-b##ITI-41","ehealth-resid-qns","urn:ehealth:DispensationService:Discard::XDR::ProvideandRegisterDocumentSet-b##ITI-41"},
{"ehealth-resid-qns::urn:ehealth:ConsentService:Put::XDR::BPPCProvideandRegisterDocumentSet-b##ITI-41","ehealth-resid-qns","urn:ehealth:ConsentService:Put::XDR::BPPCProvideandRegisterDocumentSet-b##ITI-41"},
{"ehealth-resid-qns::urn:XDR::BPPCProvideandRegisterDocumentSet-b","ehealth-resid-qns","urn:XDR::BPPCProvideandRegisterDocumentSet-b"},
{"ehealth-resid-qns::urn:ehealth:ConsentService:Discard::XDR::BPPCProvideandRegisterDocumentSet-b##ITI-41","ehealth-resid-qns","urn:ehealth:ConsentService:Discard::XDR::BPPCProvideandRegisterDocumentSet-b##ITI-41"},
{"ehealth-resid-qns::urn:ehealth:IdP::identityProvider::HPAuthentication##epsos-91","ehealth-resid-qns","urn:ehealth:IdP::identityProvider::HPAuthentication##epsos-91"},
{"ehealth-resid-qns::urn:identityProvider::HPAuthentication","ehealth-resid-qns","urn:identityProvider::HPAuthentication"},
{"ehealth-resid-qns::urn:ehealth:IdP::XUA::ProvideX-UserAssertion##ITI-40","ehealth-resid-qns","urn:ehealth:IdP::XUA::ProvideX-UserAssertion##ITI-40"},
{"ehealth-resid-qns::urn:XUA::ProvideX-UserAssertion","ehealth-resid-qns","urn:XUA::ProvideX-UserAssertion"},
{"ehealth-resid-qns::urn:ehealth:VPN::VPNGatewayServer##epsos-105","ehealth-resid-qns","urn:ehealth:VPN::VPNGatewayServer##epsos-105"},
{"ehealth-resid-qns::urn:ehealth:ncp::vpngateway","ehealth-resid-qns","urn:ehealth:ncp::vpngateway"},
{"ehealth-resid-qns::urn:ehealth:VPN::VPNGatewayClient##epsos-106","ehealth-resid-qns","urn:ehealth:VPN::VPNGatewayClient##epsos-106"},
{"ehealth-resid-qns::urn:ehealth:ISM::InternationalSearchMask##epsos-107","ehealth-resid-qns","urn:ehealth:ISM::InternationalSearchMask##epsos-107"},
{"ehealth-resid-qns::urn:ehealth:ncp::pt:ism","ehealth-resid-qns","urn:ehealth:ncp::pt:ism"}
};
}
@Test
@Parameters(method = "testCases")
public void testParticipantIdPositive(String input, String scheme, String value) {
//when
ParticipantIdentifierType participantId = Identifiers.asParticipantId(input);
//then
assertEquals(scheme, participantId.getScheme());
assertEquals(value, participantId.getValue());
}
@Test
@Parameters(method = "testCases")
public void testDocumentIdPositive(String input, String scheme, String value) {
//when
DocumentIdentifier documentId = Identifiers.asDocumentId(input);
//then
assertEquals(scheme, documentId.getScheme());
assertEquals(value, documentId.getValue());
}
@Test
@Parameters(method = "testCases")
public void testProcessIdPositive(String input, String scheme, String value) {
//when
ProcessIdentifier processId = Identifiers.asProcessId(input);
//then
assertEquals(scheme, processId.getScheme());
assertEquals(value, processId.getValue());
}
private static final Object[] negativeCases() {
return new Object[]{
null,
"",
"a",
"abc",
"a:b",
"::a",
"a::",
"ehealth-actorid-qns",
"urn:poland:ncpb",
"ehealth-resid-qns",
"epsos##services:extended:epsos:51"
};
}
@Test
@Parameters(method = "negativeCases")
public void testProcessIdNegative(String negativeInput) {
try {
//when
Identifiers.asProcessId(negativeInput);
} catch (Exception e) {
//then
negativeAssertions(negativeInput, e);
return;
}
fail();
}
@Test
@Parameters(method = "negativeCases")
public void testDocumentIdNegative(String negativeInput) {
try {
//when
Identifiers.asDocumentId(negativeInput);
} catch (Exception e) {
///then
negativeAssertions(negativeInput, e);
return;
}
fail();
}
@Test
@Parameters(method = "negativeCases")
public void testParticipantIdNegative(String negativeInput) {
try {
//when
Identifiers.asParticipantId(negativeInput);
} catch (Exception e) {
//then
negativeAssertions(negativeInput, e);
return;
}
fail();
}
private void negativeAssertions(String negativeInput, Exception e) {
assertTrue(e instanceof MalformedIdentifierException);
assertEquals(MALFORMED_INPUT_MSG + negativeInput, e.getMessage());
}
}
package eu.europa.ec.smp.api.validators;
import eu.europa.ec.smp.api.exceptions.XmlInvalidAgainstSchemaException;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import java.net.URL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* Created by migueti on 20/01/2017.
*/
@RunWith(JUnitParamsRunner.class)
public class BdxSmpOasisValidatorTest {
private static final String UTF_8 = "UTF-8";
@Test
@Parameters({"ServiceMetadata_OK.xml","ServiceGroup_OK.xml"})
public void testValidatePositive(String xmlFilename) throws IOException, XmlInvalidAgainstSchemaException {
// given
String xmlBody = loadXMLFile(xmlFilename);
// when
BdxSmpOasisValidator.validateXSD(xmlBody);
// then
// no exception occur
}
private static Object[] negativeCases() {
return new Object[][] {
{"ServiceMetadata_ElementAdded.xml", "cvc-complex-type.2.4.a: Invalid content was found starting with element 'ElementAdded'. One of '{\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\":ServiceInformation, \"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\":Redirect}' is expected."},
{"ServiceMetadata_ElementMissing.xml", "cvc-complex-type.2.4.b: The content of element 'Redirect' is not complete. One of '{\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\":CertificateUID}' is expected."},
{"ServiceGroup_MissingAssignment.xml", "Attribute name \"missingAssignment\" associated with an element type \"ServiceMetadataReferenceCollection\" must be followed by the ' = ' character."},
{"ServiceGroup_UnexpectedAttribute.xml","cvc-complex-type.3.2.2: Attribute 'unexpectedAttribute' is not allowed to appear in element 'ServiceMetadataReferenceCollection'."},
{"ServiceGroup_externalDTD.xml", "External DTD: Failed to read external DTD 'any_external_file_address.dtd', because 'file' access is not allowed due to restriction set by the accessExternalDTD property."}
};
}
@Test
@Parameters(method = "negativeCases")
public void testValidateNegative(String xmlFilename, String output) throws IOException {
// given
String xmlBody = loadXMLFile(xmlFilename);
// when
try {
BdxSmpOasisValidator.validateXSD(xmlBody);
} catch (XmlInvalidAgainstSchemaException e) {
// then
assertEquals(output, e.getMessage());
return;
}
fail();
}
public String loadXMLFile(String path) throws IOException {
URL fileUrl = BdxSmpOasisValidatorTest.class.getResource("/XMLValidation/"+path);
return IOUtils.toString(fileUrl.openStream(), UTF_8);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ServiceGroup xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">
<ParticipantIdentifier scheme="ehealth-actorid-qns">urn:poland:ncpb</ParticipantIdentifier>
<!-- sample comment -->
<ServiceMetadataReferenceCollection>
<ServiceMetadataReference href="http://smp-digit-mock.publisher.ehealth.acc.edelivery.tech.ec.europa.eu/ehealth-actorid-qns::urn:poland:ncpb/services/epsos-docid-qns%3A%3Aurn%3A%3Aepsos%3Aservices%23%23epsos-21" />
<ServiceMetadataReference href="http://smp-digit-mock.publisher.ehealth.acc.edelivery.tech.ec.europa.eu/ehealth-actorid-qns::urn:poland:ncpb/services/ehealth-resid-qns%3A%3Aurn%3A%3Aepsos%23%23services%3Aextended%3Aepsos%3A%3A107" />
</ServiceMetadataReferenceCollection>
</ServiceGroup>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><ServiceGroup xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05"><ParticipantIdentifier scheme="ehealth-actorid-qns">urn:poland:ncpb</ParticipantIdentifier><ServiceMetadataReferenceCollection><ServiceMetadataReference href="http://smp-digit-mock.publisher.ehealth.acc.edelivery.tech.ec.europa.eu/ehealth-actorid-qns::urn:poland:ncpb/services/epsos-docid-qns%3A%3Aurn%3A%3Aepsos%3Aservices%23%23epsos-21" /><ServiceMetadataReference href="http://smp-digit-mock.publisher.ehealth.acc.edelivery.tech.ec.europa.eu/ehealth-actorid-qns::urn:poland:ncpb/services/ehealth-resid-qns%3A%3Aurn%3A%3Aepsos%23%23services%3Aextended%3Aepsos%3A%3A107" /></ServiceMetadataReferenceCollection></ServiceGroup>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ServiceGroup xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">
<ParticipantIdentifier scheme="ehealth-actorid-qns">urn:poland:ncpb</ParticipantIdentifier>
<!-- sample comment -->
<ServiceMetadataReferenceCollection>
<ServiceMetadataReference href="http://smp-digit-mock.publisher.ehealth.acc.edelivery.tech.ec.europa.eu/ehealth-actorid-qns::urn:poland:ncpb/services/epsos-docid-qns%3A%3Aurn%3A%3Aepsos%3Aservices%23%23epsos-21" />
</ServiceMetadataReferenceCollection>
</ServiceGroup>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment