You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sa...@usbank.com on 2003/06/03 23:49:44 UTC

HttpUnit question

Hi all,
      I am using HttpUnit to do testing of an tapestry application. The
test case is written something like this..

public class MyHttpUnitTest extends TestCase {

      public static void main(String[] args) {

            junit.textui.TestRunner.run(suite());
      }

      public static TestSuite suite() {
            return new TestSuite(MyHttpUnitTest.class);
      }

      public MyHttpUnitTest(String arg0) {
            super(arg0);

      }

      public void testGetForm() throws Exception {
            ServletRunner sr = new ServletRunner();

.           //get the form on the page

            WebForm srchForm=srcPageResponse.getFormWithName("Form0");

            //modify the visit object with new info
            //submit the form
            //test result

}

I tried using the InvocationContext to get the httpSession.
//getting the request object
WebRequest
srcPageRequest=srchSrcForm.getRequest(srchSrcForm.getSubmitButton("SrcSrchSubmit"));
..getting the context
InvocationContext ic = client.newInvocation( srchPageRequest );
//getting the Httpsession
HttpSession sess=ic.getRequest().getSession(false);

However I get a null sess thought I am sure the Visit object is
instantiated and stored when the page is initially rendered since one of
the page components require it.

How do I access the Visit object in my test case and be able to modify it?


Thanks

Santosh