Search in sources :

Example 36 with UrlResponse

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

the class GenericSecureIntegrationTest method testGetHiAfterFilter.

@Test
public void testGetHiAfterFilter() throws Exception {
    UrlResponse response = testUtil.doMethodSecure("GET", "/hi", null);
    Assert.assertTrue(response.headers.get("after").contains("foobar"));
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 37 with UrlResponse

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

the class GenericSecureIntegrationTest method testUnauthorized.

@Test
public void testUnauthorized() throws Exception {
    UrlResponse urlResponse = testUtil.doMethodSecure("GET", "/protected/resource", null);
    Assert.assertTrue(urlResponse.status == 401);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 38 with UrlResponse

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

the class GenericSecureIntegrationTest 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, true, "text/html", headers);
    Assert.assertEquals(xForwardedFor, response.body);
    response = testUtil.doMethod("GET", "/ip", null, true, "text/html", null);
    Assert.assertNotEquals(xForwardedFor, response.body);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 39 with UrlResponse

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

the class ServletTest method testUnauthorized.

@Test
public void testUnauthorized() throws Exception {
    UrlResponse urlResponse = testUtil.doMethod("GET", SOMEPATH + "/protected/resource", null);
    Assert.assertTrue(urlResponse.status == 401);
}
Also used : UrlResponse(spark.util.SparkTestUtil.UrlResponse) Test(org.junit.Test)

Example 40 with UrlResponse

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

the class ServletTest method testEchoParam1.

@Test
public void testEchoParam1() throws Exception {
    UrlResponse response = testUtil.doMethod("GET", SOMEPATH + "/shizzy", null);
    Assert.assertEquals(200, response.status);
    Assert.assertEquals("echo: shizzy", 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