jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Chalumeau <nicolas.chalum...@gmail.com>
Subject Re: bug with double instance ?
Date Tue, 02 Aug 2005 15:03:39 GMT
Just for curiousity :
What kind of parameter is it ? And is its utility?

If it is common for all test you can use a system properties.

Nicolas,

2005/8/2, Romain Thouvenin <rthouvenin@sfwan.com>:
> Yes it's an idea, some of the settings can be transferred from the
> constructor to the setUp method, but that is not the case with the one i
> talked about.
> A parameter is given to the constructor and the constructor sets a field
> with this parameter, and the setUp method cannot accept parameters.
> 
> The parameter is given to the constructor when the testSuite is built,
> and then only the instance of the TestCase knows the parameter. Anyway,
> I can't find a solution to guess this parameter in a fonction without
> argument (but continuing to search).
> 
> Romain
> 
> Nicolas Chalumeau a écrit :
> 
> >To fix this you can do all the setting that you make in the
> >constructor in the setUp method.
> >
> >Nicolas,
> >
> >2005/8/2, Romain Thouvenin <rthouvenin@sfwan.com>:
> >
> >
> >>I'm now sure this is linked to double instance of test cases : when i
> >>printed a debug message in the MyTestCase(String theName) constructor,
> >>it appeared in the server console whereas it did not use it to build
> >>testSuites.
> >>Cactus does not make an exact copy of the test case, and thus a bad copy
> >>which results in an NullPointerException.
> >>
> >>Except from correcting Cactus, I'm completely unable to find a solution
> >>to my problem... *gasp*
> >>
> >>Romain
> >>
> >>Romain Thouvenin a écrit :
> >>
> >>
> >>
> >>>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
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
>

Mime
View raw message