1 15 package org.apache.tapestry.request; 16 17 import javax.servlet.http.HttpServletRequest ; 18 19 import org.apache.hivemind.test.HiveMindTestCase; 20 import org.easymock.MockControl; 21 22 29 public class TestDecodedRequestWrapper extends HiveMindTestCase 30 { 31 private HttpServletRequest newRequest() 32 { 33 return (HttpServletRequest ) newMock(HttpServletRequest .class); 34 } 35 36 public void testInterceptedMethods() 37 { 38 DecodedRequest dr = new DecodedRequest(); 39 40 dr.setRequestURI("/foo/bar/baz"); 41 dr.setScheme("https"); 42 dr.setServerPort(2170); 43 dr.setServerName("www.flintstone.com"); 44 45 HttpServletRequest request = newRequest(); 46 47 replayControls(); 48 49 DecodedRequestWrapper w = new DecodedRequestWrapper(request, dr); 50 51 assertEquals("/foo/bar/baz", w.getRequestURI()); 52 assertEquals("https", w.getScheme()); 53 assertEquals(2170, w.getServerPort()); 54 assertEquals("www.flintstone.com", w.getServerName()); 55 56 verifyControls(); 57 } 58 59 public void testRequestConstructor() 60 { 61 MockControl control = newControl(HttpServletRequest .class); 62 HttpServletRequest request = (HttpServletRequest ) control.getMock(); 63 64 request.getScheme(); 65 control.setReturnValue("https"); 66 67 request.getServerName(); 68 control.setReturnValue("www.flintstone.com"); 69 70 request.getRequestURI(); 71 control.setReturnValue("/foo/bar/baz"); 72 73 request.getServerPort(); 74 control.setReturnValue(2170); 75 76 replayControls(); 77 78 DecodedRequest dr = new DecodedRequest(request); 79 80 assertEquals("/foo/bar/baz", dr.getRequestURI()); 81 assertEquals("https", dr.getScheme()); 82 assertEquals(2170, dr.getServerPort()); 83 assertEquals("www.flintstone.com", dr.getServerName()); 84 85 verifyControls(); 86 } 87 } | Popular Tags |