You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Wessels, H" <H....@t-systems.de> on 2001/11/23 14:25:28 UTC
cactus and velocity?
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cactus and velocity?
Posted by Vincent Massol <vm...@octo.com>.
Holger,
I don't remember seeing anyone else using cactus and velocity on the mailing
list and I don't use velocity myself. Let me still try to help you. I'm not
sure what a velocity servlet is but I imagine it is a standard servlet,
right ? In endXXX, you'll get everything that your servlet write on the
output stream. Your template probably gets applied on the server side and
only the result is sent back to the client (and thus to your endXXX method).
If you'd like to make checks on the server side, you should make them at the
end of your testXXX method. You should be able to get the cookies in the
endXXX method, though.
Is it now working for you ?
Thanks
-Vincent
----- Original Message -----
From: "Wessels, H" <H....@t-systems.de>
To: <ca...@jakarta.apache.org>
Sent: Friday, November 23, 2001 1:25 PM
Subject: cactus and velocity?
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:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>