This component is really just a test container for testing the other components. This container is not meant to be used in a production environment.
In order to save you a little coding, a base class has been provided for your test cases.
Simply extend org.apache.fulcrum.testcontainer.BaseUnitTest and you are ready
to go.
In order to save you a little coding, a base class has been provided for your test
cases. Simply extend org.apache.fulcrum.testcontainer.BaseUnitTest and you
are ready to go.
The lookup and tearDown methods of BaseUnitTest
will handle the lifecycle of the container for you. Each test will have a freshly
initialized container in which to run.
To lookup and release components, call the lookup and release
methods of BaseUnitTest.
By default, all tests will use the configuration files
TestComponentConfig.xml and TestRoleConfig.xml located in the
src/test directory. If you want to override that behavior for ALL your
tests, you can override the getConfigurationFileName() and/or
getRoleFileName() methods.
If you are testing multiple config or role files, then just call
setConfigurationFileName() or setRoleFileName() before doing
your first lookup. The string you pass in should be prefixed from the directory the JVM is
running in (e.g. src/test/YOUR_CONFIG.xml).
If you need more control over the container itself for your test, just don't extend the
unit test provided with the container. Instead, embed the container directly in your test
case. See the java docs for org.apache.fulcrum.testcontainer.Container for
more information.
There are two ways of configuring your components. One is the traditional TestComponentConfig.xml and TestRoleConfig.xml files described below. Or, one that integrates the two, shown at the bottom.
First, here is the role configuration.
<role
name="org.apache.fulcrum.crypto.CryptoService"
shorthand="crypto"
default-class="org.apache.fulcrum.crypto.DefaultCryptoService"/>
Now comes the basic configuration of the component. Here will will configure the various encryption providers
<crypto>
<algorithm>
<unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix>
<clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear>
<java>org.apache.fulcrum.crypto.provider.JavaCrypt</java>
<oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava>
</algorithm>
</crypto>
Or, the integrated roles and components file:
<my-system>
<component
role="org.apache.fulcrum.testcontainer.SimpleComponent"
class="org.apache.fulcrum.testcontainer.AlternativeComponentImpl">
</component>
</my-system>