mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
test for gui handler
This commit is contained in:
parent
b02126c1cc
commit
b164d71199
2 changed files with 20 additions and 3 deletions
|
|
@ -29,10 +29,11 @@ abstract class BaseHandler implements HttpHandler {
|
|||
os.close();
|
||||
}
|
||||
|
||||
protected static void error(final HttpExchange httpExchange, final int statusCode, final String message) throws IOException {
|
||||
protected static void error(final HttpExchange exchange, final int statusCode, final String message) throws IOException {
|
||||
final byte[] bytes = message.getBytes();
|
||||
httpExchange.sendResponseHeaders(statusCode, bytes.length);
|
||||
final OutputStream os = httpExchange.getResponseBody();
|
||||
exchange.getResponseHeaders().add("Content-Type", "text/plain");
|
||||
exchange.sendResponseHeaders(statusCode, bytes.length);
|
||||
final OutputStream os = exchange.getResponseBody();
|
||||
os.write(bytes);
|
||||
os.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package de.kosit.validationtool.daemon;
|
||||
|
||||
import io.restassured.http.ContentType;
|
||||
import org.junit.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
public class GuiHandlerIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
public void checkGui() {
|
||||
given().when().get("/").then().statusCode(200).and().contentType(ContentType.HTML);
|
||||
given().when().get("/README.md").then().statusCode(200).and().contentType("text/markdown");
|
||||
given().when().get("/unknown.md").then().statusCode(404).and().contentType(ContentType.TEXT);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue