Ok.  That will work.  We can seed our Cactus testing framework with the
ServletContextWrapper.  Thanks for your help.

Thanks, Roger.

Vincent Massol wrote:

The context that is passed by Cactus to your code under test implements
javax.servlet.ServletContext so it makes no difference at all from your
code's point of view.

-Vincent



-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: mardi 10 ao�t 2004 14:20
To: Cactus Developers List; Vincent Massol
Subject: Re: Changing web.xml conext init param...

Hi Vincent -

The code that needs to be tested (not the cactus test itself) examines the
ServletContext context init param (the original one -
javax.servlet.ServletContext).
How can we still use Cactus?

Thanks, Roger.

Vincent Massol wrote:



Hi Roger,

Don't be afraid! There should be no problem whatsoever for the working


code


as it will use the context provided by Cactus. I don't understand your
problem and I don't think there's any.

The only case I can think of where it would be a problem is if your code
does something like this:

if (context.getClass().getName().equals("javax.servlet.[...]"))

But then that would really not be a best practice...

-Vincent





-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: mardi 10 ao�t 2004 13:49
To: Cactus Developers List
Cc: Vincent Massol
Subject: Re: Changing web.xml conext init param...

Hi Vincent -

That's what I was afraid of... Some of our code that needs to be


tested,


actually executes differently depending on the actual web.xml
context init param value. Ideally, we need a mechanism that will allow
us to manipulate the underlying "real" value. We'll have to explore


other


opportunities.

Thanks, Roger.

Vincent Massol wrote:





Hi Roger,

It's normal it's not working. When you write:

assertTrue(
 context.getOriginalContext().getInitParameter("param").equals(
 "testoverrideparam"));

You have to understand that by calling getOriginalContext() you're


asking


for ... well... the original context and not the one you're working on!

It should be:

assertTrue(
 context.getInitParameter("param").equals("testoverrideparam"));

-Vincent







-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: mardi 10 ao�t 2004 00:07
To: Vincent Massol
Cc: 'Cactus Developers List'
Subject: Re: Changing web.xml conext init param...

Hi Vincent -

Thanks for the test module.  I also found it under the cactus samples
dir...
I've tested the sample and it works as is.  However, I tweaked it
slightly:

 public void testSetContextInitParameterOverrideWebXmlParameter()
 {
     // Note: "param" is a parameter that must be already defined in
     // web.xml (in the context-param element), with a value




different




     // than "testoverrideparam1".
     assertTrue("'param' context-param should been defined in




web.xml",




         context.getOriginalContext().getInitParameter("param") !=
null);
     assertTrue(

!context.getOriginalContext().getInitParameter("param").equals(
         "testoverrideparam"));


context.setInitParameter("param", "testoverrideparam");

// Added this assertion which fails.....


assertTrue(





context.getOriginalContext().getInitParameter("param").equals(




         "testoverrideparam"));


Should the "setInitParameter" call have affected (or changed in this




case)




the underlying ServletContext init parameter?

The reason why I ask, is that ideally, that is what we want for our


test


cases.
We have code that checks the actual init param and does something




slightly




different depending on the value of the param.  We want to test this




code




with Cactus.

Thanks, in advance, Roger.



Vincent Massol wrote:







Roger,

That attachment may have been stripped by the mailing list manager.


I'm


ccing your private email address to ensure you receive it this time.

Thanks
-Vincent









-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: lundi 9 ao�t 2004 17:06
To: Cactus Developers List; [EMAIL PROTECTED]
Subject: Re: Changing web.xml conext init param...

Hi Vincent,

I did not receive an example in your last email.  Can you resend?

Thanks, in advance, Roger.

Vincent Massol wrote:









Hi Riger,

I don't know what's wrong. Maybe the fact that you're using a






JspTestCase






and not a ServletTestCase?

Could you try running the example I've included in my previous


email




to








you








to see if it works on your machine? If it works, you can work from






there








and








slowly modify the sample to your target test.

Thanks
-Vincent











-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: lundi 9 ao�t 2004 14:55
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Changing web.xml conext init param...

Hi,

I've changed the code accordingly with no success:

public class TestRenderResponsePhase extends JspFacesTestCase {
.
.

 public void setUp() {



((ServletContextWrapper)config.getServletContext()).setInitParamet


er




(




       "javax.faces.STATE_SAVING_METHOD", "client");
   System.out.println("GET INIT PARAM"+
       Config.getServletContext().getInitParameter(
       "javax.faces.STATE_SAVING_METHOD"));
.
.
.

It appears the init parameter still has the default "server"


value.


Shouldn't this have worked?  What am I missing?

Thanks in advance, Roger



Vincent Massol wrote:











Hi Roger,

Your code is invalid. You should write:

((ServletContextWrapper)










Config.getServletContext()).setInitParameter(...);










As shown in the sample application, part of the Cactus


distribution








(I'm








attaching one of its class for your reference).

-Vincent













-----Original Message-----
From: Roger Kitain [mailto:[EMAIL PROTECTED]
Sent: jeudi 5 ao�t 2004 22:36
To: [EMAIL PROTECTED]
Subject: Changing web.xml conext init param...

i,

I'm using cactus 1.6. How can I dynamically change the a


context








init








param
(that was loaded from my web.xml file) from within a test case?
Here's what I have:

in web.xml:
.
.
<context-param>
 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
 <param-value>server</param-value>
</context-param>


In my test case I was doing the following:

public class TestRenderResponsePhase extends JspFacesTestCase


{


.
.
.
public void setUp() {


ServletContextWrapper sc = new ServletContextWrapper(config.getServletContext()); sc.setInitParameter("javax.faces.STATE_SAVING_METHOD", "client"); . . . Not sure the new context param is set.....

Any help would be greatly appreciated....

Thanks, Roger.



----------------------------------------------------------------


--




--






-






To unsubscribe, e-mail: cactus-dev-


[EMAIL PROTECTED]


For additional commands, e-mail: cactus-dev-




[EMAIL PROTECTED]












-----------------------------------------------------------------


--




--






--








-








-----------------------------------------------------------------


--




--




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


[EMAIL PROTECTED]












-------------------------------------------------------------------


--


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








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






Reply via email to