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 qq...@csd.abdn.ac.uk on 2003/08/21 18:11:47 UTC
Beginner's question
Hi
I have 2 questions.
(1) My 1st question is regarding Eclipse integration plugin
When I run my test using 'Run As' 'Cactus Test' in eclipse I get the
following error:
" taskdef class org.apache.cactus.integration.ant.CactifyWarTask cannot be
found "
Any suggestion how to solve this error.
(2) My 2nd question is regarding running EJB tests.
In the cactus documentations there is an example of EJB test. I have adapted
the example to one of my session bean. I have included all the .jar files and
my classes in the WEB-INF.
In my web.xml I have:
<servlet>
<servlet-name>ServletRedirector</servlet-name>
<servlet-class>
org.apache.cactus.server.runner.ServletTestRunner
</servlet-class>
</servlet>
[...]
<servlet-mapping>
<servlet-name>ServletRedirector</servlet-name>
<url-pattern>/ServletRedirector</url-pattern>
</servlet-mapping>
My question is how do I test my classes using a browser. Do I use the following
url:
http://server:port/mywebapp/ServletTestRunner?suite=com.store.BeanTest
Do I need to include ServletTestRunner in my web.xml
thanks
RE: Testing EJBs
Posted by Vincent Massol <vm...@pivolis.com>.
Hi,
> -----Original Message-----
> From: qqasim@csd.abdn.ac.uk [mailto:qqasim@csd.abdn.ac.uk]
> Sent: 26 August 2003 11:27
> To: Cactus Users List
> Subject: Testing EJBs
>
> I am tryin to test a simple session bean. This bean has a simple
method:
>
> public String printName(String n){
> String name=n;
> System.out.println("name is "+ name);
> return name;
> }
>
> I followed the EJB example provided in the cactus/samples to write a
test
> class
> for this bean and included the following method to test my
printName(..)
> method:
>
> public void testPrintName() throws Exception
> {
> try
> {
> String s = cFacade.printName("john");
> assertNotNull(s);
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
BTW, this is bad practice. You should not use the try/catch. Any error
will be reported to the JUnit test runner.
>
> But when I run my test class using the browser, I get the following
> errors:
>
> Name: testPrintName
> Status: Error
> "
> org.apache.commons.httpclient.HttpMethod.setRequestHeader
> (Ljava/lang/String;Ljava/lang/String;)V
>
> java.lang.NoSuchMethodError:
> org.apache.commons.httpclient.HttpMethod.setRequestHeader
> (Ljava/lang/String;Ljava/lang/String;)V
> at
>
org.apache.cactus.client.connector.http.HttpClientConnectionHelper.dispa
tc
> h50_co
>
nnect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspe
ct
> .aj
> [1k]:152)
> at ....".
>
> Can anyone guide me how to solve this problem or any other information
on
> testing ejb.
>
I think that's because you're not using the correct version of
commons-httpclient. Are you using JBoss? It has an old version that you
need to replace.
-Vincent
Testing EJBs
Posted by qq...@csd.abdn.ac.uk.
I am tryin to test a simple session bean. This bean has a simple method:
public String printName(String n){
String name=n;
System.out.println("name is "+ name);
return name;
}
I followed the EJB example provided in the cactus/samples to write a test class
for this bean and included the following method to test my printName(..) method:
public void testPrintName() throws Exception
{
try
{
String s = cFacade.printName("john");
assertNotNull(s);
}
catch(Exception e)
{
e.printStackTrace();
}
}
But when I run my test class using the browser, I get the following errors:
Name: testPrintName
Status: Error
"
org.apache.commons.httpclient.HttpMethod.setRequestHeader
(Ljava/lang/String;Ljava/lang/String;)V
java.lang.NoSuchMethodError:
org.apache.commons.httpclient.HttpMethod.setRequestHeader
(Ljava/lang/String;Ljava/lang/String;)V
at
org.apache.cactus.client.connector.http.HttpClientConnectionHelper.dispatch50_co
nnect(HttpClientConnectionHelper.java;org/apache/cactus/util/log/LogAspect.aj
[1k]:152)
at ....".
Can anyone guide me how to solve this problem or any other information on
testing ejb.
Re: Problem with org.apache.cactus.integration.ant.CactusTask
Posted by jacques <in...@yahoo.com>.
Hi there
I had a similar problem (custom tasks could not be
found) and suspect it has something to do with the
classloading in ant.
I solved it by defining the tasks in the cactus.tasks
(in the cactus-ant.jar, I presume) as seperate
taskdefs in the build.xml, ie. instead of having...
<taskdef resource="cactus.tasks">
<classpath>
<pathelement....
use <taskdef name="..." class=".....>
for each task defined in cactus.tasks. It looks like
an ant problem, not a cactus problem.
Ciao
Jacques
--- qqasim@csd.abdn.ac.uk wrote:
> Hi, I am having some problems with cactus. I am
> using jakarta-cactus-13-1.5-
> beta1 version
>
> All I want to do is to use cactifywar to create my
> test war and test it using
> my browser. In order to do so, I created a taskdef
> in my build file:
>
> <taskdef resource="cactus.tasks">
> <classpath>
> <pathelement
>
location="${basedir}/bookstore-lib/cactus-1.5-beta1.jar"/>
> <pathelement
>
location="${basedir}/bookstore-lib/cactus-ant-1.5-beta1.jar"/>
> <pathelement
>
location="${basedir}/bookstore-lib/commons-httpclient-
> 1.5.3.jar"/>
> <pathelement
>
location="${basedir}/bookstore-lib/commons-logging-1.0.3.jar"/>
> <pathelement
>
location="${basedir}/bookstore-lib/aspectjrt-1.0.6.jar"/>
> </classpath>
> </taskdef>
>
> But my build fails with the following error message:
>
> " class
> org.apache.cactus.integration.ant.CactusTask cannot
> be found "
>
> Previously, I had problems with eclipse plugin. I
> used to get errors: "class
> org.apache.cactus.integration.ant.CactifyWarTask
> cannot be
> found "
>
> Since both of these errors are regarding '...ant.',
> it makes me think there may
> be something wrong with my cactus dist file. When I
> downloaded cactus, I did
> not verify it. I also do not include
> cactus.properties file in my classpath. As
> I understand cactus.properties is mostly used with
> RunServerTests task.
>
> Any ideas?
>
>
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
Problem with org.apache.cactus.integration.ant.CactusTask
Posted by qq...@csd.abdn.ac.uk.
Hi, I am having some problems with cactus. I am using jakarta-cactus-13-1.5-
beta1 version
All I want to do is to use cactifywar to create my test war and test it using
my browser. In order to do so, I created a taskdef in my build file:
<taskdef resource="cactus.tasks">
<classpath>
<pathelement location="${basedir}/bookstore-lib/cactus-1.5-beta1.jar"/>
<pathelement location="${basedir}/bookstore-lib/cactus-ant-1.5-beta1.jar"/>
<pathelement location="${basedir}/bookstore-lib/commons-httpclient-
1.5.3.jar"/>
<pathelement location="${basedir}/bookstore-lib/commons-logging-1.0.3.jar"/>
<pathelement location="${basedir}/bookstore-lib/aspectjrt-1.0.6.jar"/>
</classpath>
</taskdef>
But my build fails with the following error message:
" class org.apache.cactus.integration.ant.CactusTask cannot be found "
Previously, I had problems with eclipse plugin. I used to get errors: "class
org.apache.cactus.integration.ant.CactifyWarTask cannot be
found "
Since both of these errors are regarding '...ant.', it makes me think there may
be something wrong with my cactus dist file. When I downloaded cactus, I did
not verify it. I also do not include cactus.properties file in my classpath. As
I understand cactus.properties is mostly used with RunServerTests task.
Any ideas?
RE: Beginner's question
Posted by Vincent Massol <vm...@pivolis.com>.
> -----Original Message-----
> From: qqasim@csd.abdn.ac.uk [mailto:qqasim@csd.abdn.ac.uk]
> Sent: 21 August 2003 18:12
> To: cactus-user@jakarta.apache.org
> Subject: Beginner's question
>
> Hi
> I have 2 questions.
>
> (1) My 1st question is regarding Eclipse integration plugin
> When I run my test using 'Run As' 'Cactus Test' in eclipse I get
the
> following error:
>
> " taskdef class org.apache.cactus.integration.ant.CactifyWarTask
cannot be
> found "
>
> Any suggestion how to solve this error.
The Eclipse plugin is still experimental and should currently be used at
your own risk! :-) That said it should work better than this...
Are you using the latest nightly build version? I remember seeing this
error but that was a long time ago and I thought we had fixed it.
>
> (2) My 2nd question is regarding running EJB tests.
>
> In the cactus documentations there is an example of EJB test. I have
> adapted
> the example to one of my session bean. I have included all the .jar
files
> and
> my classes in the WEB-INF.
>
> In my web.xml I have:
> <servlet>
> <servlet-name>ServletRedirector</servlet-name>
> <servlet-class>
> org.apache.cactus.server.runner.ServletTestRunner
> </servlet-class>
> </servlet>
> [...]
> <servlet-mapping>
> <servlet-name>ServletRedirector</servlet-name>
> <url-pattern>/ServletRedirector</url-pattern>
> </servlet-mapping>
>
> My question is how do I test my classes using a browser. Do I use the
> following
> url:
>
> http://server:port/mywebapp/ServletTestRunner?suite=com.store.BeanTest
yep
>
> Do I need to include ServletTestRunner in my web.xml
yep
-Vincent