Search in sources :

Example 56 with UrlResponse

use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.

the class GenericIntegrationTest method assertEchoRoute.

private static void assertEchoRoute(String routePart) throws Exception {
    final String expected = "expected";
    UrlResponse response = testUtil.doMethod("GET", "/tworoutes/" + routePart + "/" + expected, null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals(routePart + " route: " + expected, response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse)

Example 57 with UrlResponse

use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.

the class GenericIntegrationTest method testGetHi.

@Test
public void testGetHi() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", "/hi", null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("Hello World!", response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 58 with UrlResponse

use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.

the class GenericIntegrationTest method filters_should_be_accept_type_aware.

@Test
public void filters_should_be_accept_type_aware() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", "/protected/resource", null, "application/json");
    Assert.assertTrue(response.status == 401);
    Assert.assertEquals("{\"message\": \"Go Away!\"}", response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 59 with UrlResponse

use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.

the class GenericIntegrationTest method testPathParamsWithPlusSign.

@Test
public void testPathParamsWithPlusSign() throws Exception {
    String pathParamWithPlusSign = "not+broken+path+param";
    UrlResponse response = testUtil.doMethod("GET", "/param/" + pathParamWithPlusSign, null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("echo: " + pathParamWithPlusSign, response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 60 with UrlResponse

use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.

the class GenericIntegrationTest method paths_should_be_nestable.

@Test
public void paths_should_be_nestable() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", "/firstPath/secondPath/test", null, "application/json");
    Assert.assertTrue(response.status == 200);
    Assert.assertEquals("Nested path-prefix works", response.body);
    Assert.assertEquals("true", response.headers.get("before-filter-ran"));
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) 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