You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Robert Koberg <ro...@koberg.com> on 2005/05/03 21:07:03 UTC

cactus and velocity

Hi,

I want to use Cactus to test some filters that are mapped to velocity pages.

It is working for the most part. The problem is in the endXXX methods 
and the WebResponse object (both Cactus default and HttpUnit). They 
never return any text -- using webResponse.getText() is always empty. 
The WebResponse object does return the status code as 200 and that the 
response contentType as correct (text/html).

Are there any tricks to get the response to include the velocity 
rendered page?

thanks,
-Rob

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: cactus and velocity

Posted by Shinobu Kawai <sh...@gmail.com>.
> > Are there any tricks to get the response to include the velocity
> > rendered page?
> 
> Can you provide some code snippet that reproduces the problem?

I just tried out Cactus and it worked fine for me.  Other than the
usual web.xml for web applications, I posted my sample test code on
the wiki.
   http://wiki.apache.org/jakarta-velocity/TestingVelocity

Hope that helps.

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: cactus and velocity

Posted by Robert Koberg <ro...@koberg.com>.
Shinobu Kawai wrote:
> Hi Rob,
> 
> 
>>I want to use Cactus to test some filters that are mapped to velocity pages.
>>
>>It is working for the most part. The problem is in the endXXX methods
>>and the WebResponse object (both Cactus default and HttpUnit). They
>>never return any text -- using webResponse.getText() is always empty.
>>The WebResponse object does return the status code as 200 and that the
>>response contentType as correct (text/html).
>>
>>Are there any tricks to get the response to include the velocity
>>rendered page?
> 
> 
> Can you provide some code snippet that reproduces the problem?
> ## A few whiles ago, I think there was a thread about Cactus not
> working on a not-so-well-configured VelocityViewServlet...

Sorry for not following up with this, but I did get it to work. It is 
basically the same as described here:

http://jakarta.apache.org/cactus/writing/howto_jsp.html

That is, use a RequestDispatcher to forward to the .vm page. Here is an 
example for use with cactus:


   public void beginPageExists(WebRequest webRequest) {
     webRequest.setURL("domain.com", "/app", "/path/to/page.vm", null, 
null);
   }

     public void testPageExists() throws IOException, ServletException {
     RequestDispatcher rd = 
config.getServletContext().getRequestDispatcher("/path/to/page.vm");
     rd.forward(request, response);
   }

   public void endPageExists(WebResponse webResponse) throws 
SAXException, IOException, ServletException {
     assertEquals(HttpServletResponse.SC_OK, webResponse.getResponseCode());

     assertEquals("Some title", webResponse.getTitle());
   }


Thanks,
-Rob





> 
> Best regards,
> -- Shinobu
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: cactus and velocity

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Rob,

> I want to use Cactus to test some filters that are mapped to velocity pages.
> 
> It is working for the most part. The problem is in the endXXX methods
> and the WebResponse object (both Cactus default and HttpUnit). They
> never return any text -- using webResponse.getText() is always empty.
> The WebResponse object does return the status code as 200 and that the
> response contentType as correct (text/html).
> 
> Are there any tricks to get the response to include the velocity
> rendered page?

Can you provide some code snippet that reproduces the problem?
## A few whiles ago, I think there was a thread about Cactus not
working on a not-so-well-configured VelocityViewServlet...

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org