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 Maria Sole Franzin <ma...@allos.it> on 2003/12/22 10:18:17 UTC

how to use in the better way ServletTestSuite with EJBs

Hi All, 
I'm testing my EBJs with cactus 1.5, and i'd like to test all by a
ServletTestSuite, or a simply Suite.

I did it defining this class:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package test.suite;
import junit.framework.*;
import org.apache.cactus.*;
public class AllTests
    extends ServletTestSuite {

  public AllTests(String s) {
    super(s);
  }
public static Test suite() {
    	TestSuite suite = new TestSuite();
    	suite.addTestSuite("sessioncactustest".class);
 	suite.addTestSuite("entity1cactustest".class);
    	suite.addTestSuite("entity2cactustest".class);
    	return suite;
  }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This suite works fine, but I can't create a hierarchy of test, I think
it's cause of the project architecture: the session bean is in a packege
indipendet from the package of the entity bean, even if the sessionbean
calls the two entityBean.

So the question are two: 
- why I have to use a SevletTestSuite that is a simply wrapper of the
junit TestSuite, isn't the same of using a TestSuite????
- how may i define a test hierarchy??? Do i have to call a suite inside
a   suite???

Thank in advance

Mariasole


Re: Struts Testing

Posted by PUTHENVILA P Johnson <PJ...@qtech.com.au>.
Yes, you are absolutely correct.



Regards
Johnson
Qtech Business Systems Pty Ltd
Level 1, 16 Edmondstone St, Newmarket QLD 4051
t : 07 3356 4377   |   f : 07 3356 5927
e :pjohnson@qtech.com.au   |    p : page us here for tech support
Visit our new website www.qtech.com.au
Check out our new Q - Specials by clicking here

Disclaimer

This transmission is intended only for the person or entity to which it is 
addressed and may contain confidential and/or privileged information. Any 
review, retransmission, dissemination or other use of, or taking of any 
action in reliance upon, this information by person or entities other than 

the intended recipient is prohibited. If you have received this e-mail in 
error, kindly notify the sender and please delete this message and any 
attachments or copies from your system. We use virus scanning software but 
do not warrant that this e-mail and any attachments are virus free.


Struts Testing

Posted by Bret Kumler <bk...@firstam.com>.
In order to test a struts application, I need to get
http://strutstestcase.sourceforge.net/ from
http://sourceforge.net/project/showfiles.php?group_id=39190&package_id=31401
&release_id=157811 and use CactusStrutsTestCase, is this correct?

Thanks,

Bret



RE: how to use in the better way ServletTestSuite with EJBs

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Maria,

> -----Original Message-----
> From: Maria Sole Franzin [mailto:mariasole.franzin@allos.it]
> Sent: 22 December 2003 10:18
> To: 'Cactus Users List'
> Subject: how to use in the better way ServletTestSuite with EJBs
> 
> Hi All,
> I'm testing my EBJs with cactus 1.5, and i'd like to test all by a
> ServletTestSuite, or a simply Suite.
> 
> I did it defining this class:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> package test.suite;
> import junit.framework.*;
> import org.apache.cactus.*;
> public class AllTests
>     extends ServletTestSuite {
> 
>   public AllTests(String s) {
>     super(s);
>   }
> public static Test suite() {
>     	TestSuite suite = new TestSuite();
>     	suite.addTestSuite("sessioncactustest".class);
>  	suite.addTestSuite("entity1cactustest".class);
>     	suite.addTestSuite("entity2cactustest".class);
>     	return suite;
>   }
> }

Quick note: This will not work. You must not put quotes around your
class name. If you do , "whatever".class will result in java.lang.String
... :-)

> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> This suite works fine, 

I would be surprised if it worked! String classes are not TestCase
classes :-)

> but I can't create a hierarchy of test, I think
> it's cause of the project architecture: the session bean is in a
packege
> indipendet from the package of the entity bean, even if the
sessionbean
> calls the two entityBean.

I don't undertsand this statement.

> 
> So the question are two:
> - why I have to use a SevletTestSuite that is a simply wrapper of the
> junit TestSuite, isn't the same of using a TestSuite????

You don't. If your test cases extends ServletTestCase (or JspTestCase or
FitlerTestCase) then you *must* not wrap them in a ServletTestSuite. The
ServletTestSuite must be used only for running pure JUnit test case
(i.e. classes that extends TestCase) on the server side.

> - how may i define a test hierarchy??? Do i have to call a suite
inside
> a   suite???

Yes. This is the JUnit way.

Alternatively, it depends on how you plan to run your tests. If you're
using Ant, I'd suggest your use the <batchtest> element instead of the
<test> one. It will run all the tests automatically without the need to
write TestAll classes.

-Vincent

> 
> Thank in advance
> 
> Mariasole
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org