Hi Denis,

A few answers that hopefully might help you a bit ...

* The way Cactus is currently set up you cannot prevent it from dispatching
(do you mean calling a RequestDispatcher.forward() ?)
* Usually the doGet method is only tested for functional test, and the
output asserted in endXXX(). Normally, the doGet() method should be minimal
and will call other methods in your servlet. These methods are what you want
to unit test (in addition to the doGet).
* There are several ways to resolve the "private" problem ...
  - the easiest one is to make your methods either protected or package
level access, so that your test case will have access to the method
(provided you put your test cases in the same package, which is what is
advised).
  - change the java permissions to allow calling private methods by
reflection. I have never tried it but should be able to be set up like this
:

create a policy file (security.policy for instance) and add the following to
it :

grant {
    permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};

then start you JVM with the command
"java -Djava.security.manager -Djava.security.policy==security.policy [...]"
Of course, if your server already makes uses of a policy file you should
modify that policy file. Also for security reasons you should restrict the
codeBase to only the Redirector Servlet.

Hope it helps.
-Vincent

----- Original Message -----
From: "Denis Krizanovic" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 14, 2001 2:33 AM
Subject: 2 questions


>
> Hiyas,
>
> We finally got Cactus to work on WebLogic6 .. [more on this another time]
> and are now starting to use cactus. We run into what may be some
conceptual
> problems on our side.
>
> 1 - we have our servlets set up in chains, with each servlet dispatching
to
> the next.. But we want to test the methods in the servlets in isolation..
If
> you write a test for the doGet, how do you avoid it dispatching - can
cactus
> catch the dispatch?
>
> 2 - the doGet calls a bunch of private methods. How do you get Cactus to
> test those private methods? And the broader issue, how do you get jUnit to
> test private members. I feel uncomfortable making things public just so I
> can jUnit them.
>
> regards,
> dk-
>
>
>

Reply via email to