Search in sources :

Example 26 with UrlResponse

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

the class GenericIntegrationTest method routes_should_be_accept_type_aware.

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

Example 27 with UrlResponse

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

the class GenericIntegrationTest method template_view_should_be_rendered_with_given_model_view_object.

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

Example 28 with UrlResponse

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

the class GenericIntegrationTest method testPost.

@Test
public void testPost() throws Exception {
    UrlResponse response = testUtil.doMethod("POST", "/poster", "Fo shizzy");
    LOGGER.info(response.body);
    Assert.assertEquals(201, response.status);
    Assert.assertTrue(response.body.contains("Fo shizzy"));
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 29 with UrlResponse

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

the class GenericIntegrationTest method path_should_prefix_routes.

@Test
public void path_should_prefix_routes() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", "/firstPath/test", null, "application/json");
    Assert.assertTrue(response.status == 200);
    Assert.assertEquals("Single 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)

Example 30 with UrlResponse

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

the class GenericIntegrationTest method testEchoParam2.

@Test
public void testEchoParam2() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", "/param/gunit", null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("echo: gunit", response.body);
}
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