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 Matt Raible <ma...@raibledesigns.com> on 2002/04/03 16:01:08 UTC

JunitPP for ServletTestCase?

Hello,

I'm a newbie using Cactus.  Is there anyway to externalize properties
from into a text file using Cactus.  I'm using JUnitPP's
ConfigurableTestCase for my regular bean and JDBC tests - very handy. 

More info at http://junitpp.sourceforge.net/.

Thanks,

Matt


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


RE: JunitPP for ServletTestCase?

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

See inline.

> -----Original Message-----
> From: Matt Raible [mailto:matt@raibledesigns.com]
> Sent: 05 April 2002 15:42
> To: 'Cactus Users List'
> Subject: RE: JunitPP for ServletTestCase?
> 
> I realize this, and this is what I'm doing in the meantime.  JunitPP
> gives me the ability to either (1) name my properties file the same
name
> as the class and it will be found automatically, OR (2) pass in a
> argument to a file that contains keys:
> 
> <junit...>
> <jvmarg value="-Djunit.conf=./src/onpoint/PersistenceTestValues.ini"/>
> </junit>

you can exactly the same with the strategy I have highlighted in my
previous email.

> 
> JunitPP also has functionality to retrieve the data from a RDBMS to
use
> as test values (I haven't used this yet).  

This is actually quite simple with Cactus as it is executing in the
container and you can have in your container a datasource pointing to
your database. See for example the dbunit project
(http://www.dbunit.org/bestpractices.html#connections).

> Below is the documentation on
> the loading of properties files with ConfigurableTestCase.  Is it
> possible to do this with Cactus - using ResourceBundles and Arguments?
> 
> 
> How is the properties file found when an instance of
> ConfigurableTestCase is executed? It is assumed that the property file
> has the same name as the class file but a different extension, i.e.
the
> property file for the FooTest.class would be named FooTest.conf. The
> property file is either looked up in the current directory or in the
> list of directories defined in the classpath variable.
> In some projects this approach might not work (e.g. using a single
> property file for all test suites) therefore the system property
> 'junit.conf'  either defines a property file or a starting directory
for
> the search.
> java -Djunit.conf=MyFooTest.conf junit.swingui.TestRunner FooTest
> java -Djunit.conf=./test/data junit.swingui.TestRunner FooTest
> Figure 3 - Specifying a test data repository
> How is an entry in the property file defined? To access the test data
> repository the class name, the name of the test case and the property
> name are concatenated to generate the key in the following order:
> .	fully qualified class name + test name + property name
> .	class name without package name + test name + property name
> .	class name without package name + property name
> .	property name
> 
> This implementation allows the reuse of test data definitions shared
by
> one or more test suites, e.g. the name of the sever used for testing a
> client/server application with multiple test suites.
> # FooTest.conf
> 
> foo.FooTest.testFoo.key1=XYZ
> FooTest.testFoo.key2=true
> FooTest.key3=9999
> Key4=3.1415927
> Figure 4 - Content of a test data repository
> In the case of a master test suite the corresponding property file
> contains references to the property files of the contained test
suites,
> which are loaded recursively.
> 

yes, I had read this.
Thanks
-Vincent

> 
> > -----Original Message-----
> > From: Vincent Massol [mailto:vmassol@octo.com]
> > Sent: Friday, April 05, 2002 12:56 AM
> > To: 'Cactus Users List'; matt@raibledesigns.com
> > Subject: RE: JunitPP for ServletTestCase?
> >
> > Hi Matt,
> >
> > I've had a look at junitpp and although it seems nice I still don't
> > really understand its value. Cactus has no such "built-in" API for
> > loading data from a properties file. However that's not really an
> issue
> > I think. Here's how you would do it (for example) :
> >
> > public void setUp()
> > {
> > 	ResourceBundle rb =
> > ProertyResourceBundle.getBundle("/configuration");
> > }
> >
> > public void testXXX()
> > {
> > 	String someProperty = rb.getString("myProperty");
> > [...]
> > }
> >
> > This would execute on the server side and would look for a file
> > configuration.properties (or with your locale suffixed) in your
webapp
> > classpath (i.e. you would usually put it in WEB-INF/classes).
> >
> > Is that what you were looking for ?
> > Thanks
> > -Vincent
> >
> >
> > > -----Original Message-----
> > > From: Matt Raible [mailto:matt@raibledesigns.com]
> > > Sent: 03 April 2002 15:01
> > > To: cactus-user@jakarta.apache.org
> > > Subject: JunitPP for ServletTestCase?
> > >
> > > Hello,
> > >
> > > I'm a newbie using Cactus.  Is there anyway to externalize
> properties
> > > from into a text file using Cactus.  I'm using JUnitPP's
> > > ConfigurableTestCase for my regular bean and JDBC tests - very
> handy.
> > >
> > > More info at http://junitpp.sourceforge.net/.
> > >
> > > Thanks,
> > >
> > > Matt
> > >
> > >
> > > --
> > > 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:   <mailto:cactus-user-
> > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:cactus-user-
> > help@jakarta.apache.org>
> 
> 
> --
> 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>


RE: JunitPP for ServletTestCase?

Posted by Matt Raible <ma...@raibledesigns.com>.
I realize this, and this is what I'm doing in the meantime.  JunitPP
gives me the ability to either (1) name my properties file the same name
as the class and it will be found automatically, OR (2) pass in a
argument to a file that contains keys:

<junit...>
<jvmarg value="-Djunit.conf=./src/onpoint/PersistenceTestValues.ini"/>
</junit>

JunitPP also has functionality to retrieve the data from a RDBMS to use
as test values (I haven't used this yet).  Below is the documentation on
the loading of properties files with ConfigurableTestCase.  Is it
possible to do this with Cactus - using ResourceBundles and Arguments?


How is the properties file found when an instance of
ConfigurableTestCase is executed? It is assumed that the property file
has the same name as the class file but a different extension, i.e. the
property file for the FooTest.class would be named FooTest.conf. The
property file is either looked up in the current directory or in the
list of directories defined in the classpath variable.
In some projects this approach might not work (e.g. using a single
property file for all test suites) therefore the system property
'junit.conf'  either defines a property file or a starting directory for
the search.
java -Djunit.conf=MyFooTest.conf junit.swingui.TestRunner FooTest
java -Djunit.conf=./test/data junit.swingui.TestRunner FooTest
Figure 3 - Specifying a test data repository
How is an entry in the property file defined? To access the test data
repository the class name, the name of the test case and the property
name are concatenated to generate the key in the following order:
.	fully qualified class name + test name + property name 
.	class name without package name + test name + property name 
.	class name without package name + property name 
.	property name 

This implementation allows the reuse of test data definitions shared by
one or more test suites, e.g. the name of the sever used for testing a
client/server application with multiple test suites.
# FooTest.conf

foo.FooTest.testFoo.key1=XYZ
FooTest.testFoo.key2=true
FooTest.key3=9999
Key4=3.1415927
Figure 4 - Content of a test data repository
In the case of a master test suite the corresponding property file
contains references to the property files of the contained test suites,
which are loaded recursively.


> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@octo.com]
> Sent: Friday, April 05, 2002 12:56 AM
> To: 'Cactus Users List'; matt@raibledesigns.com
> Subject: RE: JunitPP for ServletTestCase?
> 
> Hi Matt,
> 
> I've had a look at junitpp and although it seems nice I still don't
> really understand its value. Cactus has no such "built-in" API for
> loading data from a properties file. However that's not really an
issue
> I think. Here's how you would do it (for example) :
> 
> public void setUp()
> {
> 	ResourceBundle rb =
> ProertyResourceBundle.getBundle("/configuration");
> }
> 
> public void testXXX()
> {
> 	String someProperty = rb.getString("myProperty");
> [...]
> }
> 
> This would execute on the server side and would look for a file
> configuration.properties (or with your locale suffixed) in your webapp
> classpath (i.e. you would usually put it in WEB-INF/classes).
> 
> Is that what you were looking for ?
> Thanks
> -Vincent
> 
> 
> > -----Original Message-----
> > From: Matt Raible [mailto:matt@raibledesigns.com]
> > Sent: 03 April 2002 15:01
> > To: cactus-user@jakarta.apache.org
> > Subject: JunitPP for ServletTestCase?
> >
> > Hello,
> >
> > I'm a newbie using Cactus.  Is there anyway to externalize
properties
> > from into a text file using Cactus.  I'm using JUnitPP's
> > ConfigurableTestCase for my regular bean and JDBC tests - very
handy.
> >
> > More info at http://junitpp.sourceforge.net/.
> >
> > Thanks,
> >
> > Matt
> >
> >
> > --
> > 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:   <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>


RE: JunitPP for ServletTestCase?

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

I've had a look at junitpp and although it seems nice I still don't
really understand its value. Cactus has no such "built-in" API for
loading data from a properties file. However that's not really an issue
I think. Here's how you would do it (for example) :

public void setUp()
{
	ResourceBundle rb =
ProertyResourceBundle.getBundle("/configuration");
}

public void testXXX()
{
	String someProperty = rb.getString("myProperty");
[...]
}

This would execute on the server side and would look for a file
configuration.properties (or with your locale suffixed) in your webapp
classpath (i.e. you would usually put it in WEB-INF/classes).

Is that what you were looking for ?
Thanks
-Vincent


> -----Original Message-----
> From: Matt Raible [mailto:matt@raibledesigns.com]
> Sent: 03 April 2002 15:01
> To: cactus-user@jakarta.apache.org
> Subject: JunitPP for ServletTestCase?
> 
> Hello,
> 
> I'm a newbie using Cactus.  Is there anyway to externalize properties
> from into a text file using Cactus.  I'm using JUnitPP's
> ConfigurableTestCase for my regular bean and JDBC tests - very handy.
> 
> More info at http://junitpp.sourceforge.net/.
> 
> Thanks,
> 
> Matt
> 
> 
> --
> 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>