jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kendo <kencac...@yahoo.com>
Subject testing ejb's with cactus
Date Thu, 26 Sep 2002 14:32:25 GMT

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!
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message