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 la...@masq.ca on 2002/04/23 17:06:11 UTC

Running cactus in a separate tree from source

Hi,

We have a setup which generates a lot of war files in

/tmp/foo/foo.war
/tmp/bar/bar.war
.
.
.

I want to create some tests for Cactus which tests the classes in the above
wars. I was hoping that I could put all my tests in a cactus.war file and
run the tests correclty. Is this possible? Or do I have to have all my tests
in the foo.war, bar.war, etc. files? Should I try to use an EAR file for my
cactus tests?

Note that I'm creating a new directory for all my tests, and running my
tests in that directory.

Is this clear or not?

Thanks,

L

-- 
Laurent Duperval <ma...@masq.ca>

MURPHY'S_LAWS_OF_COMBAT:
 14. Never draw fire, it irritates everyone around you.



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


RE: Running cactus in a separate tree from source

Posted by Nicholas Lesiecki <ni...@eblox.com>.
<<<
So I am stuck with having to intersperse the cactus tests with the code,
right? Each WebApp needs its deployment descriptor to operate properly,
right? So I will have to put the cactus code with the rest of the code, so
that the Webapp will be constructed correctly. ... I don't really see a way
around it. I wanted to keep the cactus code from being deployed with the
production code, without having to do a lot of gymnastics.
>>>

You can probably use Ant to keep them separate. Simply have adifferent
target in your build script that excludes all of your test code from a
production build of any of your WARs. You can also use Ant to remove test
stuff from your web.xml. There's an entry in the FAQ on this.

Cheers,

Nicholas Lesiecki
Principal Software Engineer
eBlox, Inc.
(520) 615-9345 x104
Check out my new book!:
Java Tools for Extreme Programming: Mastering Open Source Tools, including
Ant, JUnit, and Cactus

http://www.amazon.com/exec/obidos/ASIN/047120708X/

Check out my article on AspectJ:
http://www-106.ibm.com/developerworks/library/j-aspectj/index.html


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


RE: Running cactus in a separate tree from source

Posted by Vincent Massol <vm...@octo.com>.

