|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAssert
TestCase
OnlineTestCase
public abstract class OnlineTestCase
Test support for test cases which require an "online" resource, such as an external server or database.
Online tests work off of a "fixture". A fixture is a properties file which
defines connection parameters for some remote service. Each online test case
must define the id of the fixture is uses with getFixtureId()
.
Fixtures are stored under the users home directory, under the ".geotools
"
directory. In the event that a fixture does not exist, the test case is
aborted.
Online tests connect to remote / online resources. Test cases should do all
connection / disconnection in the connect()
and disconnect()
methods.
The default behaviour of this class is that if connect()
throws an exception, the test
suite is disabled, causing each test to pass without being run. In addition, exceptions thrown by
disconnect()
are ignored. This behaviour allows tests to be robust against transient
outages of online resources, but also means that local software failures in connect()
or
disconnect()
will be silent.
To have exceptions thrown by connect()
and disconnect()
cause tests to fail,
set skip.on.failure=false
in the fixture property file. This restores the
traditional behaviour of unit tests, that is, that exceptions cause unit tests to fail.
modules/library/sample-data (gt-sample-data.jar)
Field Summary | |
---|---|
protected Properties |
fixture
The test fixture, null if the fixture is not available. |
static String |
SKIP_ON_FAILURE_DEFAULT
The default value used for SKIP_ON_FAILURE_KEY if it is not present. |
static String |
SKIP_ON_FAILURE_KEY
The key in the test fixture property file used to set the behaviour of the online test if connect() fails. |
protected boolean |
skipOnFailure
Flag that determines effect of exceptions in connect/disconnect. |
Constructor Summary | |
---|---|
OnlineTestCase()
|
Method Summary | |
---|---|
protected void |
connect()
Connection method, called from setUp() . |
protected void |
disconnect()
Disconnection method, called from tearDown() . |
protected abstract String |
getFixtureId()
The fixture id for the test case. |
protected void |
runTest()
Override which checks if the fixture is available. |
protected void |
setUp()
Loads the test fixture for the test case. |
protected void |
tearDown()
Tear down method for test, calls through to disconnect() if the
test is active. |
Methods inherited from class TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, setName, toString |
Methods inherited from class Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SKIP_ON_FAILURE_KEY
connect()
fails.
public static final String SKIP_ON_FAILURE_DEFAULT
SKIP_ON_FAILURE_KEY
if it is not present.
protected Properties fixture
null
if the fixture is not available.
protected boolean skipOnFailure
Constructor Detail |
---|
public OnlineTestCase()
Method Detail |
---|
protected void setUp() throws Exception
The fixture id is obtained via getFixtureId()
.
setUp
in class TestCase
Exception
protected void tearDown() throws Exception
disconnect()
if the
test is active.
tearDown
in class TestCase
Exception
protected void connect() throws Exception
setUp()
.
Subclasses should do all initialization / connection here. In the event of a connection not being available, this method should throw an exception to abort the test case.
Exception
- if the connection failed.protected void disconnect() throws Exception
tearDown()
.
Subclasses should do all cleanup here.
Exception
- if the disconnection failed.protected void runTest() throws Throwable
runTest
in class TestCase
Throwable
protected abstract String getFixtureId()
This name is hierarchical, similar to a java package name. Example:
"postgis.demo_bc"
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |