Vincent

I have dome more investigation on this problem I have been getting.
I   have written the following servlet and test case as attached.

(See attached file: TestViewStaffResourceServlet.java)(See attached file:
ViewStaffResourceServlet.java)

And when running them I still get the following errors.

>From tomcat

001-05-29 01:50:57 - Ctx( /staffResource ): Exception in: R( /staffResource +
/ServletRedirector + null) - java.lang.ClassCastException:
org.apache.commons.cactus.ServletTestResult
       at
org.apache.commons.cactus.server.ServletTestCaller.doGetResults(ServletTestCaller.java:201)
       at
org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java:121)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
       at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
       at org.apache.tomcat.core.Handler.service(Handler.java:286)
       at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
       at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
       at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
       at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
       at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
       at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
       at java.lang.Thread.run(Thread.java:484)

and from the JUnit  dialog

java.io.FileNotFoundException:
http://localhost:8080/staffResource/ServletRedirector
     at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:549)
     at
org.apache.commons.cactus.client.ServletHttpClient.doTest(ServletHttpClient.java:119)
     at
org.apache.commons.cactus.ServletTestCase.runGenericTest(ServletTestCase.java:153)
     at
org.apache.commons.cactus.ServletTestCase.runTest(ServletTestCase.java:128)
     at
org.apache.commons.cactus.AbstractTestCase.runBare(AbstractTestCase.java:266)


This is the same error and same trace I was getting before as far as I know.
But there is progress .....

Within the Servlet method with the doSessionRequest method there are a set of
out.println() calls to build up some response HTML.
With these out.println() methods then the problem above occurs but if one
removes these print calls so there is no reponse HTML then the problem
disappears and tests work correctly, and test cases can be handled. Thus it
seems to me that there seems a conflict somewhere in the test suite code when
there is a session object and response data being BOTH sent back from a
PostMethod.

Other to you guys on this one, as I have not gone down the root of trying to
resolve where theere may be a problem in the Cactus code.
If it helps I am using the download of cactus common-cactus-23-20010502.

Please if someone can get to me with a resolution, I will be most greatful.

Cheers  and thanks for any assistance to a real problem.

Jon Belinfante




|--------+----------------------->
|        |          "Vincent     |
|        |          Massol"      |
|        |          <vmassol@octo|
|        |          .com>        |
|        |                       |
|        |          28/05/01     |
|        |          19:53        |
|        |          Please       |
|        |          respond to   |
|        |          jakarta-commo|
|        |          ns; Please   |
|        |          respond to   |
|        |          "Vincent     |
|        |          Massol"      |
|        |                       |
|--------+----------------------->
  >----------------------------------------------------------------------------|
  |                                                                            |
  |       To:     [EMAIL PROTECTED]                           |
  |       cc:     (bcc: Jon Belinfante/London/CWB)                             |
  |       Subject:     Re: Cactus Error on testing servlet.doPost Method       |
  >----------------------------------------------------------------------------|




Hi Jon,

A few general remarks first :) (we'll tackle the hard problems just after
... )

* The beginXXX() methods are optional so if you don't use it, you can simply
remove it from the test, making it more readable
* If you're testing for a positive response, like a doPost that executes
correctly, you shouldn't try to catch a possible error in a try/catch block.
Just let the exception be bounced up in the call stack. It will eventually
be picked up by the JUnit test runner. Again, this is to make it easier to
read a test and guess it's intent.

Ok, now the hard part ...

It actually looks quite strange. The line that seems to cause problem seems
to be the following from ServletTestCaller.java (although I am not sure as I
may be using a newer version than yours)

"        ServletTestResult result =
(ServletTestResult)theObjects.m_Config.getServletContext().getAttribute(TEST
_RESULTS);"

This line could return a null value if the attribute is not set but I don't
see how it could return an object of a type different than a
ServletTestResult unless :
* The getAtrtibute(TEST_RESULTS) calls returns a java object that is not a
ServletTestResult but as TEST_RESULTS is declared as 'private final static
String TEST_RESULTS = "ServletTestRedirector_TestResults";', I don't see how
this value could have been overwritten ...

No, sorry, I don't get it ... Could you try to trim your class under test
and your test class so that it contains minimum code (remove any unnecessary
code) that still triggers the error. Once done, could you send it to the
list ?

Thanks.
Vincent.

----- Original Message -----
From: "Jon Belinfante" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 24, 2001 5:49 PM
Subject: Cactus Error on testing servlet.doPost Method


