You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Brette, Marc" <Ma...@mkms.xerox.com> on 2002/05/23 11:02:13 UTC

How to pass parameters to a Cactus Test Case

Hi,
I have a Cactus test that should be used against several configurations.
To fix ideas, this test accesses a database and I would like to use this
same test when my database is SQLServer or Oracle.

In my application, the database to use is defined by a configuration file.
An easy to use method would be to give the file name as a command line
argument of the test runner, and call the same test with different parameter
in my Makefile/Ant but :
- this should be given both to the test runner and of the web server
- I already pass an argument (my server root path) as a System property
(using -DrootPath=...), and I expect other tests to need such "runtime"
argument.
- It would be simpler to have such parameter defined in the Makefile/Ant,
rather than hard-coded in the test.

Does anybody have a method to provide such "runtime" argument to a test ?
(note that this is already a JUnit problem, but with Cactus, as we have
several JVM, the problem is worse)

Thanks,

Marc

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to pass parameters to a Cactus Test Case

Posted by Andrei <av...@mail.ru>.
Hello Marc,
I use a property file to provide a property to a test.
(Thank you Vincent for the idea)
Look at this:

    public void setUp() throws Exception
    {
        rb = PropertyResourceBundle.getBundle("bundle");
    }


    ...
    String host = rb.getString("property");
    ....

    
The bundle.properties file is deployed under WEB-INF/classes

If you really need you can use Ant to change this property file as you
want.
Good luck.
Andrei Somov.

    
BM> Hi,
BM> I have a Cactus test that should be used against several configurations.
BM> To fix ideas, this test accesses a database and I would like to use this
BM> same test when my database is SQLServer or Oracle.

BM> In my application, the database to use is defined by a configuration file.
BM> An easy to use method would be to give the file name as a command line
BM> argument of the test runner, and call the same test with different parameter
BM> in my Makefile/Ant but :
BM> - this should be given both to the test runner and of the web server
BM> - I already pass an argument (my server root path) as a System property
BM> (using -DrootPath=...), and I expect other tests to need such "runtime"
BM> argument.
BM> - It would be simpler to have such parameter defined in the Makefile/Ant,
BM> rather than hard-coded in the test.

BM> Does anybody have a method to provide such "runtime" argument to a test ?
BM> (note that this is already a JUnit problem, but with Cactus, as we have
BM> several JVM, the problem is worse)

BM> Thanks,

BM> Marc

BM> --
BM> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
BM> For additional commands, e-mail: <ma...@jakarta.apache.org>




-- 
Best regards,
 Andrei                            mailto:avsomov@mail.ru


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How to pass parameters to a Cactus Test Case

Posted by Vincent Massol <vm...@octo.com>.
Hi Marc,

Good question. Several solutions that comes to mind :

1/ In beginXXX() send the parameter using and WebRequest.addParameter()
and get it on the server side by calling request.getParameter() (in your
setUp() for example). Agreed this is not nice as it modified your test
case

2/ In Cactus 1.4dev every property defined in Cactus.properties is
exposed as a Java System property. Thus you can add your own properties
there and get them in your code using System.getProperty(). You'll have
to put it in both cactus.properties (client side and server side) though
(you can copy the same file to both locations).

Would that do for you ?

-Vincent

> -----Original Message-----
> From: Brette, Marc [mailto:Marc.Brette@mkms.xerox.com]
> Sent: 23 May 2002 10:02
> To: 'Cactus Users List'
> Subject: How to pass parameters to a Cactus Test Case
> 
> Hi,
> I have a Cactus test that should be used against several
configurations.
> To fix ideas, this test accesses a database and I would like to use
this
> same test when my database is SQLServer or Oracle.
> 
> In my application, the database to use is defined by a configuration
file.
> An easy to use method would be to give the file name as a command line
> argument of the test runner, and call the same test with different
> parameter
> in my Makefile/Ant but :
> - this should be given both to the test runner and of the web server
> - I already pass an argument (my server root path) as a System
property
> (using -DrootPath=...), and I expect other tests to need such
"runtime"
> argument.
> - It would be simpler to have such parameter defined in the
Makefile/Ant,
> rather than hard-coded in the test.
> 
> Does anybody have a method to provide such "runtime" argument to a
test ?
> (note that this is already a JUnit problem, but with Cactus, as we
have
> several JVM, the problem is worse)
> 
> Thanks,
> 
> Marc
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>