Package org.apache.fulcrum.testcontainer
Class BaseUnitTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.apache.fulcrum.testcontainer.BaseUnitTest
-
- All Implemented Interfaces:
junit.framework.Test
public class BaseUnitTest extends junit.framework.TestCase
Base class for unit tests for components. This version doesn't load the container until the first request for a component. This allows the tester to populate the configurationFileName and roleFileName, possible one per test. This class uses JUnit 3.- Version:
- $Id$
- Author:
- Eric Pugh, Quinton McCombs
- See Also:
BaseUnit4Test
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_APP_ROOT
Key used in the context for defining the application rootstatic String
CONTAINER_ECM
static String
CONTAINER_YAAFI
static String
containerType
Pick the default container to be Yaafistatic int
defaultLogLevel
Use INFO for ConsoleLogger
-
Constructor Summary
Constructors Constructor Description BaseUnitTest(String testName)
Constructor for test.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getConfigurationFileName()
Gets the configuration file name for the container should use for this test.protected String
getParameterFileName()
Gets the parameter file name for the container should use for this test.protected String
getRoleFileName()
Gets the role file name for the container should use for this test.protected Object
lookup(String roleName)
Returns an instance of the named component.protected void
release(Object component)
Releases the component.protected Object
resolve(String roleName)
Helper method for converting to and from Merlin Unit TestCase.protected void
setConfigurationFileName(String configurationFileName)
Gets the configuration file name for the container should use for this test.protected void
setLogLevel(int logLevel)
Set the console logger levelprotected void
setRoleFileName(String roleFileName)
Override the role file name for the container should use for this test.protected void
tearDown()
Clean up after each test is run.-
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, toString
-
-
-
-
Field Detail
-
CONTAINER_ECM
public static final String CONTAINER_ECM
- See Also:
- Constant Field Values
-
CONTAINER_YAAFI
public static final String CONTAINER_YAAFI
- See Also:
- Constant Field Values
-
COMPONENT_APP_ROOT
public static final String COMPONENT_APP_ROOT
Key used in the context for defining the application root- See Also:
- Constant Field Values
-
containerType
public static final String containerType
Pick the default container to be Yaafi- See Also:
- Constant Field Values
-
defaultLogLevel
public static final int defaultLogLevel
Use INFO for ConsoleLogger- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseUnitTest
public BaseUnitTest(String testName)
Constructor for test.- Parameters:
testName
- name of the test being executed
-
-
Method Detail
-
setConfigurationFileName
protected void setConfigurationFileName(String configurationFileName)
Gets the configuration file name for the container should use for this test. By default it is src/test/TestComponentConfig.- Parameters:
configurationFileName
- the location of the config file
-
setRoleFileName
protected void setRoleFileName(String roleFileName)
Override the role file name for the container should use for this test. By default it is src/test/TestRoleConfig.- Parameters:
roleFileName
- location of the role file
-
setLogLevel
protected void setLogLevel(int logLevel)
Set the console logger level- Parameters:
logLevel
- set valid logging level- See Also:
for debugging levels
-
tearDown
protected void tearDown()
Clean up after each test is run.- Overrides:
tearDown
in classjunit.framework.TestCase
-
getConfigurationFileName
protected String getConfigurationFileName()
Gets the configuration file name for the container should use for this test.- Returns:
- The filename of the configuration file
-
getRoleFileName
protected String getRoleFileName()
Gets the role file name for the container should use for this test.- Returns:
- The filename of the role configuration file
-
getParameterFileName
protected String getParameterFileName()
Gets the parameter file name for the container should use for this test.- Returns:
- The filename of the role configuration file
-
lookup
protected Object lookup(String roleName) throws org.apache.avalon.framework.component.ComponentException
Returns an instance of the named component. This method will also start the container if it has not been started already- Parameters:
roleName
- Name of the role the component fills.- Returns:
- instance of the component
- Throws:
org.apache.avalon.framework.component.ComponentException
- generic exception
-
resolve
protected Object resolve(String roleName) throws org.apache.avalon.framework.component.ComponentException
Helper method for converting to and from Merlin Unit TestCase.- Parameters:
roleName
- the role name to resolve- Returns:
- the component matching the role
- Throws:
org.apache.avalon.framework.component.ComponentException
- generic exception
-
-