Re: bug with double instance ?

2005-08-04 Thread Romain Thouvenin
OK, you should have news about that issue in less that two months. Just 
let me finish my course and improve my schoolar english :) (Did you 
encounter some difficuties to understand the frenchie I am ?)


Happy to have mean to thank cactus for what it gave to my project ;)

Romain

Vincent Massol a écrit :


Hi Romain,

 


-Original Message-
From: Romain Thouvenin [mailto:[EMAIL PROTECTED]
Sent: jeudi 4 août 2005 11:46
To: Cactus Users List
Subject: Re: bug with double instance ?

Yes this sample show exactly what I want to do and what I did.
I found why the begin method wasn't called, it was declared protected !
I'm sorry to be so stupid...
Now the stuff with HTTP parameter works, but another result of my
stupidity hit me...
The static class where I'm storing informations about tests is not
shared with the server JVM : I can't access it in the setUp method.
My key in the request is therefore useless...
Should I commit suicide ?

Anyway, thank you a lot for all the help you provided.
Cactus is very useful for my current project, and I'm planning to join
the dev team in one or two month, after my course. So you should see me
again in cactus-dev list :)
Now I'm going to search another solution to my problem, and if don't
find one, going to add some code to Cactus to improve double
instanciating...
   



Yes, double instantiation is an issue we've been aware of since a long time
ago. One issue is that it prevents data-driven testig. See this thread
http://tinyurl.com/cfj2z

We'd like to fix it but no committer has found the time nor the itch to do
it... :-)

Feel free to tackle it if you're interested!

Thanks
-Vincent


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: bug with double instance ?

2005-08-04 Thread Vincent Massol
Hi Romain,

> -Original Message-
> From: Romain Thouvenin [mailto:[EMAIL PROTECTED]
> Sent: jeudi 4 août 2005 11:46
> To: Cactus Users List
> Subject: Re: bug with double instance ?
> 
> Yes this sample show exactly what I want to do and what I did.
> I found why the begin method wasn't called, it was declared protected !
> I'm sorry to be so stupid...
> Now the stuff with HTTP parameter works, but another result of my
> stupidity hit me...
> The static class where I'm storing informations about tests is not
> shared with the server JVM : I can't access it in the setUp method.
> My key in the request is therefore useless...
> Should I commit suicide ?
> 
> Anyway, thank you a lot for all the help you provided.
> Cactus is very useful for my current project, and I'm planning to join
> the dev team in one or two month, after my course. So you should see me
> again in cactus-dev list :)
> Now I'm going to search another solution to my problem, and if don't
> find one, going to add some code to Cactus to improve double
> instanciating...

Yes, double instantiation is an issue we've been aware of since a long time
ago. One issue is that it prevents data-driven testig. See this thread
http://tinyurl.com/cfj2z

We'd like to fix it but no committer has found the time nor the itch to do
it... :-)

Feel free to tackle it if you're interested!

Thanks
-Vincent


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-04 Thread Romain Thouvenin

Yes this sample show exactly what I want to do and what I did.
I found why the begin method wasn't called, it was declared protected ! 
I'm sorry to be so stupid...
Now the stuff with HTTP parameter works, but another result of my 
stupidity hit me...
The static class where I'm storing informations about tests is not 
shared with the server JVM : I can't access it in the setUp method.

My key in the request is therefore useless...
Should I commit suicide ?

Anyway, thank you a lot for all the help you provided.
Cactus is very useful for my current project, and I'm planning to join 
the dev team in one or two month, after my course. So you should see me 
again in cactus-dev list :)
Now I'm going to search another solution to my problem, and if don't 
find one, going to add some code to Cactus to improve double 
instanciating...


Regards,
Romain

Kazuhito SUGURI a écrit :


Hi Romain,

In article <[EMAIL PROTECTED]>,
Thu, 04 Aug 2005 09:17:10 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> That is what I thought, but according to the debug messages I print in 
rthouvenin> the beginXXX method, it is not already called when the program enter in 
rthouvenin> setUp in server-side.

rthouvenin> Could it be a problem of synchronizing ?

This may depending on how your TestSuite is created.

By the way, I made a working example.
Does this sample show what you want to do?

Regards,

Kazuhito SUGURI
 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-04 Thread Kazuhito SUGURI
Hi Romain,

In article <[EMAIL PROTECTED]>,
Thu, 04 Aug 2005 09:17:10 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> That is what I thought, but according to the debug messages I print 
in 
rthouvenin> the beginXXX method, it is not already called when the program 
enter in 
rthouvenin> setUp in server-side.
rthouvenin> Could it be a problem of synchronizing ?