> Hi Guys
>
> I am using Cactus to test a single servlet, connected to two EJB's in
> tomcat/jboss.
>
> All my tests on the servlet work except for when I try to test a doPost or
a
> doGet servlet on the code.
>
> My code is as follows
>
>
>
> public void beginProcessRequest(ServletTestRequest theRequest)
>           throws IOException
>     {
>     }
>
>   public void testProcessRequest( )
>                throws IOException, Exception
>     {
>
>           ViewStaffResourceServlet servlet =
>                new ViewStaffResourceServlet();
>           try
>           {
>                servlet.init(config);
>
>                servlet.doPost( request, response);
>           }
>
>           catch (Exception e)
>           {
>                throw e;
>           }
> }
>
> public void endProcessrequest(HttpURLConnection theConnection)
> {
> }
>
> When I run this test I get error messages from both Tomcat and also in the
> Cactus Dialog.
> The Error from Tomcat is as follows
>
> 2001-05-24 05:41:00 - Ctx( /staffResource ): Exception in: R(
/staffResource +
> /ServletRedirector + null) - java.lang.ClassCastException:
> org.apache.commons.cactus.ServletTestResult
>         at
>
org.apache.commons.cactus.server.ServletTestCaller.doGetResults(ServletTestC
aller.java:201)
>         at
>
org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTestRed
irector.java:121)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
>         at org.apache.tomcat.core.Handler.service(Handler.java:286)
>         at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>         at
>
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>         at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
>         at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>         at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>         at java.lang.Thread.run(Thread.java:484)
>
> And the Error from Cactus  is as follows
>
> java.io.FileNotFoundException:
> http://localhost:8080/staffResource/ServletRedirector
>      at
>
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:549)
>      at
>
org.apache.commons.cactus.client.ServletHttpClient.doTest(ServletHttpClient.
java:119)
>      at
>
org.apache.commons.cactus.ServletTestCase.runGenericTest(ServletTestCase.jav
a:153)
>      at
>
org.apache.commons.cactus.ServletTestCase.runTest(ServletTestCase.java:128)
>      at
>
org.apache.commons.cactus.AbstractTestCase.runBare(AbstractTestCase.java:266
)
>
> I feel resonably confident that I have my configuration correct because I
have
> other tests working correctly in the test suite - however I am always
willing to
> be proved wrong here.
> The name of my web-app here is staffResource.
>
> If anyone can help, I will be very greatful.
>
> Thanks
>
> Jon Belinfante
>
>
>
****************************************************************************
**************************************************************************
> This e-mail has been prepared using information  believed  by  the  author
> to be reliable and accurate, but CWB makes  no  warranty  as to accuracy
or
> completeness. In particular CWB does not  accept  responsibility  for
> changes  made to this e-mail after it was sent.  Any  opinions expressed
in
> this document are those of the author and do  not  necessarily reflect the
> opinions of the company or its affiliates. They may be subject to change
> without notice.
>
****************************************************************************
***************************************************************************
>
>
>




(UUEncoded file named: TestViewStaffResourceServlet.java follows)

