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 Pavan Aripirala Venkata <pv...@h5technologies.com> on 2001/12/11 01:23:38 UTC

RE: Cactus : Struts

	Hi I used the StrutsTestCase.java to test one of my struts
class. I have struts.jar file in WEB-INF/lib directory of weblogic 6.0
server. I am getting the following exception in the setUp() method :

     [java] java.lang.NoClassDefFoundError:
org/apache/struts/action/ActionFormBeans
     [java]     at
com.ejemoni.qa.struts.TestLogonStrut.setUp(TestLogonStrut.java:93)
     [java]     at
org.apache.cactus.AbstractTestCase.runBareServerTest(AbstractTestCase.ja
va:454)
     [java]     at
org.apache.cactus.server.AbstractTestCaller.doTest(AbstractTestCaller.ja
va:137)
     [java]     at
org.apache.cactus.server.AbstractTestController.handleRequest
(AbstractTestController.java:122)
     [java]     at
org.apache.cactus.server.ServletTestRedirector.doPost(Servlet
TestRedirector.java:134)

At this line
 	ActionFormBeans formBeans =
                  (ActionFormBeans)
context.getAttribute(Action.FORM_BEANS_KEY);

If I do
	Object tmpObj = context.getAttribute(Action.FORM_BEANS_KEY);
and if I print this object, it is showing that the type of object is
org.apache.struts.action.ActionFormBeans
but however if I cast it
	ActionFormBeans formBeans =
                  (ActionFormBeans) tmpObj;
then again the above exception is being thrown
	I am able to run the EJB tests using cactus, but I am unable to
run the tests for struts. Could someone please help me in this regard?
Thanks

Pavan.

-----Original Message-----
From: Erik Hatcher [mailto:jakarta-struts@ehatchersolutions.com]
Sent: Friday, November 09, 2001 1:51 PM
To: struts-user@jakarta.apache.org
Cc: cactus-user@jakarta.apache.org
Subject: Re: Cactus : Struts


First, I'd like to thank Nick for the great work on the code he sent to
the
list.

I wanted to get something officially submitted to Struts or Cactus, so I
took what Nick provided and based the attached StrutsTestCase loosely on
it.
I wanted to do away with the mock ActionServlet inner class, so I just
use
the instance of the actual servlet provided by the ActionMappings put in
application scope.

I did not implement all the methods that Nick had as I wanted to start
small
and build up to it.  I borrowed his assertNoErrors code.  In this
version
you can assert that there are no ActionErrors (after a validate or after
an
Action.perform), and you can assert that the desired ActionForward
(currently only by name, not path) is returned.  I wanted to go ahead
and
toss this out for general review by both the Struts and Cactus
communities.
I package scoped it for inclusion in the Cactus project, but if its more
appropriate to submit to Struts thats fine.  This ought to stir up some
dependency issues between the two projects, since struts.jar will be
needed
to compile Cactus if this is accepted there!  :)

Future work on this would include adding more assert capabilities such
as
Nick has in his code.

I almost stopped work on this when I saw Deryl's post this morning -
very
fine job, Deryl!  But in my case I need the in-container testing because
our
Actions are dependent on EJB's and could not run without a container.

Let me know if I've just re-invented the wheel, and if not which project
wants it (I'm lobbying for Cactus hopefully, and not leave it dangling
without a home), any issues with the base class, other features desired,
etc.

Thanks,
    Erik


Here is a sample test case using this StrutsTestCase:

package antbook.struts;

import org.apache.cactus.struts.StrutsTestCase;

public class SearchTest extends StrutsTestCase {
    public SearchTest (String name) {
        super(name);
    }

    public void testSearch() throws Exception {
        setActionPath("/search");
        SearchForm searchForm = (SearchForm) getActionForm();
        searchForm.setQuery("abc");

        performValidate();
        assertNoErrors("After validate");

        performAction();
        assertNoErrors("After perform");
        assertActionForward("success");
    }
}

----- Original Message -----
From: "Nick Chalko" <Ni...@planetU.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, October 25, 2001 1:49 PM
Subject: Cactus : Struts


>
>
> Here is the extension I wrote.  I am still trying to get this released
Open
> Source.
>
> Note that I have a internal class to wrap the action servlet, to
return
the
> action forward,
> instead of the response.
> This also allows me to use the actual struts-congif.xml.
>
> If there is interest I think I can get my company to donate it to
struts.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Cactus : Struts

Posted by Vincent Massol <vm...@octo.com>.
Hi Pavan,

Hum ... not sure what is happening here. Are you sure that struts or any
other jar is not in your weblogic system classpath ?

-Vincent

