jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nsathiamoor...@agl.com.au
Subject problem unit testing local ejbs on oc4j
Date Wed, 15 Oct 2003 08:13:01 GMT
Hi,

I trying to use Cactus to unit test some local ejbs but am running into
problems.

Initially, all the ejbs were remote and all my Junit classess worked fine.
I changed the ejbs to be local and tried out Cactus and things kept failing
with NullPointerExceptions.

I have finally narrowed it to the setup() method not being called.
Ridiculous .. I hear you mutter!! I created a small test ServletTestCase.
The details are below:

package au.com.agl.component.customer.activities;
import org.apache.cactus.*;
import junit.framework.*;
public class CactusTest extends ServletTestCase
{
      String hello;

      public void setUp() {
            hello = "hi there";
      }
      public void tearDown() {
            hello = null;
      }
      public CactusTest(String name) {
            super(name);
      }
      public static Test suite(){
            ServletTestSuite suite = new ServletTestSuite();
            suite.addTestSuite(CactusTest.class);
            return suite;
      }
      public void testSetUp() {
            try {
                  assertNotNull("String is null", hello);
                  assertTrue("String value is:" + hello, hello.equals("hi
there"));
            } catch (Exception ex) {
                  fail("Caught an exception:" + ex);
            }
      }
      public void testSuccess() {
            boolean test = true;
            assertTrue(test);
      }
}


The results were:
|-------------+--------->
|             |         |
|     Name    |  Status |
|             |         |
|-------------+--------->
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  |                                                                                      
                                                           |
  |                                                                       Type           
                                                           |
  |                                                                                      
                                                           |
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  >---------|
  |         |
  |  Time(s |
  |    )    |
  |         |
  >---------|
|-------------+--------->
|             |         |
|  testSetUp  |  Failur |
|             |  e      |
|             |         |
|-------------+--------->
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  |                                                                                      
                                                           |
  |  String is null                                                                      
                                                           |
  |                                                                                      
                                                           |
  |  junit.framework.AssertionFailedError: String is null                                
                                                           |
  |  at au.com.agl.component.customer.activities.CactusTest.testSetUp(Unknown Source)    
                                                           |
  |  at                                                                                  
                                                           |
  |  org.apache.cactus.internal.server.ServerTestCaseDelegate.runServerTest(ServerTestCaseDelegate.java;org/apache/cactus/util/log/LogAspect.aj[1k]:
|
  |  214)                                                                                
                                                           |
  |  at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:280)              
                                                           |
  |  at org.apache.cactus.ServletTestCase.runBare(ServletTestCase.java:251)              
                                                           |
  |  at org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:156)
                                                       |
  |  at                                                                                  
                                                           |
  |  org.apache.cactus.server.AbstractWebTestController.dispatch133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspec
|
  |  t.aj[1k]:130)                                                                       
                                                           |
  |  at                                                                                  
                                                           |
  |  org.apache.cactus.server.AbstractWebTestController.around133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.
|
  |  aj[1k]:1158)                                                                        
                                                           |
  |  at                                                                                  
                                                           |
  |  org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101
|
  |  )                                                                                   
                                                           |
  |  at                                                                                  
                                                           |
  |  org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
  |
  |  at org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
|
  |  at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:109)
           |
  |  at org.apache.cactus.server.ServletTestRedirector.dispatch159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:96)
 |
  |  at org.apache.cactus.server.ServletTestRedirector.around159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
 |
  |  at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:92)
             |
  |  at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)                     
                                                           |
  |  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)                     
                                                           |
  |  at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
                                                 |
  |  at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
                                        |
  |  at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
                                                     |
  |  at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)     
                                                           |
  |  at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)     
                                                           |
  |  at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
                                                         |
  |  at java.lang.Thread.run(Unknown Source)                                             
                                                           |
  |                                                                                      
                                                           |
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  >---------|
  |         |
  |  1.313  |
  |         |
  >---------|
|-------------+--------->
|             |         |
|  testSucces |  Succes |
|  s          |  s      |
|             |         |
|-------------+--------->
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  |                                                                                      
                                                           |
  |                                                                                      
                                                           |
  |                                                                                      
                                                           |
  >-------------------------------------------------------------------------------------------------------------------------------------------------->
  >---------|
  |         |
  |  0.046  |
  |         |
  >---------|


I also read that I can run JUnit TestCase classes in Cactus and tried it
with the same results.
I am using:
oc4j 9.0.3
cactus 12-1.5-beta1

I have been trawling the mailing list with no success ... would appreciate
any help you can provide.

Cheers,
Nim.






**********************************************************************
This  email  is  intended  solely  for the use of the addressee
and may contain information that is confidential or privileged.
If you receive this email in error please notify the sender and
delete the email immediately.
**********************************************************************


Mime
View raw message