mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
#10 Daemon Mode umsetzen
This commit is contained in:
parent
87a05cb456
commit
d1d3d25f36
35 changed files with 17482 additions and 25 deletions
74
src/test/java/de/kosit/validationtool/cmd/DaemonIT.java
Normal file
74
src/test/java/de/kosit/validationtool/cmd/DaemonIT.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package de.kosit.validationtool.cmd;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
|
||||
/**
|
||||
* Testet the Daemon-Mode input , Methoden , Output Content-Type and the success case
|
||||
*
|
||||
* @author Roula Antoun
|
||||
*/
|
||||
public class DaemonIT {
|
||||
|
||||
private static final String EXAMPLE_FILE = "examples/UBLReady/UBLReady_EU_UBL-NL_20170102_FULL.xml";
|
||||
|
||||
private static final String APPLICATION_XML = "application/xml";
|
||||
|
||||
private static final String INVALID_XML = "examples/UBLReady/UBLReady_EU_UBL-NL_20170102_FULL-invalid.xml";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
final String port = System.getProperty("daemon.port");
|
||||
if (port != null) {
|
||||
RestAssured.port = Integer.valueOf(port);
|
||||
}
|
||||
final String baseHost = System.getProperty("daemon.host");
|
||||
if (baseHost != null) {
|
||||
RestAssured.baseURI = baseHost;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void makeSureThatSuccessTest() throws IOException {
|
||||
try ( InputStream io = DaemonIT.class.getClassLoader().getResourceAsStream(EXAMPLE_FILE) ) {
|
||||
given().contentType(APPLICATION_XML).body(io).when().post("/").then().statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void NoInputTest() {
|
||||
given().body("").contentType(APPLICATION_XML).when().post("/").then().statusCode(400);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void internalServerErrorTest() throws IOException {
|
||||
try ( InputStream io = DaemonIT.class.getClassLoader().getResourceAsStream(INVALID_XML) ) {
|
||||
given().contentType(APPLICATION_XML).body(io).when().post("/").then().statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodNotAllowedTest() {
|
||||
given().when().get("/").then().statusCode(405);
|
||||
given().when().put("/").then().statusCode(405);
|
||||
given().when().patch("/").then().statusCode(405);
|
||||
given().when().delete("/").then().statusCode(405);
|
||||
given().when().head("/").then().statusCode(405);
|
||||
given().when().options("/").then().statusCode(405);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlResultTest() throws IOException {
|
||||
try ( InputStream io = DaemonIT.class.getClassLoader().getResourceAsStream(EXAMPLE_FILE) ) {
|
||||
given().body(io).when().post("/").then().contentType(APPLICATION_XML).and().statusCode(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<xsl:with-param name="parent-id" select="$id"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:variable>
|
||||
<!-- Skip output for implicit validation steps (i. e., wellformedness check) unless there is anything to tell -->
|
||||
<!-- Skip output for implicit validation steps (i. e., wellformedness implemenation) unless there is anything to tell -->
|
||||
<xsl:if test="exists($messages) or exists(s:resource)">
|
||||
<rep:validationStepResult id="{$id}"
|
||||
valid="{if ($messages[@level = ('warning', 'error')]) then false() else true()}">
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
<xsl:variable name="messages" as="element(rep:message)*">
|
||||
<xsl:apply-templates select="in:xmlSyntaxError"/>
|
||||
</xsl:variable>
|
||||
<!-- Skip output for implicit validation steps (i. e., wellformedness check) unless there is anything to tell -->
|
||||
<!-- Skip output for implicit validation steps (i. e., wellformedness implemenation) unless there is anything to tell -->
|
||||
<xsl:if test="exists($messages) or exists(s:resource)">
|
||||
<rep:validationStepResult valid="{if ($messages[@level = ('warning', 'error')]) then false() else true()}">
|
||||
<xsl:apply-templates mode="copy-to-report-ns" select="s:resource"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue