use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericIntegrationTest method testStaticFile.
@Test
public void testStaticFile() throws Exception {
UrlResponse response = testUtil.doMethod("GET", "/css/style.css", null);
Assert.assertEquals(200, response.status);
Assert.assertEquals("Content of css file", response.body);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericIntegrationTest method testRuntimeExceptionForAllRoutesFinally.
@Test
public void testRuntimeExceptionForAllRoutesFinally() throws Exception {
UrlResponse response = testUtil.doMethod("GET", "/hi", null);
Assert.assertEquals("foobar", response.headers.get("after"));
Assert.assertEquals("nice done response after all", response.headers.get("post-process-all"));
Assert.assertEquals(200, response.status);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericIntegrationTest method testPostProcessBodyForFinally.
@Test
public void testPostProcessBodyForFinally() throws Exception {
UrlResponse response = testUtil.doMethod("POST", "/nice", "");
Assert.assertEquals("nice response", response.body);
Assert.assertEquals("nice done response", response.headers.get("post-process"));
Assert.assertEquals(200, response.status);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericIntegrationTest method testNotFound.
@Test
public void testNotFound() throws Exception {
UrlResponse response = testUtil.doMethod("GET", "/no/resource", null);
Assert.assertTrue(response.status == 404);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericIntegrationTest method testXForwardedFor.
@Test
public void testXForwardedFor() throws Exception {
final String xForwardedFor = "XXX.XXX.XXX.XXX";
Map<String, String> headers = new HashMap<>();
headers.put("X-Forwarded-For", xForwardedFor);
UrlResponse response = testUtil.doMethod("GET", "/ip", null, false, "text/html", headers);
Assert.assertEquals(xForwardedFor, response.body);
response = testUtil.doMethod("GET", "/ip", null, false, "text/html", null);
Assert.assertNotEquals(xForwardedFor, response.body);
}
Aggregations