jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robertson, Jason" <Jason.Robert...@acs-inc.com>
Subject RE: testing ejb's with cactus
Date Thu, 26 Sep 2002 15:35:42 GMT
Have you looked at the "EJB Howto" guide on the cactus site?

http://jakarta.apache.org/cactus/howto_ejb.html

You can test EJBs over their remote interface just fine using JUnit by
itself. But if, for example, you want to test Local Interfaces then you have
to run you test on the app server, and this is what Cactus does for you.
It's also good to test on the app server if you're building a web app since
this is the context in which your EJBs will be used.

As for your connection refused error, it's likely a configuration problem so
look through the other "Howto" guides to make sure you have everything
configured properly.

Jason

-----Original Message-----
From: kendo [mailto:kencactus@yahoo.com]
Sent: Thursday, September 26, 2002 10:32 AM
To: cactus usergroup
Subject: testing ejb's with cactus



Hi all

 

I have recently downloaded cactus to use for testing ejb's, however from
working with junit  I know the setup method should be called before each
test method etc. But when using cactus and following your example on the
apache site, it seems that the setup method is not called at all but the
test methods are.  Also I can test the ejb using junit by itself and this
works but rather than extending ServletTestCase, i extend the general
TestCase.

However with extending ServletTestCase

I always get connection refused from the container(which happens to be OC4J)

 

 

1) can you inform me on the proceedure is for testing ejb's with cactus
because I have looked the apache site and followed the example :

 

package org.apache.cactus.sample.ejb; 

 

import javax.ejb.*; 

 

public class ConverterEJB implements SessionBean 

{ 

private SessionContext context; 

 

public double convertYenToDollar(double theYenAmount) 

{ 

return theYenAmount / 100.0; 

} 

 

public ConverterEJB() 

{ 

} 

 

public void ejbCreate() throws CreateException 

{ 

} 

 

public void setSessionContext(SessionContext theContext) 

{ 

this.context = theContext; 

} 

 

public void ejbActivate() 

{ 

} 

 

public void ejbPassivate() 

{ 

} 

 

public void ejbRemove() 

{ 

} 

} 

and added the test with main to call the 

junit.textui.TestRunner.run(suite()), however, this does not seem

to work. 

test example:

package org.apache.cactus.sample.ejb; 

 

import javax.naming.*; 

import javax.rmi.*; 

import junit.framework.*; 

 

import org.apache.cactus.*; 

 

public class ConverterTest extends ServletTestCase 

{ 

private Converter converter; 

 

public ConverterTest(String name) 

{ 

super(name); 

} 

 //added this method to call on the cmd line

 //acting as a client

 public static void main(String []args){
      junit.textui.TestRunner.run(suite());
      
    } 

public static Test suite() 

{ 

return new TestSuite(ConverterTest.class); 

} 

 

public void setUp() 

{ 

Context ctx = new InitialContext(); 

ConverterHome home = (ConverterHome) 

PortableRemoteObject.narrow(ctx.lookup("java:comp/ejb/Converter"), 

ConverterHome.class); 

this.converter = home.create(); 

} 

 

public void testConvert() throws Exception 

{ 

double dollar = this.converter.convertYenToDollar(100.0); 

assertEquals("dollar", 1.0, dollar, 0.01); 

} 

} 

 

Can anyone let me know to go about testing ejb's with cactus 

 Many thanks for your help or advice in advance

 

Kendo



---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message