1 20 package org.apache.cactus.sample.servlet.unit; 21 22 import org.apache.cactus.ServletTestCase; 23 import org.apache.cactus.WebRequest; 24 import org.apache.cactus.WebResponse; 25 26 32 public class TestGlobalBeginEnd extends ServletTestCase 33 { 34 37 private boolean isClientGlobalEndCalled; 38 39 44 protected void runTest() throws Throwable 45 { 46 super.runTest(); 47 48 if (this.request == null) 52 { 53 if (!this.isClientGlobalEndCalled) 54 { 55 fail("end() has not been called"); 56 } 57 } 58 } 59 60 68 public void begin(WebRequest theRequest) 69 { 70 theRequest.addParameter("param1", "value1"); 71 } 72 73 80 public void end(WebResponse theResponse) 81 { 82 assertEquals("Hello there!", theResponse.getText()); 83 this.isClientGlobalEndCalled = true; 84 } 85 86 88 96 public void beginGlobalBeginEnd(WebRequest theRequest) 97 { 98 assertEquals("value1", theRequest.getParameterGet("param1")); 99 } 100 101 108 public void testGlobalBeginEnd() throws Exception 109 { 110 assertEquals("value1", request.getParameter("param1")); 111 response.getWriter().print("Hello there!"); 112 } 113 114 121 public void endGlobalBeginEnd(WebResponse theResponse) 122 { 123 assertEquals("Hello there!", theResponse.getText()); 124 } 125 126 } 127 | Popular Tags |