jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@pivolis.com>
Subject RE: Want to pass argument to ServletTestRunner.
Date Sun, 04 May 2003 11:08:00 GMT
Anil,

> -----Original Message-----
> From: Anil Agrawal [mailto:a.agrawal@popnet.co.in]
> Sent: 02 May 2003 17:24
> To: Cactus Users List
> Subject: RE: Want to pass argument to ServletTestRunner.
> 
> I want to pass argument from outside my testcase class.

You cannot. And the reason is that all the client-side setup for your
test has to go in your beginXXX() methods, which you can factorize in a
common begin() method (common to all testXXX()) if you wish.

For example:

public void MYTest extends ServletTestCase
{
    public void begin(WebRequest request)
    {
        request.addParameter("alias", "anil");
        request.addParameter("password", "123456");
    }
[...]
}

Now if you want to *Parametrize* the tests with outside configuration
values, just use the following (for example):

public void MYTest extends ServletTestCase
{
    public void begin(WebRequest request)
    {
        request.addParameter("alias", System.getProperty("alias"));
        request.addParameter("password",
System.getProperty("password"));
    }
[...]
}

In order to pass the system properties to cactus you have 2 options:

1/ pass them on the command line that you use to start the JUnit Test
Runner. If you're using the ServletTestRunner, then that would be on the
command line that you use to start your container.

2/ add these properties in the cactus.properties file. All properties
found in this file are imported as system properties during the Cactus
initialization.

Hope it help,
-Vincent

PS: I've also created a FAQ entry but somehow I cannot succeed in
uploading the cactus web site today...

> 
> With regards
> anil
> 
> -----Original Message-----
> From: eric.hodge@jpmorgan.com [mailto:eric.hodge@jpmorgan.com]
> Sent: Friday, May 02, 2003 7:27 PM
> To: cactus-user@jakarta.apache.org
> Subject: Re: Want to pass argument to ServletTestRunner.
> 
> 
> 
> Given a testXXX() method, add this to your ServletTestCase:
> 
> public void beginXXX(WebRequest theRequest) {
>       theRequest.addParameter("parameterName", "parameterValue"); }
> 
> 
> 
> 
> |---------+---------------------------->
> |         |           a.agrawal@popnet.|
> |         |           co.in            |
> |         |                            |
> |         |           05/02/2003 05:42 |
> |         |           AM               |
> |         |           Please respond to|
> |         |           cactus-user      |
> |         |                            |
> |---------+---------------------------->
> 
>
>-----------------------------------------------------------------------
> -------------------------------------------------------|
>   |
> |
>   |       To:       cactus-user@jakarta.apache.org
> |
>   |       cc:       eric.hodge@jpmorgan.com
> |
>   |       Subject:  Want to pass argument to ServletTestRunner.
> |
> 
>
>-----------------------------------------------------------------------
> -------------------------------------------------------|
> 
> 
> 
> 
> I want to pass arguments to ServletTestRunner like
>  alias=anil
>  assword=123456
> 
> And from my testcase which extends jsptestcase I want to access this
> value by
> request.getParameter("alias")
> request.getParameter("password")
> 
> Pl. help me
> 
>
http://aa:7001/ServletTestRunner?suite=com.csam.wsc.auth.junit.cactus.Te
>
stTagUpdateServiceUrl&xsl=junit-noframes.xsl&alias=anil&password=123456
> 
> With regards
> anil
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
> 
> 
> 
> 
> 
> This communication is for informational purposes only.  It is not
> intended as an offer or solicitation for the purchase or sale of any
> financial instrument or as an official confirmation of any
transaction.
> All market prices, data and other information are not warranted as to
> completeness or accuracy and are subject to change without notice. Any
> comments or statements made herein do not necessarily reflect those of
> J.P. Morgan Chase & Co., its subsidiaries and affiliates.
> 
> 
> ---------------------------------------------------------------------
> 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