use of spark.util.SparkTestUtil in project spark by perwendel.
the class GzipTest method testGet.
/**
* Used to verify that "normal" functionality works after static files mapping
*/
private static void testGet() throws Exception {
SparkTestUtil testUtil = new SparkTestUtil(4567);
SparkTestUtil.UrlResponse response = testUtil.doMethod("GET", "/hello", "");
Assert.assertEquals(200, response.status);
Assert.assertTrue(response.body.contains(GzipExample.FO_SHIZZY));
}
use of spark.util.SparkTestUtil in project spark by perwendel.
the class StaticFilesMemberTest method setup.
@BeforeClass
public static void setup() throws IOException {
testUtil = new SparkTestUtil(4567);
tmpExternalFile = new File(System.getProperty("java.io.tmpdir"), EXTERNAL_FILE_NAME_HTML);
FileWriter writer = new FileWriter(tmpExternalFile);
writer.write(CONTENT_OF_EXTERNAL_FILE);
writer.flush();
writer.close();
staticFiles.location("/public");
staticFiles.externalLocation(System.getProperty("java.io.tmpdir"));
get("/hello", (q, a) -> FO_SHIZZY);
get("/*", (q, a) -> {
throw new NotFoundException();
});
exception(NotFoundException.class, (e, request, response) -> {
response.status(404);
response.body(NOT_FOUND_BRO);
});
Spark.awaitInitialization();
}
use of spark.util.SparkTestUtil in project spark by perwendel.
the class CustomErrorPagesTest method setup.
@BeforeClass
public static void setup() throws IOException {
testUtil = new SparkTestUtil(4567);
get("/hello", (q, a) -> HELLO_WORLD);
get("/raiseinternal", (q, a) -> {
throw new Exception("");
});
notFound(CUSTOM_NOT_FOUND);
internalServerError((request, response) -> {
if (request.queryParams(QUERY_PARAM_KEY) != null) {
throw new Exception();
}
response.type(APPLICATION_JSON);
return CUSTOM_INTERNAL;
});
Spark.awaitInitialization();
}
use of spark.util.SparkTestUtil in project spark by perwendel.
the class ResponseBodyTest method setup.
@BeforeClass
public static void setup() throws IOException {
http = new SparkTestUtil(4567);
get(HELLO, (q, a) -> HELLO_WORLD);
after(HELLO, (q, a) -> {
String body = a.body();
assertEquals(HELLO_WORLD, body);
});
get(SPECIAL, (q, a) -> {
a.body(XIDXUS);
return "";
});
after(SPECIAL, (q, a) -> {
String body = a.body();
assertEquals(XIDXUS, body);
});
get(PORAKATIKAOKAO, (q, a) -> {
a.body(GALLUS_SCANDALUM);
return null;
});
after(PORAKATIKAOKAO, (q, a) -> {
String body = a.body();
assertEquals(GALLUS_SCANDALUM, body);
});
get(MAXIME, (q, a) -> {
a.body(XIDXUS);
return $11AB;
});
after(MAXIME, (q, a) -> {
String body = a.body();
assertEquals($11AB, body);
});
Spark.awaitInitialization();
}
use of spark.util.SparkTestUtil in project spark by perwendel.
the class FilterTest method setup.
@BeforeClass
public static void setup() throws IOException {
testUtil = new SparkTestUtil(4567);
before("/justfilter", (q, a) -> System.out.println("Filter matched"));
awaitInitialization();
}
Aggregations