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

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

fix failed soapui plan

parent 12c8aa5b
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,11 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
......@@ -23,8 +23,7 @@ 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;
import static org.junit.Assert.*;
/**
* Created by migueti on 20/01/2017.
......@@ -35,7 +34,7 @@ public class BdxSmpOasisValidatorTest {
private static final String UTF_8 = "UTF-8";
@Test
@Parameters({"ServiceMetadata_OK.xml","ServiceGroup_OK.xml"})
@Parameters({"ServiceMetadata_OK.xml", "ServiceGroup_OK.xml"})
public void testValidatePositive(String xmlFilename) throws IOException, XmlInvalidAgainstSchemaException {
// given
byte[] xmlBody = loadXMLFileAsByteArray(xmlFilename);
......@@ -48,12 +47,12 @@ public class BdxSmpOasisValidatorTest {
}
private static Object[] negativeCases() {
return new Object[][] {
{"ServiceMetadata_ElementAdded.xml", "cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\":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."}
return new Object[][]{
{"ServiceMetadata_ElementAdded.xml", "cvc-complex-type.2.4.a: Invalid content was found starting with element \\'\\{?(\\\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\\\")?:?ElementAdded\\}?\\'.*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."}
};
}
......@@ -68,14 +67,14 @@ public class BdxSmpOasisValidatorTest {
BdxSmpOasisValidator.validateXSD(xmlBody);
} catch (XmlInvalidAgainstSchemaException e) {
// then
assertEquals(output, e.getMessage());
assertThat(e.getMessage(), org.hamcrest.Matchers.matchesPattern(output));
return;
}
fail();
}
public String loadXMLFile(String path) throws IOException {
URL fileUrl = BdxSmpOasisValidatorTest.class.getResource("/XMLValidation/"+path);
URL fileUrl = BdxSmpOasisValidatorTest.class.getResource("/XMLValidation/" + path);
return IOUtils.toString(fileUrl.openStream(), UTF_8);
}
......
......@@ -98,6 +98,7 @@
<jackson.version>2.13.2</jackson.version>
<jackson-databind.version>2.13.2.2</jackson-databind.version>
<jackson.annotations.version>2.13.2</jackson.annotations.version>
<hamcrest.version>2.0.0.0</hamcrest.version>
<!-- jacoco, sonar code coverage settings start -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.jacoco.reportPath>${maven.multiModuleProjectDirectory}/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
......@@ -558,6 +559,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
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