> -----Original Message-----
> From: laurent.duperval@masq.ca [mailto:laurent.duperval@masq.ca]
> Sent: 24 April 2002 14:21
> To: cactus-user@jakarta.apache.org
> Subject: Re: Running cactus in a separate tree from source
> 
> On 23 Apr, Vincent Massol wrote:
> > Laurent,
> >
> > I hope you'll submit some FAQ entries after all these questions !
:-)
> >
> 
> Sure, if that can help.
> 
> > The constraint is not Cactus. It is your container classloader. Once
you
> > understand that you understand all valid possibilities. However, it
is a
> > bit tricky to understand ... :-)
> >
> > The one thing that would not work is if you put the Cactus tests in
one
> > J2EE module and the classes to test in another. This is because
Cactus
> > needs a Redirector (let's say a servlet). Let's say you configure
Cactus
> > web.xml in a cactus.war module and that your application is in
> > myapp1.war. I think the J2EE spec says that a webapp is independent
of
> > another one and thus they're not supposed to share the same
classloader.
> > Thus it is impossible to view the classes in one webapp from another
> > webapp.
> >
> 
> Ok, I can dig that.
> 
> > What Cactus 1.3 should support (if your container supports Context
> > classloaders) is to be put in the your container system classpath (I
> > haven't tried it though) so that you can "share" cactus.jar for
several
> > webapps.
> >
> 
> Ok.
> 
> > Your underlying question, if I understand correctly is : how do I
test
> > several webapps ?
> >
> 
> Right. But with a twist: I'd like to keep the cactus stuff separate
from
> the
> source code. Our source code structure looks like this:
> 
> project/modules/moduleA
>                /moduleB
>                .
>                .
>                .
>                /cactus
> 
> 
> In cactus, I want to put all the code to do the cactus tests.
> 
> > The solution :
> >
> > - Have several <junit> tasks and use several "cactus.properties"
files
> > (you can pass them to Cactus using the cactus.config java parameter
(See
> > http://jakarta.apache.org/cactus/howto_config.html).
> >
> 
> So I am stuck with having to intersperse the cactus tests with the
code,
> right? 

yes

> Each WebApp needs its deployment descriptor to operate properly,
> right? 

yes

> So I will have to put the cactus code with the rest of the code, so
> that the Webapp will be constructed correctly. ... I don't really see
a
> way
> around it. I wanted to keep the cactus code from being deployed with
the
> production code, without having to do a lot of gymnastics.
> 

The solution that we are all using is by making the "gymnastic" with
Ant. What I do is simply to have 2 targets and in the production one I
don't include the Cactus jars and the test classes. I have 2 web.xml.
You can also using the replace task (can't remember the exact name) to
replace a portion of text in a file, thus you can have a single web.xml
file (someone posted an example a while ago). It is really not difficult
at all.

What you shoud be able to do with Cactus this far is to remove the
cactus jars and the test classes from your webapp and put them in the
system classloader. However you will still need a modified web.xml.

> The <junit> thing you're talking about is taken care of by the way our
> code
> is structured. Probably what I'll need to do is to start Weblogic from
my
> toplevel build.xml, then the runtests target will run the tests in
each of
> the modules, and then it will stop weblogic in the toplevel build
file.
> 

yep run all your tests (<junit> tasks) in the runTarget target.

> If there's another way, let me know.
> 
> Thanks for the reply,
> 
> L
> 

-Vincent


> 
> --
> Laurent Duperval <ma...@masq.ca>
> 
> "When women say they love you just the way you are, they really mean
it...
> then they try to change you."
>                      -Paraphrased from "Coach"
> 
> 
> 
> --
> 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>


Re: Running cactus in a separate tree from source

Posted by la...@masq.ca.
On 23 Apr, Vincent Massol wrote:
> Laurent,
> 
> I hope you'll submit some FAQ entries after all these questions ! :-)
> 

Sure, if that can help.

> The constraint is not Cactus. It is your container classloader. Once you
> understand that you understand all valid possibilities. However, it is a
> bit tricky to understand ... :-)
> 
> The one thing that would not work is if you put the Cactus tests in one
> J2EE module and the classes to test in another. This is because Cactus
> needs a Redirector (let's say a servlet). Let's say you configure Cactus
> web.xml in a cactus.war module and that your application is in
> myapp1.war. I think the J2EE spec says that a webapp is independent of
> another one and thus they're not supposed to share the same classloader.
> Thus it is impossible to view the classes in one webapp from another
> webapp.
> 

Ok, I can dig that.

> What Cactus 1.3 should support (if your container supports Context
> classloaders) is to be put in the your container system classpath (I
> haven't tried it though) so that you can "share" cactus.jar for several
> webapps.
> 

Ok.

> Your underlying question, if I understand correctly is : how do I test
> several webapps ?
> 

Right. But with a twist: I'd like to keep the cactus stuff separate from the
source code. Our source code structure looks like this:

project/modules/moduleA
               /moduleB
               .
               .
               .
               /cactus


In cactus, I want to put all the code to do the cactus tests.

> The solution :
> 
> - Have several <junit> tasks and use several "cactus.properties" files
> (you can pass them to Cactus using the cactus.config java parameter (See
> http://jakarta.apache.org/cactus/howto_config.html).
> 

So I am stuck with having to intersperse the cactus tests with the code,
right? Each WebApp needs its deployment descriptor to operate properly,
right? So I will have to put the cactus code with the rest of the code, so
that the Webapp will be constructed correctly. ... I don't really see a way
around it. I wanted to keep the cactus code from being deployed with the
production code, without having to do a lot of gymnastics. 

The <junit> thing you're talking about is taken care of by the way our code
is structured. Probably what I'll need to do is to start Weblogic from my
toplevel build.xml, then the runtests target will run the tests in each of
the modules, and then it will stop weblogic in the toplevel build file.

If there's another way, let me know.

Thanks for the reply,

L


-- 
Laurent Duperval <ma...@masq.ca>

"When women say they love you just the way you are, they really mean it...
then they try to change you."
                     -Paraphrased from "Coach"



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


RE: Running cactus in a separate tree from source

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

I hope you'll submit some FAQ entries after all these questions ! :-)

> -----Original Message-----
> From: laurent.duperval@masq.ca [mailto:laurent.duperval@masq.ca]
> Sent: 23 April 2002 19:54
> To: cactus-user@jakarta.apache.org
> Subject: Re: Running cactus in a separate tree from source
> 
> On 23 Apr, To: Cactus Mailing List wrote:
> > Hi,
> >
> > We have a setup which generates a lot of war files in
> >
> > /tmp/foo/foo.war
> > /tmp/bar/bar.war
> > .
> > .
> > .
> >
> > I want to create some tests for Cactus which tests the classes in
the
> above
> > wars. I was hoping that I could put all my tests in a cactus.war
file
> and
> > run the tests correclty. Is this possible? Or do I have to have all
my
> tests
> > in the foo.war, bar.war, etc. files? Should I try to use an EAR file
for
> my
> > cactus tests?
> >
> 
> Ok, turns out that this question is valid after all. I have a number
of
> EJB
> jars and Web apps that have been built by our build script. Each
> application
> is deployed it its own archive. I would like to put all the cactus
tests
> in
> one archive, instead of spreading them out in each of the archives as
> outlined earlier? Is this possible? Should I do that using an EAR
which
> will
> contain the war file for my cactus tests and a bunch of jar and/or ear
> files
> which contain the classes I want to test? Or is there a better way?
> 

The constraint is not Cactus. It is your container classloader. Once you
understand that you understand all valid possibilities. However, it is a
bit tricky to understand ... :-)

The one thing that would not work is if you put the Cactus tests in one
J2EE module and the classes to test in another. This is because Cactus
needs a Redirector (let's say a servlet). Let's say you configure Cactus
web.xml in a cactus.war module and that your application is in
myapp1.war. I think the J2EE spec says that a webapp is independent of
another one and thus they're not supposed to share the same classloader.
Thus it is impossible to view the classes in one webapp from another
webapp.

What Cactus 1.3 should support (if your container supports Context
classloaders) is to be put in the your container system classpath (I
haven't tried it though) so that you can "share" cactus.jar for several
webapps.

Your underlying question, if I understand correctly is : how do I test
several webapps ?

The solution :

- Have several <junit> tasks and use several "cactus.properties" files
(you can pass them to Cactus using the cactus.config java parameter (See
http://jakarta.apache.org/cactus/howto_config.html).

Thanks
-Vincent

> Thanks,
> 
> L
> 
> --
> Laurent Duperval <ma...@masq.ca>
> 
> PARKINSON'S LAW, MODIFIED
>     The components you have will expand to fill the available space.
> 
> 
> 
> --
> 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>


Re: Running cactus in a separate tree from source

Posted by la...@masq.ca.
On 23 Apr, To: Cactus Mailing List wrote:
> Hi,
> 
> We have a setup which generates a lot of war files in
> 
> /tmp/foo/foo.war
> /tmp/bar/bar.war
> .
> .
> .
> 
> I want to create some tests for Cactus which tests the classes in the above
> wars. I was hoping that I could put all my tests in a cactus.war file and
> run the tests correclty. Is this possible? Or do I have to have all my tests
> in the foo.war, bar.war, etc. files? Should I try to use an EAR file for my
> cactus tests?
> 

Ok, turns out that this question is valid after all. I have a number of EJB
jars and Web apps that have been built by our build script. Each application
is deployed it its own archive. I would like to put all the cactus tests in
one archive, instead of spreading them out in each of the archives as
outlined earlier? Is this possible? Should I do that using an EAR which will
contain the war file for my cactus tests and a bunch of jar and/or ear files
which contain the classes I want to test? Or is there a better way?

Thanks,

L

-- 
Laurent Duperval <ma...@masq.ca>

PARKINSON'S LAW, MODIFIED
    The components you have will expand to fill the available space.



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


Re: Running cactus in a separate tree from source

Posted by la...@masq.ca.
On 23 Apr, To: cactus-user@jakarta.apache.org wrote:
> Ok, let me change this question. After rereading the config page, I decided
> to take all the .class files and put them in my cactus.war file. However,
> when I run my tests, I get this error:
> 

Well, looks like a 10 minute break cleared the cobwebs pretty well. Turns
out my web.xml file doesn't contain the name of the correct class to use for
testing. Doh! Let me try again. You can disregard this whole thread...

L

-- 
Laurent Duperval <ma...@masq.ca>

"Life is what happens while you're making other plans"
                     -John Lennon



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


Re: Running cactus in a separate tree from source

Posted by la...@masq.ca.
On 23 Apr, To: Cactus Mailing List wrote:
> Hi,
> 
> We have a setup which generates a lot of war files in
> 
> /tmp/foo/foo.war
> /tmp/bar/bar.war
> .
> .
> .
> 
> I want to create some tests for Cactus which tests the classes in the above
> wars. I was hoping that I could put all my tests in a cactus.war file and
> run the tests correclty. Is this possible? Or do I have to have all my tests
> in the foo.war, bar.war, etc. files? Should I try to use an EAR file for my
> cactus tests?
> 

Ok, let me change this question. After rereading the config page, I decided
to take all the .class files and put them in my cactus.war file. However,
when I run my tests, I get this error:


    [junit] Testcase: testDoGet took 0.036 sec
    [junit] 	Caused an ERROR
    [junit] Not a valid response
    [junit] org.apache.cactus.util.ChainedRuntimeException: Not a valid response
    [junit] 	at org.apache.cactus.client.WebTestResultParser.readRootElement(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):134)
    [junit] 	at org.apache.cactus.client.WebTestResultParser.dispatch29_parse(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):101)
    [junit] 	at org.apache.cactus.client.WebTestResultParser.around29_parse(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):1221)
    [junit] 	at org.apache.cactus.client.WebTestResultParser.parse(WebTestResultParser.java;org/apache/cactus/util/log/LogAspect.java(1k):96)
    [junit] 	at org.apache.cactus.client.AbstractHttpClient.callGetResult(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):231)
    [junit] 	at org.apache.cactus.client.AbstractHttpClient.dispatch1_doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):123)
    [junit] 	at org.apache.cactus.client.AbstractHttpClient.around1_doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):1221)
    [junit] 	at org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.java;org/apache/cactus/util/log/LogAspect.java(1k):115)
    [junit] 	at org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:457)
    [junit] 	at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133)
    [junit] 	at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:400)
    [junit] 	at junit.framework.TestResult$1.protect(TestResult.java:106)
    [junit] 	at junit.framework.TestResult.runProtected(TestResult.java:124)
    [junit] 	at junit.framework.TestResult.run(TestResult.java:109)
    [junit] 	at junit.framework.TestCase.run(TestCase.java:131)
    [junit] 	at junit.framework.TestSuite.runTest(TestSuite.java:173)
    [junit] 	at junit.framework.TestSuite.run(TestSuite.java:168)
    [junit] 	at junit.framework.TestSuite.runTest(TestSuite.java:173)
    [junit] 	at junit.framework.TestSuite.run(TestSuite.java:168)
    [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:231)
    [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:409)

What causes this in my setup?

L

-- 
Laurent Duperval <ma...@masq.ca>

LARKINSON'S LAW
    All laws are basically false.



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