org.geotools.test
Class OnlineTestCase

Object
  extended by Assert
      extended by TestCase
          extended by OnlineTestCase
All Implemented Interfaces:
Test

public abstract class OnlineTestCase
extends TestCase

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.

Since:
2.4
Author:
Justin Deoliveira, The Open Planning Project
Module:

Field Summary
protected  Properties fixture
          The test fixture, null if the fixture is not available.
 
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

fixture

protected Properties fixture
The test fixture, null if the fixture is not available.

Constructor Detail

OnlineTestCase

public OnlineTestCase()
Method Detail

setUp

protected void setUp()
              throws Exception
Loads the test fixture for the test case.

The fixture is obtained via getFixtureId().

Overrides:
setUp in class TestCase
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Tear down method for test, calls through to disconnect() if the test is active.

Overrides:
tearDown in class TestCase
Throws:
Exception

connect

protected void connect()
                throws Exception
Connection method, called from 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.

Throws:
Exception - if the connection failed.

disconnect

protected void disconnect()
                   throws Exception
Disconnection method, called from tearDown().

Subclasses should do all cleanup here.

Throws:
Exception - if the disconnection failed.

runTest

protected void runTest()
                throws Throwable
Override which checks if the fixture is available. If not the test is not executed.

Overrides:
runTest in class TestCase
Throws:
Throwable

getFixtureId

protected abstract String getFixtureId()
The fixture id for the test case.

This name is hierachical, similar to a java package name. Example: "postgis.demo_bc".

Returns:
The fixture id.


Copyright © 1996-2009 Geotools. All Rights Reserved.