This may depending on how your TestSuite is created.

By the way, I made a working example.
Does this sample show what you want to do?

Regards,

Kazuhito SUGURI
import junit.framework.Test;
import org.apache.cactus.ServletTestCase;
import org.apache.cactus.ServletTestSuite;
import org.apache.cactus.WebRequest;

public class SampleTest
extends ServletTestCase
{
private static final String HTTP_PARAM_FOR_TESTCASE = "private_param_info";

private String param;

public SampleTest(String theName)
{
super(theName);
}

public SampleTest(String theName, String theParam)
{
this(theName);
this.param = new String(theParam);
}

public void setUp()
{
String paramStr = request.getParameter(HTTP_PARAM_FOR_TESTCASE);
this.param = new String(paramStr);
}

public void begin(WebRequest theRequest)
{
theRequest.addParameter(HTTP_PARAM_FOR_TESTCASE, this.param);
}

public void testSample()
{
assertEquals("hello world", this.param);
}

public static Test suite()
{
ServletTestSuite suite = new ServletTestSuite();
suite.addTest(new SampleTest("testSample", "hello world"));
return suite;
}
}

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: bug with double instance ?

2005-08-04 Thread Romain Thouvenin
That is what I thought, but according to the debug messages I print in 
the beginXXX method, it is not already called when the program enter in 
setUp in server-side.

Could it be a problem of synchronizing ?

For example :
# public void beginAdd(WebRequest p_req){
#   System.out.println("Entering in begin");
#   p_req.addParameter(BEAN_PARAM, beanKey);
# }
#
# public void setUp(){
#System.out.println("Entering in setUp");
#String beanKey = request.getParameter(BEAN_PARAM);
#MyVar var = getBean(beanKey).getVar();
# }

Result :
 client-side console server-side 
console

>There was 1 error :   >Entering in setUp
>[...]NullPointerException
>at setUp
>[...]

Not seen any "Entering in begin"...
I don't unserstand :(

Thanks for you help,
Romain

Kazuhito SUGURI a écrit :


Hi Romain,

In article <[EMAIL PROTECTED]>,
Wed, 03 Aug 2005 14:56:57 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> I tried this morning, but it still have the same NullPointerException. 
rthouvenin> It seems that the begin method is called after the setUp method 
rthouvenin> (messages printed in the begin method never appear in the console). I 
rthouvenin> believed it is the contrary, isn't it ?


At server-side, begin method will never be called.
The execution sequence of a test method is roughly as follows:
client-side JVM server-side JVM
--
begin(WebRequest)
beginXXX(WebRequest)
-- send HTTP request -->
XXXTestCase(String) :construct
setUp()
testXXX()
tearDown()
<-- return HTTP response --
endXXX(WebResponse)
end(WebResponse)
# Though it's not accurate...

Is this helps you?

Kazuhito SUGURI

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-03 Thread Kazuhito SUGURI
Hi Romain,

In article <[EMAIL PROTECTED]>,
Wed, 03 Aug 2005 14:56:57 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> I tried this morning, but it still have the same 
NullPointerException. 
rthouvenin> It seems that the begin method is called after the setUp method 
rthouvenin> (messages printed in the begin method never appear in the console). 
I 
rthouvenin> believed it is the contrary, isn't it ?

At server-side, begin method will never be called.
The execution sequence of a test method is roughly as follows:
client-side JVM server-side JVM
--
begin(WebRequest)
beginXXX(WebRequest)
-- send HTTP request -->
XXXTestCase(String) :construct
setUp()
testXXX()
tearDown()
<-- return HTTP response --
endXXX(WebResponse)
end(WebResponse)
# Though it's not accurate...

Is this helps you?

Kazuhito SUGURI

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-03 Thread Romain Thouvenin
I tried this morning, but it still have the same NullPointerException. 
It seems that the begin method is called after the setUp method 
(messages printed in the begin method never appear in the console). I 
believed it is the contrary, isn't it ?


Romain


Kazuhito SUGURI a écrit :


Hi Romain,

In article <[EMAIL PROTECTED]>,
Tue, 02 Aug 2005 15:44:57 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> I'm creating a tool to launch tests based on cactus.
rthouvenin> It uses my own test cases which extend ServletTestCase, and these 
rthouvenin> testCases have a field used in test methods.
rthouvenin> But when i launch the test and try to access this field in the setUp 
rthouvenin> method, i get a NullPointerException.
rthouvenin> I've checked with prints and with a debugger, the field is correctly 
rthouvenin> initialized.

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

