|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase org.apache.avalon.excalibur.testcase.ExcaliburTestCase
JUnit TestCase for Avalon Components.
This class extends the JUnit TestCase class to setup an environment which makes it possible to easily test Avalon Components. The following methods and instance variables are exposed for convenience testing:
The following test case configuration can be used as a basis for new tests. Detailed are explanations of the configuration elements can be found after the example. The example will log all logger output to the console and to a log file.
<testcase> <annotation> <![CDATA[ <title>{Name of test}</title> <para> {Description of test} The configuration is specified in the file located in <parameter>avalon-excalibur/src/test/{path and name of conf file}.xtext</parameter>. </para> ]]> </annotation> <logkit log-level="INFO"> <factories> <factory type="stream" class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/> <factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/> </factories> <targets> <stream id="console"> <stream>System.out</stream> <format type="avalon"> %7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS} [%30.30{category}] (%{context}): %{message}\n%{throwable} </format> </stream> <file id="log-file"> <filename>TEST-{full test class name}.log</filename> <format type="avalon"> %7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS} [%30.30{category}] (%{context}): %{message}\n%{throwable} </format> </file> </targets> <categories> <category name="test" log-level="INFO"> <log-target id-ref="console"/> <log-target id-ref="log-file"/> </category> <category name="jdbc" log-level="INFO"> <log-target id-ref="console"/> <log-target id-ref="log-file"/> </category> </categories> </logkit> <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" logger="jdbc"> <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:
annotation
, logkit
,
context
, roles
, and components
title
element, naming the test, and a para
element which is used to describe the test.logkit
element takes two optional
attributes:
"lm"
)logkit
element is parsed. This
attribute allows the Log Kit's log priority to be set. This log
level will also become the default for the Role Manager, Component
Manager, and all components if they do not have category
elements declated in the logkit
element.
(Defaults to "INFO")<categories> <category name="test" log-level="INFO"> <log-target id-ref="console"/> <log-target id-ref="log-file"/> <category name="testCheckTotals" log-level="DEBUG"> <log-target id-ref="console"/> <log-target id-ref="log-file"/> </category> </category> </categories>For general information on how to configure the LogKit Manager, please refer to the Log Kit documentation.
components
element. The logger used by the RoleManager
can be configured using a logger
attribute, which defaults
to "rm". By default this logger will have the same log level and
formatting as the LogKit logger. It can be configured by adding a
category
within the logkit
element.logger
attribute, which defaults to "cm". By default this logger will have the
same log level and formatting as the LogKit logger. It can be configured
by adding a category
within the logkit
element.
Field Summary | |
protected ComponentManager |
manager
Deprecated. |
Constructor Summary | |
ExcaliburTestCase(java.lang.String name)
Deprecated. |
Method Summary | |
protected void |
addContext(DefaultContext context)
Deprecated. This method may be overwritten by subclasses to put additional objects into the context programmatically. |
protected LogKitLogger |
getLogEnabledLogger()
Deprecated. Return the logger |
protected Logger |
getLogger()
Deprecated. Return the logger |
protected java.lang.Object |
lookup(java.lang.String key)
Deprecated. |
protected void |
prepare()
Deprecated. Initializes the ComponentLocator The configuration file is determined by the class name plus .xtest appended, all '.' replaced by '/' and loaded as a resource via classpath |
protected void |
prepare(java.io.InputStream testconf)
Deprecated. Initializes the ComponentLocator |
protected void |
release(Component object)
Deprecated. |
void |
run(junit.framework.TestResult result)
Deprecated. Override run so that we can have code that is run once. |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, runBare, runTest, setName, setUp, tearDown, toString |
Methods inherited from class junit.framework.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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected ComponentManager manager
Constructor Detail |
public ExcaliburTestCase(java.lang.String name)
Method Detail |
protected Logger getLogger()
protected LogKitLogger getLogEnabledLogger()
protected void prepare() throws java.lang.Exception
java.lang.Exception
protected final void prepare(java.io.InputStream testconf) throws java.lang.Exception
testconf
- The configuration file is passed as a InputStream
A common way to supply a InputStream is to overwrite the initialize() method
in the sub class, do there whatever is needed to get the right InputStream object
supplying a conformant xtest configuartion and pass it to this initialize method.
the mentioned initialize method is also the place to set a different logging priority
to the member variable m_logPriority.
java.lang.Exception
public final void run(junit.framework.TestResult result)
run
so that we can have code that is run once.
protected void addContext(DefaultContext context)
protected final java.lang.Object lookup(java.lang.String key) throws ComponentException
ComponentException
protected final void release(Component object)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |