Search in sources :

Example 31 with UrlResponse

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

the class GenericIntegrationTest method testEchoParam3.

@Test
public void testEchoParam3() throws Exception {
    String polyglot = "жξ Ä 聊";
    String encoded = URIUtil.encodePath(polyglot);
    UrlResponse response = testUtil.doMethod("GET", "/param/" + encoded, null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("echo: " + polyglot, response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 32 with UrlResponse

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

the class GenericIntegrationTest method testSplatWithEncodedSlash.

@Test
public void testSplatWithEncodedSlash() throws Exception {
    String param = "fo/shizzle";
    String encodedParam = URLEncoder.encode(param, "UTF-8");
    String splat = "mah/FRIEND";
    String encodedSplat = URLEncoder.encode(splat, "UTF-8");
    UrlResponse response = testUtil.doMethod("GET", "/paramandwild/" + encodedParam + "/stuff/" + encodedSplat, null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("paramandwild: " + param + splat, response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 33 with UrlResponse

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

the class GenericIntegrationTest method testGetByteBufferHi.

@Test
public void testGetByteBufferHi() {
    try {
        UrlResponse response = testUtil.doMethod("GET", "/bytebufferhi", null);
        Assert.assertEquals(200, response.status);
        Assert.assertEquals("Hello World!", response.body);
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 34 with UrlResponse

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

the class GenericIntegrationTest method testPostViaGetWithMethodOverrideHeader.

@Test
public void testPostViaGetWithMethodOverrideHeader() throws IOException {
    Map<String, String> map = new HashMap<>();
    map.put("X-HTTP-Method-Override", "POST");
    UrlResponse response = testUtil.doMethod("GET", "/post_via_get", "Fo shizzy", false, "*/*", map);
    System.out.println(response.body);
    Assert.assertEquals(201, response.status);
    Assert.assertTrue(response.body.contains("Method Override Worked"));
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 35 with UrlResponse

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

the class GenericIntegrationTest method testGetBinaryHi.

@Test
public void testGetBinaryHi() {
    try {
        UrlResponse response = testUtil.doMethod("GET", "/binaryhi", null);
        Assert.assertEquals(200, response.status);
        Assert.assertEquals("Hello World!", response.body);
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
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