blob: 3437c9253634cf621c974a9274fdef814822c2c8 [file] [log] [blame]
<?xml version="1.0"?>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
<title>Test Container</title>
<author email="">Quinton McCombs</author>
<author email="">Eric Pugh</author>
<section name="Overview">
<p> 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. </p>
<subsection name="JUnit Integration">
<p>Find more information about <a href="">migration to Junit5 here</a>. JUnit 3 and JUnit 4 ((<code>org.apache.fulcrum.testcontainer.BaseUnitTest</code>, <code>org.apache.fulcrum.testcontainer.BaseUnit4Test</code>) are still supported.
IDEs (Eclipse/IntelliJ 2018.x) and Surefire Plugin 3.x should be able to handle all flavors. Running a JUnit 4 test in older IDE versions may require a test class annotation (@RunWith(JUnitPlatform.class)).</p>
<section name="Usage">
<subsection name="Extending the test case">
<p> In order to save you a little coding, a base class has been provided for your test cases.
Simply extend <code>org.apache.fulcrum.testcontainer.BaseUnit5Test</code> for JUnit 5 and you are ready to go!</p>
<p> The <code>lookup</code> and <code>tearDown</code> methods of <code>BaseUnit5Test</code>
will handle the lifecycle of the container for you. Each test will have a freshly
initialized container in which to run.
<p> To lookup and release components, call the <code>lookup</code> and <code>release</code>
methods of <code>BaseUnit5Test</code>.
<p> By default, all tests will use the configuration files
<code>TestComponentConfig.xml</code> and <code>TestRoleConfig.xml</code> located in the
<code>src/test</code> directory. If you want to override that behavior for ALL your
tests, you can override the <code>getConfigurationFileName()</code> and/or
<code>getRoleFileName()</code> methods.
<p> If you are testing multiple config or role files, then just call
<code>setConfigurationFileName()</code> or <code>setRoleFileName()</code> 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).
<p> You can choose between two container implementations, the ECM and Fulcrum YAAFI. For this
just assign one of the values BaseUnit5Test.CONTAINER_ECM or BaseUnit5Test.CONTAINER_YAAFI to
the static variable BaseUnit5Test.containerType before doing the first lookup. The default
container is Fulcrum YAAFI.
<subsection name="Using the container directly">
<p> 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 <code>org.apache.fulcrum.testcontainer.Container</code> for
more information.
<subsection name="Configuring the Components">
<p> There are two ways of configuring your components. One is the traditional
TestComponentConfig.xml and TestRoleConfig.xml files described below. Or, for the ECMContainer
one is available that integrates the two, shown at the bottom.
<p> First, here is the role configuration example.</p>
<p> Now comes the basic configuration of the component. Here will will configure the various
encryption providers.
<p>When using the ECM container you can choose to use an integrated roles and components file
like follows. Note that this file format is not supported with Fulcrum YAAFI and will cause
an Exception to be thrown.