jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wessels, H" <H.Wess...@t-systems.de>
Subject cactus and velocity?
Date Fri, 23 Nov 2001 13:25:28 GMT
Hi,
I want to test my velocityServlets with Cactus. From VelocityServlet's handleRequest I get
a Template, but I can't see a way to get it into the WebResponse for the endXXX function.
I did a workaround for only the page source within testXXX and did my asserts there, but this
gives me no access to cookies etc. I suppose. What is the right way?
Thanks,
Holger (h.wessels@t-systems.de)

---- from testSinglePicture ----
      public void testRequestSinglePicture() {
        SinglePictureServlet picserv = new SinglePictureServlet();
		VelocityContext wtcontext=new VelocityContext();
		Template result=picserv.handleRequest(request, response, wtcontext);
	}

    public void endRequestSinglePicture(WebResponse theResponse) {
	      assertTrue( "Result is empty", "".equals(theResponse.getText()));
	}
}
--------------------------
---- from SinglePicture ----
public final class SinglePictureServlet extends VelocityServlet {

    public Template handleRequest(HttpServletRequest request,
                      HttpServletResponse response, Context wtcontext)
      {
		  Date now = new Date();
		  wtcontext.put("name", now.toString());
		  Template template=null;
		  try {
			  template = getTemplate ("singlepicture.vm");
		  }
		  catch (Exception e) 
		  {
		  System.out.println("error e: "+e.toString());
		  }
		  return template;
    }
}
----------------------------------





Holger We├čels
T-Systems Nova GmbH
Berkom
Experte F&E
Goslarer Ufer 35
D-10589 Berlin
Tel.  +49 (030) 3497 -2266
Fax  +49 (030) 3497 -2267
Email  h.wessels@t-systems.de


--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message