1 package groovy.servlet; 2 3 import javax.servlet.ServletConfig ; 4 import javax.servlet.ServletContext ; 5 import javax.servlet.http.HttpServletRequest ; 6 7 import org.jmock.Mock; 8 import org.jmock.MockObjectTestCase; 9 10 public class GroovyServletTest extends MockObjectTestCase { 11 12 private ServletConfig config; 13 private ServletContext context; 14 private GroovyServlet servlet; 15 16 protected void setUp() throws Exception { 17 super.setUp(); 18 this.servlet = new GroovyServlet(); 21 } 23 24 protected void tearDown() throws Exception { 25 super.tearDown(); 26 } 27 28 public void testRequestGetCommandOK() { 29 Mock requestMock = mock(HttpServletRequest .class); 30 requestMock.expects(once()).method("getParameter").with(eq("command")).will(returnValue("SELECT...")); 31 HttpServletRequest request = (HttpServletRequest ) requestMock.proxy(); 32 String command = request.getParameter("command"); 33 assertEquals("SELECT...", command); 34 } 35 36 50 } 51 | Popular Tags |