JUnit TestCase for Cocoon Components.
This class extends the JUnit TestCase class to setup an environment which
makes it possible to easily test Cocoon Components. The following methods
and instance variables are exposed for convenience testing:
- getManager()
-
This instance variable contains an initialized service manager which
can be used to lookup components configured in the test configuration
file. (see below)
- getLogger()
-
This method returns a logger for this test case. By default this
logger logs with log level DEBUG.
The following test case configuration can be used as a basis for new tests.
Detailed explanations of the configuration elements can be found after
the example.
<testcase>
<context>
<entry name="foo" value="bar"/>
<entry name="baz" class="my.context.Class"/>
</context>
<roles>
<role name="org.apache.avalon.excalibur.datasource.DataSourceComponentSelector"
shorthand="datasources"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
<hint shorthand="jdbc" class="org.apache.avalon.excalibur.datasource.JdbcDataSource"/>
</role>
</roles>
<components>
<datasources>
<jdbc name="personell">
<pool-controller min="5" max="10"/>
<jdbc name="personnel"/>
<dburl>jdbc:odbc:test</dburl>
<user>test</user>
<password>test</password>
<driver>sun.jdbc.odbc.JdbcOdbcDriver</driver>
</jdbc>
</datasources>
</components>
</testcase>
Element Explanation:
- testcase
- Defines a test case configuration. Must contain one each of the
following elements:
annotation ,
context , roles , and components
.
- context
- Allows context properties to be set in the context passed to any
Contextualizable components.
- roles
- Roles configuration for the components configured in the
components element.
- components
- Used to configure any Components used by the test cases.
version: $Id: $ |