begin 644 TestViewStaffResourceServlet.java
M+RHJ#0H@*@T*("H@0&%U=&AO<B`@0F5L:6YF84H-"B`J($!V97)S:6]N(`T*
M("HO#0H-"@T*:6UP;W)T(&IA=F$N=71I;"XJ.PT*:6UP;W)T(&IA=F$N=&5X
M="XJ.PT*:6UP;W)T(&IA=F%X+G-E<G9L970N*CL-"FEM<&]R="!J879A>"YS
M97)V;&5T+FAT='`N*CL-"FEM<&]R="!J879A+FYE="XJ.PT*:6UP;W)T(&IA
M=F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*
M#0H@("`@<'5B;&EC('-T871I8R!497-T('-U:71E*"D-"B`@("![#0H@("`@
M("`@(')E='5R;B!N97<@5&5S=%-U:71E*%1E<W16:65W4W1A9F9297-O=7)C
M95-E<G9L970N8VQA<W,I.PT*("`@('T-"@T*"7!U8FQI8R!V;VED('1E<W10
M<F]C97-S4F5Q=65S="@@*0T*"0D)=&AR;W=S($E/17AC97!T:6]N+"!%>&-E
M<'1I;VX-"B`@("![#0H-"@D)5FEE=U-T869F4F5S;W5R8V5397)V;&5T('-E
M<G9L970@/0T*"0D);F5W(%9I97=3=&%F9E)E<V]U<F-E4V5R=FQE="@I.PT*
M"0D-"@D)<V5R=FQE="YI;FET*&-O;F9I9RD[#0H)"4AT='!397-S:6]N('-E
M<W-I;VX@/2!R97%U97-T+F=E=%-E<W-I;VXH*3L-"@D)"0D)#0H@("`@"0ES
M97)V;&5T+F1O4&]S="@@<F5Q=65S="P@<F5S<&]N<V4I.PT*"0EA<W-E<G0H
M("!S97-S:6]N+F=E=$%T=')I8G5T92@B3&ES=%!A<F%M971E<B(I("$](&YU
M;&P@*3L-"@T*"0E/8FIE8W1;72!S97-S:6]N07)R87D@/2`H3V)J96-T6UTI
M<V5S<VEO;BYG971!='1R:6)U=&4H(DQI<W1087)A;65T97(B*3L-"@T*"0EA
M<W-E<G0H('-E<W-I;VY!<G)A>2`A/2!N=6QL*3L-"@T*"0D)#0H)"5-Y<W1E
M;2YO=70N<')I;G1L;B@B=&5S=%!R;V-E<W-297%U97-T(BD[#0H@("`@?0T*
&"0T*?0T*
`
end

(UUEncoded file named: ViewStaffResourceServlet.java follows)

begin 644 ViewStaffResourceServlet.java
M+RH-"B`J(%9I97=3=&%F9E)E<V]U<F-E4V5R=FQE="YJ879A#0H@*@T*("H@
M0W)E871E9"!O;B`P."!-87D@,C`P,2P@,30Z-30-"B`J+PT*#0H-"B\J*@T*
M("H-"B`J($!A=71H;W(@($)E;&EN9F%*#0H@*B!`=F5R<VEO;B`-"B`J+PT*
M#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5T(')E<W!O;G-E#0H@("`@
M*B\-"B`@("!P<F]T96-T960@=F]I9"!D;T=E="A(='1P4V5R=FQE=%)E<75E
M<W0@<F5Q=65S="P@2'1T<%-E<G9L971297-P;VYS92!R97-P;VYS92D-"@ET
M:')O=W,@4V5R=FQE=$5X8V5P=&EO;BP@:F%V82YI;RY)3T5X8V5P=&EO;@T*
M("`@('L-"@D)=&AI<RYD;U-E<W-I;VY297%U97-T*')E<75E<W0L(')E<W!O
M;G-E*3L-"@D)+R]P<F]C97-S4F5Q=65S="AR97%U97-T+"!R97-P;VYS92D[
M#0H@("`@?2`-"@T*("`@("\J*B!(86YD;&5S('1H92!(5%10(#QC;V1E/E!/
M4U0\+V-O9&4^(&UE=&AO9"X-"B`@("`J($!P87)A;2!R97%U97-T('-E<G9L
M970@<F5Q=65S=`T*("`@("H@0'!A<F%M(')E<W!O;G-E('-E<G9L970@<F5S
M<&]N<V4-"B`@("`J+PT*("`@('!R;W1E8W1E9"!V;VED(&1O4&]S="A(='1P
M4V5R=FQE=%)E<75E<W0@<F5Q=65S="P@2'1T<%-E<G9L971297-P;VYS92!R
M97-P;VYS92D-"B`@("!T:')O=W,@4V5R=FQE=$5X8V5P=&EO;BP@:F%V82YI
M;RY)3T5X8V5P=&EO;@T*("`@('L-"@D)=&AI<RYD;U-E<W-I;VY297%U97-T
M*')E<75E<W0L(')E<W!O;G-E*3L-"B`@("`@("`@+R]P<F]C97-S4F5Q=65S
M="AR97%U97-T+"!R97-P;VYS92D[#0H@("`@?0T*#0H@("`@+RHJ(%)E='5R
M;G,@82!S:&]R="!D97-C<FEP=&EO;B!O9B!T:&4@<V5R=FQE="X-"B`@("`J
M+PT*("`@('!U8FQI8R!3=')I;F<@9V5T4V5R=FQE=$EN9F\H*2![#0H@("`@
M("`@(')E='5R;B`B5FEE=R!3=&%F9E)E<V]U<F-E($5N=&5R<')I<V4@2F%V
;84)E86X@4V5R=FQE="([#0H@("`@?0T*?0T*
`
end


Reply via email to