jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: how to test jsp?
Date Sat, 14 Dec 2002 20:59:57 GMT
Hi Leo,

> -----Original Message-----
> From: news [mailto:news@main.gmane.org] On Behalf Of Leos Literak
> Sent: 14 December 2002 17:13
> To: cactus-user@jakarta.apache.org
> Subject: how to test jsp?
> Hi all,
> I am new to cactus and I read all doc, though I wonder,
> how to test jsp. I dont want to test tag library, but
> execution of jsp.
> My situation:
> I am developing j2ee application and all my tests
> are plain old jsp's, where I lookup interfaces and perform
> all tests. Now my boss wants me to use cactus and automate
> these tests.

I like your boss ... :-)

> I'd like to stay with jsp, as they are easy to develope.

You must the first one I hear saying that JSP are easy to develop! ;-)

> Also they're reloading is great. So I created class
> holding common testing methods, one is
> public static void setUnitTestResult(HttpServletResponse response,
> boolean result) {
>   response.setHeader(UNIT_TEST_RESULT,new Boolean(result).toString());
> }

ok. What is your test client (i.e. the part that will read the header
and decide whether the test was successful or not)?

It looks like you are using the same kind of approach as Cactus is

> I wanted to execute jsp from ServletTestCase and in
> endTestJSP(WebReponse) to test that header value:
> public void endJSP(com.meterware.httpunit.WebResponse r) {
>   String result =
>   assertNotNull("Unit test result is missing!",result);
>   assertEquals("Unit test failed!",Boolean.TRUE,new Boolean(result));
> }

ok. I understand what you want to do. Note: you don't need HttpUnit
integration for just testing the header.

It will work but it means you're actually only using the client side
part of Cactus (i.e. only a small portion of it). Thus Cactus is only
providing you the bridge with the JUnit Test Runner. The Cactus
Redirector is actually more a handicap than a help for what you want to
do. The problem is that for each jsp test you'll have to write a
Cactus/JUnit testXXX() test, which is a pain I think. Of course, you
could write a generic testXXX() that will generically call each of your
JSPs but your tests will appear as only a single test for JUnit and it
will be a bit awkward.

> This approach is very simple and it is backward compatible
> with current scenerio. 

It looks complex to me... :-) If you want to use Cactus I would drop
your JSPs and instead use Cactus ServletTestCase. Java classes can also
be reloaded by most containers so that shouldn't be an issue.

> I would like to be able to develope
> jsp with browser interaction and when it is ready, just
> add it into ServletTestCase for automated build process.

Not sure what you mean here by browser interaction.

> I am open to advices for better approach.
> My problem is, that there is no single line in documentation
> describing, how to open URL with jsp. 

This is Servlet/JSP API, not Cactus! Even though, it is documented in
Cactus... (see below).

> Doc for ServletTestCase
> relies on fact, that you are instantiating servlet class,
> which will not work with jsp. And JspTestCase seems to me
> focused on tag library, and there is no way to execute jsp.

Hum.. You said you read all the doc... Have you read this one:
http://jakarta.apache.org//cactus/howto_jsp.html which explains what you
can do with Cactus for testing JSPs!

> I'd appreciate any comments to my approach and advices for
> JSP execution. How to open that URL.
> Thanks!
> 	Leo


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

View raw message