jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Thouvenin <rthouve...@sfwan.com>
Subject bug with double instance ?
Date Tue, 02 Aug 2005 13:44:57 GMT
I'm creating a tool to launch tests based on cactus.
It uses my own test cases which extend ServletTestCase, and these 
testCases have a field used in test methods.
But when i launch the test and try to access this field in the setUp 
method, i get a NullPointerException.
I've checked with prints and with a debugger, the field is correctly 
initialized.

I've read that cactus make two instances of test cases. Could it be 
linked to my problem ?
How are initialized class varaibles when a second instance of the test 
case is made ?

To build the TestSuite, i use my own constructor with a code like this :
# suite.addTest(new MyTestCase("testName", MyClass param));
and a field of MyTestCase is directly set with param.

I use cactus 1.7, junit 3.8.1 and orion server 2.0.5
Here is the stack trace
testAdd(com.aguila.tests.client.ClientTest)java.lang.NullPointerException
   at com.aguila.tests.client.ClientTest.setUp(ClientTest.java:77)
   at 
org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)


   at 
org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)


   at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)


   at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)


   at 
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)


   at 
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)


   at 
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)


   at 
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java) 

   at 
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)


   at 
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)


   at 
org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java) 

   at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
   at com.evermind._ctb._psd(Unknown Source)
   at com.evermind._ctb._bqc(Unknown Source)
   at com.evermind._ax._luc(Unknown Source)
   at com.evermind._ax._ucb(Unknown Source)
   at com.evermind._bf.run(Unknown Source)

ClientTest.java:77 and around :
#protected void setUp () throws Exception {
#       StartSessionServlet sss = new StartSessionServlet();
#        sss.init(super.config);
#        if(super.getInstance() == null) {
#            System.out.println("instance est null"); //This message is 
printed in the server console
#        }
#        try {
#            UserInfoBean uib = CollaborateurRep.getInstance().connect(
#                    super.getInstance().getColLogin(), 
super.getInstance().getColPass()); //line 77
#            super.getInstance().setUiBean(uib);

I would be glad to give further informations. I did not provide more 
java code since it's quite intricate and it would need more 
informations, but I'm sure super.instance should be not null (it is 
initialized in constructor and then just accessed with getInstance)

Anyway, could I have more accurate information about the way Cactus 
instanciate the test case a second time ?

Thanks for your help.
Romain Thouvenin



Mime
View raw message