1   package com.atlassian.core.filters.legacy;
2   
3   import junit.framework.TestCase;
4   import com.atlassian.core.filters.ServletStubs;
5   
6   public class TestNoContentLocationHeaderResponseWrapper extends TestCase
7   {
8       public void testCannotSetHeader() throws Exception
9       {
10          ServletStubs.Response response = ServletStubs.getResponseInstance();
11          NoContentLocationHeaderResponseWrapper wrapper = new NoContentLocationHeaderResponseWrapper(response);
12  
13          wrapper.setHeader("Content-Location", "/test");
14          assertNull("Content-Location should not be set", response.getHeader("Content-Location"));
15  
16          wrapper.setHeader("ConTENT-location", "/test");
17          assertNull("ConTENT-location should not be set", response.getHeader("ConTENT-location"));
18  
19          wrapper.setHeader("Content-Type", "text/html");
20          assertEquals("Other headers work fine", "text/html", response.getHeader("Content-Type"));
21      }
22  
23      public void testCannotAddHeader() throws Exception
24      {
25          ServletStubs.Response response = ServletStubs.getResponseInstance();
26          NoContentLocationHeaderResponseWrapper wrapper = new NoContentLocationHeaderResponseWrapper(response);
27  
28          wrapper.addHeader("Content-Location", "/test");
29          assertNull("Content-Location should not be set", response.getHeader("Content-Location"));
30  
31          wrapper.addHeader("ConTENT-location", "/test");
32          assertNull("Content-location should not be set", response.getHeader("Content-location"));
33  
34          wrapper.addHeader("Content-Type", "text/html");
35          assertEquals("Other headers work fine", "text/html", response.getHeader("Content-Type"));
36      }
37  }