> -----Original Message-----
> From: Pavan Aripirala Venkata [mailto:pvenkata@h5technologies.com]
> Sent: 11 December 2001 00:24
> To: Cactus Users List
> Subject: RE: Cactus : Struts
> 
> 	Hi I used the StrutsTestCase.java to test one of my struts
> class. I have struts.jar file in WEB-INF/lib directory of weblogic 6.0
> server. I am getting the following exception in the setUp() method :
> 
>      [java] java.lang.NoClassDefFoundError:
> org/apache/struts/action/ActionFormBeans
>      [java]     at
> com.ejemoni.qa.struts.TestLogonStrut.setUp(TestLogonStrut.java:93)
>      [java]     at
>
org.apache.cactus.AbstractTestCase.runBareServerTest(AbstractTestCase.ja
> va:454)
>      [java]     at
>
org.apache.cactus.server.AbstractTestCaller.doTest(AbstractTestCaller.ja
> va:137)
>      [java]     at
> org.apache.cactus.server.AbstractTestController.handleRequest
> (AbstractTestController.java:122)
>      [java]     at
> org.apache.cactus.server.ServletTestRedirector.doPost(Servlet
> TestRedirector.java:134)
> 
> At this line
>  	ActionFormBeans formBeans =
>                   (ActionFormBeans)
> context.getAttribute(Action.FORM_BEANS_KEY);
> 
> If I do
> 	Object tmpObj = context.getAttribute(Action.FORM_BEANS_KEY);
> and if I print this object, it is showing that the type of object is
> org.apache.struts.action.ActionFormBeans
> but however if I cast it
> 	ActionFormBeans formBeans =
>                   (ActionFormBeans) tmpObj;
> then again the above exception is being thrown
> 	I am able to run the EJB tests using cactus, but I am unable to
> run the tests for struts. Could someone please help me in this regard?
> Thanks
> 
> Pavan.
> 
> -----Original Message-----
> From: Erik Hatcher [mailto:jakarta-struts@ehatchersolutions.com]
> Sent: Friday, November 09, 2001 1:51 PM
> To: struts-user@jakarta.apache.org
> Cc: cactus-user@jakarta.apache.org
> Subject: Re: Cactus : Struts
> 
> 
> First, I'd like to thank Nick for the great work on the code he sent
to
> the
> list.
> 
> I wanted to get something officially submitted to Struts or Cactus, so
I
> took what Nick provided and based the attached StrutsTestCase loosely
on
> it.
> I wanted to do away with the mock ActionServlet inner class, so I just
> use
> the instance of the actual servlet provided by the ActionMappings put
in
> application scope.
> 
> I did not implement all the methods that Nick had as I wanted to start
> small
> and build up to it.  I borrowed his assertNoErrors code.  In this
> version
> you can assert that there are no ActionErrors (after a validate or
after
> an
> Action.perform), and you can assert that the desired ActionForward
> (currently only by name, not path) is returned.  I wanted to go ahead
> and
> toss this out for general review by both the Struts and Cactus
> communities.
> I package scoped it for inclusion in the Cactus project, but if its
more
> appropriate to submit to Struts thats fine.  This ought to stir up
some
> dependency issues between the two projects, since struts.jar will be
> needed
> to compile Cactus if this is accepted there!  :)
> 
> Future work on this would include adding more assert capabilities such
> as
> Nick has in his code.
> 
> I almost stopped work on this when I saw Deryl's post this morning -
> very
> fine job, Deryl!  But in my case I need the in-container testing
because
> our
> Actions are dependent on EJB's and could not run without a container.
> 
> Let me know if I've just re-invented the wheel, and if not which
project
> wants it (I'm lobbying for Cactus hopefully, and not leave it dangling
> without a home), any issues with the base class, other features
desired,
> etc.
> 
> Thanks,
>     Erik
> 
> 
> Here is a sample test case using this StrutsTestCase:
> 
> package antbook.struts;
> 
> import org.apache.cactus.struts.StrutsTestCase;
> 
> public class SearchTest extends StrutsTestCase {
>     public SearchTest (String name) {
>         super(name);
>     }
> 
>     public void testSearch() throws Exception {
>         setActionPath("/search");
>         SearchForm searchForm = (SearchForm) getActionForm();
>         searchForm.setQuery("abc");
> 
>         performValidate();
>         assertNoErrors("After validate");
> 
>         performAction();
>         assertNoErrors("After perform");
>         assertActionForward("success");
>     }
> }
> 
> ----- Original Message -----
> From: "Nick Chalko" <Ni...@planetU.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, October 25, 2001 1:49 PM
> Subject: Cactus : Struts
> 
> 
> >
> >
> > Here is the extension I wrote.  I am still trying to get this
released
> Open
> > Source.
> >
> > Note that I have a internal class to wrap the action servlet, to
> return
> the
> > action forward,
> > instead of the response.
> > This also allows me to use the actual struts-congif.xml.
> >
> > If there is interest I think I can get my company to donate it to
> struts.
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>