1
2
3
4
5
6 package nl.mineleni.cbsviewer.jsp;
7
8 import static javax.servlet.http.HttpServletResponse.SC_OK;
9 import static nl.mineleni.cbsviewer.util.CookieNamesConstants.COOKIE_baselyr;
10 import static nl.mineleni.cbsviewer.util.CookieNamesConstants.COOKIE_mapid;
11 import static org.hamcrest.Matchers.equalTo;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertThat;
14 import static org.junit.Assert.assertTrue;
15
16 import org.apache.http.Header;
17 import org.apache.http.client.methods.HttpGet;
18 import org.junit.Test;
19
20
21
22
23
24
25 public class IndexJSPIntegrationTest extends JSPIntegrationTest {
26
27
28
29
30
31 @Override
32 @Test
33 public void testIfValidResponse() throws Exception {
34 response = client.execute(new HttpGet(BASE_TEST_URL + "index.jsp"));
35 assertThat("Response status is OK.", response.getStatusLine()
36 .getStatusCode(), equalTo(SC_OK));
37 boilerplateValidationTests(response);
38 }
39
40
41
42
43
44
45 @Test
46 public void testIfCookiesSet() throws Exception {
47 response = client.execute(new HttpGet(BASE_TEST_URL + "index.jsp"));
48
49
50 Header[] headers = response.getHeaders("Set-Cookie");
51
52 int cookiesFound = 0;
53 for (int i = 0; i < headers.length; i++) {
54
55 if (headers[i].getValue().contains(COOKIE_baselyr.value)) {
56 cookiesFound++;
57 assertTrue("base layer cookie is juist ingesteld", headers[i]
58 .getValue().contains("topografie"));
59 }
60 if (headers[i].getValue().contains(COOKIE_mapid.value)) {
61 cookiesFound++;
62 assertTrue(
63 "thema layer cookie is juist ingesteld",
64 headers[i]
65 .getValue()
66 .contains(
67 "gemeenten2012_bevolkingsdichtheid_inwoners_per_km2"));
68 }
69
70 }
71 assertEquals("Aantal gevonden cookies is gelijk aan twee", 2,
72 cookiesFound);
73 }
74 }