Server side test-case construction of Cacuts uses
constructor with one String argument ... or use the default
(i.e. no argument) constructor and setName method to specify
test method name to be executed.
So, your custom constructor is ignored in server-side.


If the parameter is determined at client-side in run-time,
you might use request parameter to pass it to server.
For example:
   private Param param;
   public ExampleTestCase(String name) {
   super(name);
   }
   public ExampleTestCase(String name, Param param) {
   this(name);
   this.param = param;
   }
   public void begin(WebRequest request) {
   request.addParameter("PARAM_NAME_FOR_TESTCASE", param.toString(),
WebRequest.POST_METHOD);
   }
   public void setUp() {
   String paramStr = request.getParameter("PARAM_NAME_FOR_TESTCASE");
   this.param = new Param(paramStr);
   }
   public void testXXX() {
   
   }

Just an idea.

Hope this helps,

Kazuhito SUGURI


 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-02 Thread Kazuhito SUGURI
Hi Romain,

In article <[EMAIL PROTECTED]>,
Tue, 02 Aug 2005 15:44:57 +0200,
Romain Thouvenin <[EMAIL PROTECTED]> wrote: 
rthouvenin> I'm creating a tool to launch tests based on cactus.
rthouvenin> It uses my own test cases which extend ServletTestCase, and these 
rthouvenin> testCases have a field used in test methods.
rthouvenin> But when i launch the test and try to access this field in the 
setUp 
rthouvenin> method, i get a NullPointerException.
rthouvenin> I've checked with prints and with a debugger, the field is 
correctly 
rthouvenin> initialized.
(snip)
rthouvenin> To build the TestSuite, i use my own constructor with a code like 
this :
rthouvenin> # suite.addTest(new MyTestCase("testName", MyClass param));
rthouvenin> and a field of MyTestCase is directly set with param.

Server side test-case construction of Cacuts uses
constructor with one String argument ... or use the default
(i.e. no argument) constructor and setName method to specify
test method name to be executed.
So, your custom constructor is ignored in server-side.


If the parameter is determined at client-side in run-time,
you might use request parameter to pass it to server.
For example:
private Param param;
public ExampleTestCase(String name) {
super(name);
}
public ExampleTestCase(String name, Param param) {
this(name);
this.param = param;
}
public void begin(WebRequest request) {
request.addParameter("PARAM_NAME_FOR_TESTCASE", param.toString(),
 WebRequest.POST_METHOD);
}
public void setUp() {
String paramStr = request.getParameter("PARAM_NAME_FOR_TESTCASE");
this.param = new Param(paramStr);
}
public void testXXX() {

}

Just an idea.

Hope this helps,

Kazuhito SUGURI

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: bug with double instance ?

2005-08-02 Thread Romain Thouvenin
The parameter is not common for all tests (i have thought about system 
properties and static classes, but it doesn't solve the problem).
In fact, the tool i'm creating will enable very easy test writing and 
launching (just a very few basis on java will be needed). The user will 
implement a method with "fake commands" (some methods encapsulated) 
which will make test cases. In a nutshell, it's a (Servlet)TestCase factory.


The way it works : the program read some configuration in XML files, 
execute the fake command and give the testcases to Junit.
Since it is a "factory", each test case is customized and that's why i 
used parameters to instanciate the test cases. At the moment, there is a 
sole parameter, it is a bean containinng all informations about the test 
to create : data to put in the request, actions to perform, assertions, 
etc...


The End :)

Since each test case as its own parameter, i stored it in a field, but 
Cactus does not properly copy it in the second instance...
A whole (and possibly big) TestSuite is given to Cactus, so i would have 
to store the whole list of parameters in the system properties or static 
class, and i would not be able to retrieve the good parameter in the 
SetUp method or the default constructor (well, i think so).


Romain

Nicolas Chalumeau a écrit :


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 <[EMAIL PROTECTED]>:
 


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 <[EMAIL PROTECTED]>:


 


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.H

Re: bug with double instance ?

2005-08-02 Thread Nicolas Chalumeau
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 <[EMAIL PROTECTED]>:
> 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 <[EMAIL PROTECTED]>:
> >
> >
> >>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);

Re: bug with double instance ?

2005-08-02 Thread Romain Thouvenin
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 <[EMAIL PROTECTED]>:
 


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 



-
To unsubscribe, e-mail: [EMAIL PR

Re: bug with double instance ?

2005-08-02 Thread Nicolas Chalumeau
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 <[EMAIL PROTECTED]>:
> 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additio

Re: bug with double instance ?

2005-08-02 Thread Romain Thouvenin
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]