Hi,
I've just commited live testing support. Here is a summary
of what I changed.
The first thing to notice is that we not have an interface
for classes that are meant to setup a data directory for
functional testing. Here is is:
/**
* A test data directory creator and accessor, used for functional testing
* purposes in GeoServer
*
* @author Andrea Aime - TOPP
*/
public interface TestData {
/**
* Creates the temporary GeoServer data directory
*/
public void setUp() throws Exception;
/**
* Wipes out the contents of the temporary data directory
*/
public void tearDown() throws Exception;
/**
* @return The root of the data directory.
*/
public File getDataDirectoryRoot();
/**
* Returns wheter the test data is available. If not the test should be skipped
*/
public boolean isTestDataAvailable();
}
As you can see, there are methods to create the data dir,
destroy it, grab its root, and check wheter the test
data is available. This is used to skip tests where the
data dir could not be setup, think for example
when a fixture is not available or a database to which
we want to connect to is not available.
The implementors of this class are:
* the old MockData (was already there)
* a LiveData class that copies an available data dir
into /target for testing (pure file based, no dbms)
* a LiveDbmsData that adds whatever is necessary to
run a test against a database.
In particular, LiveDbmsData:
* looks up of a test fixture, whose identifier is provided
as a constructor parameter, in the $home/.geoserver
directory. The lookup fails if the property file is
not there, or if the -Dgs.fixtureId=false parameter
was passed to the JVM (to explicitly disable a certain
online test)
* uses the key/value pairs contained in the property file
to make a filtered copy of catalog.xml so that the data
dir points to the local dbms
* uses the same connection parameters to look up a JDBC
datastore that will give it a JDCB Connection.
That connection is used to run a sql script to initialize
the database state.
The sql script location is provided in the constructor.
If you want to see an example of a test actually using
LiveDbmsData look into org.getoserver.wfsv.WFSVTestSupport,
it's a very simple test that does set up the connection to
a db, and then checks that the stuff we expect is actually
in the GeoServer catalog.
Question, comments, requests for changes: fire away!
Cheers
Andrea