mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
use random ports;
tests for the Daemon
This commit is contained in:
parent
aca3d2bd04
commit
fcf3ff2bf1
7 changed files with 102 additions and 26 deletions
26
src/test/java/de/kosit/validationtool/daemon/BaseIT.java
Normal file
26
src/test/java/de/kosit/validationtool/daemon/BaseIT.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package de.kosit.validationtool.daemon;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
|
||||
/**
|
||||
* Base for integration tests.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public abstract class BaseIT {
|
||||
|
||||
@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;
|
||||
}
|
||||
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.kosit.validationtool.cmd;
|
||||
package de.kosit.validationtool.daemon;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
|
|
@ -6,13 +6,11 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
|
||||
/**
|
||||
|
|
@ -20,24 +18,13 @@ import io.restassured.http.ContentType;
|
|||
*
|
||||
* @author Roula Antoun
|
||||
*/
|
||||
public class DaemonIT {
|
||||
public class CheckHandlerIT extends BaseIT {
|
||||
|
||||
|
||||
private static final String APPLICATION_XML = "application/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;
|
||||
}
|
||||
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void makeSureThatSuccessTest() throws IOException {
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package de.kosit.validationtool.daemon;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import io.restassured.http.ContentType;
|
||||
|
||||
/**
|
||||
* Integration test for the {@link ConfigHandler}.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class ConfigHandlerIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
public void checkHealth() {
|
||||
given().when().get("/server/config").then().statusCode(200).and().contentType(ContentType.XML);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package de.kosit.validationtool.daemon;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import io.restassured.http.ContentType;
|
||||
|
||||
/**
|
||||
* Checks the health endpoint.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class HealthHandlerIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
public void checkHealth() {
|
||||
given().when().get("/server/health").then().statusCode(200).and().contentType(ContentType.XML);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue