Search in sources :

Example 21 with UrlResponse

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);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 22 with UrlResponse

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);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 23 with UrlResponse

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);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 24 with UrlResponse

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);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 25 with UrlResponse

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);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

UrlResponse (spark.util.SparkTestUtil.UrlResponse)66 Test (org.junit.Test)65 HashMap (java.util.HashMap)3 JWGmeligMeylingException (spark.examples.exception.JWGmeligMeylingException)1