JBoss Portal SVN: r8500 - in modules/test/trunk: build and 61 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-09-30 18:38:06 -0400 (Sun, 30 Sep 2007)
New Revision: 8500
Added:
modules/test/trunk/build/ide/intellij/idea60/modules/unit/
modules/test/trunk/build/ide/intellij/idea60/modules/unit/unit.iml
modules/test/trunk/unit/
modules/test/trunk/unit/build.bat
modules/test/trunk/unit/build.sh
modules/test/trunk/unit/build.xml
modules/test/trunk/unit/src/
modules/test/trunk/unit/src/main/
modules/test/trunk/unit/src/main/org/
modules/test/trunk/unit/src/main/org/jboss/
modules/test/trunk/unit/src/main/org/jboss/test/
modules/test/trunk/unit/src/main/org/jboss/test/unit/
modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/api/
modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/
modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassWithoutAnnotations.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassHavingSamePropertyParameterAndMethodArgumentParameter.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor3.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor4.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutAnnotations.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor3.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor4.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence01.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence02.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence03.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence04.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence05.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence06.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence07.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence08.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence09.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence10.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence11.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate01.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate02.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate03.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate04.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate07.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter01.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter02.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter05.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter06.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter07.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter09.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter10.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter11.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter12.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter13.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest5.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest6.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest7.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest8.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest9.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOAssert.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations3.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations4.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter1.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter2.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter3.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter4.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter5.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter6.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter7.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter8.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/ParametrizationTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerEventBroadcasterSupportTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerLifeCycleFilterTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/
modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java
modules/test/trunk/unit/src/main/org/jboss/unit/FailureType.java
modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/
modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Create.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/DefaultValues.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Description.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Destroy.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Parameter.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Test.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/
modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/
modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverCommand.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/command/
modules/test/trunk/unit/src/main/org/jboss/unit/driver/command/StartTestCommand.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/
modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/EndTestResponse.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/FailureResponse.java
modules/test/trunk/unit/src/main/org/jboss/unit/info/
modules/test/trunk/unit/src/main/org/jboss/unit/info/ParameterInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/info/TestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/info/TestSuiteInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/Parametrization.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventBroadcaster.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventListener.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndRunnerEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndTestEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartRunnerEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerEventBroadcasterSupport.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerLifeCycleFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/filter/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/filter/NullFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/BuilderException.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/Constants.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParameterValueDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParametersDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestCaseDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java
modules/test/trunk/unit/src/main/org/jboss/unit/util/
modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
modules/test/trunk/unit/src/main/org/jboss/unit/util/XMLTools.java
modules/test/trunk/unit/src/resources/
modules/test/trunk/unit/src/resources/jboss-unit-jar/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit.dtd
modules/test/trunk/unit/src/resources/test/
modules/test/trunk/unit/src/resources/test/org/
modules/test/trunk/unit/src/resources/test/org/jboss/
modules/test/trunk/unit/src/resources/test/org/jboss/test/
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
Removed:
modules/test/trunk/tools/lib/cargo-core-uberjar-0.8.jar
Modified:
modules/test/trunk/build/build-thirdparty.xml
modules/test/trunk/build/ide/intellij/idea60/modules/test/test.iml
modules/test/trunk/testsuite/build.xml
modules/test/trunk/tools/etc/buildfragments/buildmagic.ent
Log:
initial commit for unit test framework
Modified: modules/test/trunk/build/build-thirdparty.xml
===================================================================
--- modules/test/trunk/build/build-thirdparty.xml 2007-09-28 13:08:27 UTC (rev 8499)
+++ modules/test/trunk/build/build-thirdparty.xml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -49,7 +49,8 @@
<componentref name="jboss-portal/modules/common" version="1.0.0-SNAPSHOT"/>
- <componentref name="codehaus/cargo" version="0.9"/>
+ <componentref name="codehaus/cargo" version="0.9-portal"/>
+ <componentref name="testng" version="5.5"/>
<componentref name="jbossas/core-libs" version="4.0.4.GA"/>
<componentref name="hibernate" version="3.2.0.CR2"/>
Modified: modules/test/trunk/build/ide/intellij/idea60/modules/test/test.iml
===================================================================
--- modules/test/trunk/build/ide/intellij/idea60/modules/test/test.iml 2007-09-28 13:08:27 UTC (rev 8499)
+++ modules/test/trunk/build/ide/intellij/idea60/modules/test/test.iml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -334,6 +334,15 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/testng/lib/testng-5.5-jdk15.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Added: modules/test/trunk/build/ide/intellij/idea60/modules/unit/unit.iml
===================================================================
--- modules/test/trunk/build/ide/intellij/idea60/modules/unit/unit.iml (rev 0)
+++ modules/test/trunk/build/ide/intellij/idea60/modules/unit/unit.iml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../unit">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../unit/src/main" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Modified: modules/test/trunk/testsuite/build.xml
===================================================================
--- modules/test/trunk/testsuite/build.xml 2007-09-28 13:08:27 UTC (rev 8499)
+++ modules/test/trunk/testsuite/build.xml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -46,7 +46,6 @@
<path id="portal.task.classpath">
<pathelement location="${project.tools}/lib/ant.jar"/>
<pathelement location="${project.tools}/lib/explode.jar"/>
- <pathelement location="${project.tools}/lib/cargo-core-uberjar-0.8.jar"/>
</path>
<taskdef
Modified: modules/test/trunk/tools/etc/buildfragments/buildmagic.ent
===================================================================
--- modules/test/trunk/tools/etc/buildfragments/buildmagic.ent 2007-09-28 13:08:27 UTC (rev 8499)
+++ modules/test/trunk/tools/etc/buildfragments/buildmagic.ent 2007-09-30 22:38:06 UTC (rev 8500)
@@ -1111,7 +1111,6 @@
<path id="portal.task.classpath">
<pathelement location="${project.tools}/lib/ant.jar"/>
<pathelement location="${project.tools}/lib/explode.jar"/>
- <pathelement location="${project.tools}/lib/cargo-core-uberjar-0.8.jar"/>
</path>
<taskdef
name="deploy"
Deleted: modules/test/trunk/tools/lib/cargo-core-uberjar-0.8.jar
===================================================================
(Binary files differ)
Added: modules/test/trunk/unit/build.bat
===================================================================
--- modules/test/trunk/unit/build.bat (rev 0)
+++ modules/test/trunk/unit/build.bat 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 1829 2006-03-05 13:20:08Z julien $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: modules/test/trunk/unit/build.bat
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/unit/build.sh
===================================================================
--- modules/test/trunk/unit/build.sh (rev 0)
+++ modules/test/trunk/unit/build.sh 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 1829 2006-03-05 13:20:08Z julien $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: modules/test/trunk/unit/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/unit/build.xml
===================================================================
--- modules/test/trunk/unit/build.xml (rev 0)
+++ modules/test/trunk/unit/build.xml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM "../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!-- $Id: build.xml 7954 2007-08-16 14:51:00Z julien(a)jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and |-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable" depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+ <path id="library.classpath">
+ </path>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="true"/>
+ <property name="javadoc.protected" value="false"/>
+
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="compile">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/jboss-unit-lib.jar">
+ <fileset dir="${build.classes}">
+ <exclude name="org/jboss/test/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/jboss-unit-jar"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/jboss-unit-test.jar">
+ <fileset dir="${build.classes}">
+ <exclude name="org/jboss/unit/**"/>
+ </fileset>
+ </jar>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <target name="test" depends="init">
+
+ <java classname="org.jboss.test.unit.AllTests" fork="true">
+ <classpath>
+ <path location="${build.lib}/jboss-unit-lib.jar"/>
+ <path location="${build.lib}/jboss-unit-test.jar"/>
+ <path location="${build.resources}/test"/>
+ </classpath>
+ </java>
+
+ </target>
+
+</project>
Property changes on: modules/test/trunk/unit/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit;
+
+import org.jboss.test.unit.api.AssertTests;
+import org.jboss.test.unit.blah.BlahTests;
+import org.jboss.test.unit.pojo.POJOTestDriverTests;
+import org.jboss.test.unit.runner.CompositeTestRunnerTests;
+import org.jboss.test.unit.runner.ParametrizationTests;
+import org.jboss.test.unit.runner.event.TestRunnerEventBroadcasterSupportTests;
+import org.jboss.test.unit.runner.event.TestRunnerLifeCycleFilterTests;
+import org.jboss.test.unit.runner.model.ModelTests;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AllTests
+{
+
+ public static void main(String[] args) throws Exception
+ {
+ AssertTests.main(args);
+ POJOTestDriverTests.main(args);
+ CompositeTestRunnerTests.main(args);
+
+ //
+ TestRunnerLifeCycleFilterTests.main(args);
+ TestRunnerEventBroadcasterSupportTests.main(args);
+ ModelTests.main(args);
+ ParametrizationTests.main(args);
+
+ //
+ BlahTests.main(args);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/PrintListener.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit;
+
+import org.jboss.unit.Failure;
+import org.jboss.unit.TestId;
+import org.jboss.unit.runner.TestResult;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.EndTestEvent;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.event.StartTestEvent;
+import org.jboss.unit.runner.results.TestFailure;
+import org.jboss.unit.runner.results.TestSuccess;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PrintListener implements TestRunnerEventListener
+{
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ if (event instanceof StartRunnerEvent)
+ {
+ System.out.println("--- Start ---");
+ }
+ else if (event instanceof EndRunnerEvent)
+ {
+ System.out.println("--- End ---");
+ }
+ else if (event instanceof RunnerFailureEvent)
+ {
+ RunnerFailureEvent failure = (RunnerFailureEvent)event;
+ System.out.println("Runner failure: " + failure.getLevel() + " " + failure.getMessage());
+ }
+ else if (event instanceof StartTestEvent)
+ {
+ StartTestEvent startTestEvent = (StartTestEvent)event;
+ System.out.println("Starting id=" + startTestEvent.getTestId() + " name=" + startTestEvent.getTestInfo().getName() + " description=" + startTestEvent.getTestInfo().getDescription());
+ }
+ else if (event instanceof EndTestEvent)
+ {
+ EndTestEvent endTestEvent = (EndTestEvent)event;
+ TestId testId = endTestEvent.getTestId();
+ TestResult testResult = endTestEvent.getTestResult();
+ if (testResult instanceof TestSuccess)
+ {
+ System.out.println("Test id=" + testId + " is successful");
+ }
+ else if (testResult instanceof TestFailure)
+ {
+ TestFailure testFailure = (TestFailure)testResult;
+ Failure failure = testFailure.getFailure();
+ System.out.println("Test id=" + testId + " " + failure.getLevel() + " failed " + failure.getMessage());
+ if (failure.getCause() != null)
+ {
+ failure.getCause().printStackTrace();
+ }
+ }
+ }
+
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/api/AssertTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,330 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.api;
+
+import org.jboss.unit.api.Assert;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AssertTests
+{
+
+ /** . */
+ private final static Object o1 = new Object();
+
+ /** . */
+ private final static Object o2 = new Object();
+
+ public static void main(String[] args)
+ {
+ testObjectEquals();
+ testObjectNotEquals();
+ testObjectSame();
+ testObjectNotSame();
+ testFail();
+ testInstanceOf();
+ }
+
+ public static void testInstanceOf()
+ {
+ try
+ {
+ Assert.assertInstanceOf(null, Object.class);
+ throw new RuntimeException();
+ }
+ catch (AssertionError e)
+ {
+ }
+
+ //
+ try
+ {
+ Assert.assertInstanceOf(new Object(), null);
+ throw new RuntimeException();
+ }
+ catch (AssertionError e)
+ {
+ }
+
+ //
+ A a = new A();
+ Object a_o = Assert.assertInstanceOf(a, Object.class);
+ if (a != a_o)
+ {
+ throw new RuntimeException();
+ }
+ A a_a = Assert.assertInstanceOf(a, A.class);
+ if (a != a_a)
+ {
+ throw new RuntimeException();
+ }
+ try
+ {
+ Assert.assertInstanceOf(a, B.class);
+ throw new RuntimeException();
+ }
+ catch (AssertionError e)
+ {
+ }
+ try
+ {
+ Assert.assertInstanceOf(a, C.class);
+ throw new RuntimeException();
+ }
+ catch (AssertionError e)
+ {
+ }
+ try
+ {
+ Assert.assertInstanceOf(a, D.class);
+ throw new RuntimeException();
+ }
+ catch (AssertionError e)
+ {
+ }
+
+ //
+ D d = new D();
+ Object d_o = Assert.assertInstanceOf(d, Object.class);
+ if (d != d_o)
+ {
+ throw new RuntimeException();
+ }
+ A d_a = Assert.assertInstanceOf(d, A.class);
+ if (d != d_a)
+ {
+ throw new RuntimeException();
+ }
+ B d_b = Assert.assertInstanceOf(d, B.class);
+ if (d != d_b)
+ {
+ throw new RuntimeException();
+ }
+ C d_c = Assert.assertInstanceOf(d, C.class);
+ if (d != d_c)
+ {
+ throw new RuntimeException();
+ }
+ D d_d = Assert.assertInstanceOf(d, D.class);
+ if (d != d_d)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ private static class A
+ {
+ }
+
+ private static interface B
+ {
+ }
+
+ private static interface C extends B
+ {
+ }
+
+ private static class D extends A implements C
+ {
+ }
+
+ public static void testObjectEquals()
+ {
+ try
+ {
+ Assert.assertEquals(o1, null);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertEquals(null, o1);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertEquals(o1, o2);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ Assert.assertEquals(o1, o1);
+ Assert.assertEquals("foo", "foo");
+ Assert.assertEquals((Object)null, null);
+ }
+
+ public static void testObjectNotEquals()
+ {
+ Assert.assertNotEquals(o1, null);
+ Assert.assertNotEquals(null, o1);
+ Assert.assertNotEquals(o1, o2);
+ try
+ {
+ Assert.assertNotEquals(o1, o1);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertNotEquals("foo", "foo");
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertNotEquals((Object)null, null);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ }
+
+ public static void testObjectSame()
+ {
+ try
+ {
+ Assert.assertSame(o1, null);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertSame(null, o1);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertSame(o1, o2);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertSame(new String("foo"), new String("foo"));
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ Assert.assertSame(o1, o1);
+ Assert.assertSame(null, null);
+ }
+
+ public static void testObjectNotSame()
+ {
+ Assert.assertNotSame(o1, null);
+ Assert.assertNotSame(null, o1);
+ Assert.assertNotSame(o1, o2);
+ Assert.assertNotSame(new String("foo"), new String("foo"));
+ try
+ {
+ Assert.assertNotSame(o1, o1);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.assertNotSame(null, null);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ }
+
+ public static void testFail()
+ {
+ try
+ {
+ Assert.fail();
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ }
+ try
+ {
+ Assert.fail("foo");
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ if (!"foo".equals(expected.getMessage()))
+ {
+ throw new RuntimeException();
+ }
+ }
+ Exception e1 = new Exception();
+ try
+ {
+ Assert.fail(e1);
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ if (e1 != expected.getCause())
+ {
+ throw new RuntimeException();
+ }
+ }
+ Exception e2 = new Exception();
+ try
+ {
+ Assert.fail(e2, "foo");
+ throw new RuntimeException();
+ }
+ catch (AssertionError expected)
+ {
+ if (e2 != expected.getCause())
+ {
+ throw new RuntimeException();
+ }
+ if (!"foo".equals(expected.getMessage()))
+ {
+ throw new RuntimeException();
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.blah;
+
+import org.jboss.test.unit.PrintListener;
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.model.ModelBuilder;
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.xml.sax.InputSource;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BlahTests
+{
+
+ public static void main(String[] args) throws Exception
+ {
+
+ InputStream in = BlahTests.class.getResourceAsStream("f1.xml");
+ InputSource source = new InputSource(in);
+ ModelBuilder builder = new ModelBuilder(source);
+ TestSuiteDef suite = builder.build();
+
+ TestRunner runner = suite.createRunner();
+
+ runner.addListener(new PrintListener());
+
+ runner.run();
+
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.blah;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestedClass1
+{
+
+ @Test
+ public void testFoo()
+ {
+ }
+
+ @Test
+ public void testBlah()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/TestedClass2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.blah;
+
+import static org.jboss.unit.api.Assert.assertEquals;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestedClass2
+{
+
+ private String foo;
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ this.foo = foo;
+ }
+
+ @Test
+ public void testBlah()
+ {
+ assertEquals("foo", foo);
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test
+public abstract class AbstractClassAnnotatedWithTest1
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassAnnotatedWithTest2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test(name="foo")
+public abstract class AbstractClassAnnotatedWithTest2
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassWithoutAnnotations.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassWithoutAnnotations.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/AbstractClassWithoutAnnotations.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test
+public abstract class AbstractClassWithoutAnnotations
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test
+public class ClassAnnotatedWithTest1
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassAnnotatedWithTest2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test(name="foo")
+public class ClassAnnotatedWithTest2
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassHavingSamePropertyParameterAndMethodArgumentParameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassHavingSamePropertyParameterAndMethodArgumentParameter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassHavingSamePropertyParameterAndMethodArgumentParameter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassHavingSamePropertyParameterAndMethodArgumentParameter
+{
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = foo;
+ }
+
+ @Test
+ public void testFoo(@Parameter(name="foo") String foo)
+ {
+ if (POJOAssert.buffer1 != null && POJOAssert.buffer1.equals(foo))
+ {
+ POJOAssert.call(ClassHavingSamePropertyParameterAndMethodArgumentParameter.class, Collections.singletonMap("foo", POJOAssert.buffer1));
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithFailingConstructor1
+{
+ public ClassWithFailingConstructor1()
+ {
+ throw new RuntimeException();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass());
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithFailingConstructor2
+{
+ public ClassWithFailingConstructor2()
+ {
+ throw new Error();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass());
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor3.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithFailingConstructor3
+{
+ public ClassWithFailingConstructor3() throws Exception
+ {
+ throw new Exception();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass());
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor4.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor4.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithFailingConstructor4.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithFailingConstructor4
+{
+ public ClassWithFailingConstructor4() throws Exception
+ {
+ Assert.fail();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass());
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutAnnotations.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutAnnotations.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutAnnotations.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@Test
+public class ClassWithoutAnnotations
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithoutDefaultConstructor1
+{
+
+ private ClassWithoutDefaultConstructor1()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithoutDefaultConstructor2
+{
+
+ protected ClassWithoutDefaultConstructor2()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor3.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithoutDefaultConstructor3
+{
+
+ ClassWithoutDefaultConstructor3()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor4.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor4.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/ClassWithoutDefaultConstructor4.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithoutDefaultConstructor4
+{
+
+ public ClassWithoutDefaultConstructor4(String foo)
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence01.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence01.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence01.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence01
+{
+
+ public LifeCycleSequence01()
+ {
+ throw new RuntimeException();
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 = "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence02.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence02.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence02.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence02
+{
+
+ public LifeCycleSequence02()
+ {
+ Assert.fail();
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 = "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence03.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence03.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence03.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence03
+{
+
+ public LifeCycleSequence03()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ throw new RuntimeException();
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence04.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence04.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence04.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence04
+{
+
+ public LifeCycleSequence04()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ Assert.fail();
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence05.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence05.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence05.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence05
+{
+
+ public LifeCycleSequence05()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ }
+
+ @Create
+ public void create()
+ {
+ throw new RuntimeException();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence06.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence06.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence06.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence06
+{
+
+ public LifeCycleSequence06()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ }
+
+ @Create
+ public void create()
+ {
+ Assert.fail();
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.buffer1 = "W";
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence07.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence07.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence07.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence07
+{
+
+ public LifeCycleSequence07()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 += "R";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ throw new RuntimeException();
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence08.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence08.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence08.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence08
+{
+
+ public LifeCycleSequence08()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 += "R";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ Assert.fail();
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence09.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence09.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence09.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence09
+{
+
+ public LifeCycleSequence09()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ POJOAssert.buffer2 = foo;
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 += "R";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass(), Collections.singletonMap("foo", POJOAssert.buffer2));
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence10.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence10.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence10.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence10
+{
+
+ public LifeCycleSequence10()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ POJOAssert.buffer2 = foo;
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 += "R";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass(), Collections.singletonMap("foo", POJOAssert.buffer2));
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ throw new RuntimeException();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence11.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence11.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/LifeCycleSequence11.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifeCycleSequence11
+{
+
+ public LifeCycleSequence11()
+ {
+ POJOAssert.buffer1 = "C";
+ }
+
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 += "S";
+ POJOAssert.buffer2 = foo;
+ }
+
+ @Create
+ public void create()
+ {
+ POJOAssert.buffer1 += "R";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(getClass(), Collections.singletonMap("foo", POJOAssert.buffer2));
+ }
+
+ @Destroy
+ public void destroy()
+ {
+ POJOAssert.buffer1 += "D";
+ Assert.fail();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate01.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate01.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate01.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate01
+{
+
+ @Create
+ public void foo()
+ {
+ POJOAssert.buffer1 = "foo";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ if ("foo".equals(POJOAssert.buffer1))
+ {
+ POJOAssert.call(MethodAnnotatedWithCreate01.class);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate02.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate02.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate02.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate02
+{
+
+ @Create
+ private void foo()
+ {
+ POJOAssert.buffer1 = "foo";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ if (POJOAssert.buffer1 == null)
+ {
+ POJOAssert.call(MethodAnnotatedWithCreate02.class);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate03.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate03.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate03.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate03
+{
+
+ @Create
+ void foo()
+ {
+ POJOAssert.buffer1 = "foo";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ if (POJOAssert.buffer1 == null)
+ {
+ POJOAssert.call(MethodAnnotatedWithCreate03.class);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate04.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate04.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate04.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate04
+{
+
+ @Create
+ protected void foo()
+ {
+ POJOAssert.buffer1 = "foo";
+ }
+
+ @Test
+ public void testFoo()
+ {
+ if (POJOAssert.buffer1 == null)
+ {
+ POJOAssert.call(MethodAnnotatedWithCreate04.class);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate05.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate05
+{
+
+ @Create
+ public static void foo()
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate06.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate06
+{
+
+ @Create
+ public void foo(String s)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate07.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate07.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithCreate07.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithCreate07
+{
+
+ @Create
+ public int foo()
+ {
+ return 0;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter01.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter01.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter01.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter01
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter02.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter02.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter02.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter02
+{
+ @Parameter(name="bar")
+ public void setFoo(String foo)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter05.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter05.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter05.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter05
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = foo;
+ }
+
+ @Test
+ public void test()
+ {
+ POJOAssert.call(MethodAnnotatedWithParameter05.class, Collections.singletonMap("foo", POJOAssert.buffer1));
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter06.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter06.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter06.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter06
+{
+ @Parameter(name="bar")
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = foo;
+ }
+
+ @Test
+ public void test()
+ {
+ POJOAssert.call(MethodAnnotatedWithParameter06.class, Collections.singletonMap("bar", POJOAssert.buffer1));
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter07.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter07.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter07.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter07
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = foo;
+ }
+
+ @Test
+ public void test()
+ {
+ POJOAssert.call(MethodAnnotatedWithParameter07.class, Collections.singletonMap("foo", POJOAssert.buffer1));
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter09.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter09.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter09.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter09
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ POJOAssert.buffer1 = foo;
+ }
+
+ @Parameter(name="foo")
+ public void setBar(String bar)
+ {
+ POJOAssert.buffer2 = bar;
+ }
+
+ @Test
+ public void test()
+ {
+ if (POJOAssert.buffer1 != null && POJOAssert.buffer1.equals(POJOAssert.buffer2))
+ {
+ POJOAssert.call(MethodAnnotatedWithParameter09.class, Collections.singletonMap("foo", POJOAssert.buffer1));
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter10.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter10.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter10.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter10
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ throw new RuntimeException();
+ }
+
+ @Test
+ public void test()
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter11.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter11.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter11.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter11
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ throw new Error();
+ }
+
+ @Test
+ public void test()
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter12.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter12.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter12.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter12
+{
+ @Parameter
+ public void setFoo(String foo) throws Exception
+ {
+ throw new Exception();
+ }
+
+ @Test
+ public void test()
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter13.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter13.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithParameter13.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithParameter13
+{
+ @Parameter
+ public void setFoo(String foo)
+ {
+ Assert.fail();
+ }
+
+ @Test
+ public void test()
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest1
+{
+
+ @Test
+ public void testFoo()
+ {
+ POJOAssert.call(MethodAnnotatedWithTest1.class);
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest2
+{
+
+ @Test(name="testBar")
+ public void testFoo()
+ {
+ POJOAssert.call(MethodAnnotatedWithTest2.class);
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest5.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest5.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest5.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest5
+{
+
+ @Test
+ public static void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest6.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest6.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest6.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest6
+{
+
+ @Test
+ void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest7.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest7.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest7.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest7
+{
+
+ @Test
+ protected void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest8.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest8.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest8.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest8
+{
+
+ @Test
+ private void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest9.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest9.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/MethodAnnotatedWithTest9.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodAnnotatedWithTest9
+{
+
+ @Test
+ public void testFoo()
+ {
+ }
+
+ @Test(name="testFoo")
+ public void testBar()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOAssert.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOAssert.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOAssert.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import static org.jboss.unit.api.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOAssert
+{
+
+ /** . */
+ private static Class callerClass;
+
+ /** . */
+ private static Map<String,? extends Object> callerArgs;
+
+ /** . */
+ public static String buffer1;
+
+ /** . */
+ public static Object buffer2;
+
+ /** . */
+ public static int counter;
+
+ public static void clear()
+ {
+ callerClass = null;
+ callerArgs = null;
+ buffer1 = null;
+ buffer2 = null;
+ }
+
+ public static void call(Class clazz)
+ {
+ call(clazz, new HashMap<String, Object>());
+ }
+
+ public static void call(Class clazz, Map<String,? extends Object> args)
+ {
+ if (callerClass != null)
+ {
+ fail();
+ }
+ callerClass = clazz;
+ callerArgs = args;
+ }
+
+ public static void assertWasCalled(Class clazz)
+ {
+ assertWasCalled(clazz, new HashMap<String, Object>());
+ }
+
+ public static void assertWasCalled(Class clazz, Map<String,? extends Object> args)
+ {
+ assertEquals(clazz, callerClass);
+ assertEquals(callerArgs, args);
+ }
+
+ public static void assertWasNotCalled()
+ {
+ assertNull(callerClass);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/POJOTestDriverTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,406 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.Failure;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.TestId;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.command.StartTestCommand;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.info.ParameterInfo;
+import org.jboss.unit.info.TestCaseInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestDriverTests
+{
+
+ public static void main(String[] args)
+ {
+ testAbstractClassWithoutAnnotations();
+ testClassWithoutAnnotations();
+ testAbstractClassAnnotatedWithTest();
+ testClassAnnotatedWithTest();
+
+ //
+ testMethodAnnotatedWithTest();
+ testTestMethodHavingArgumentsAnnotatedWithParameter();
+ testTestMethodAnnotatedWithConflictingAnnotations();
+ testMethodAnnotatedWithParameter();
+ testMethodAnnotatedWithCreate();
+
+ //
+ testClassHavingSamePropertyParameterAndMethodArgumentParameter();
+
+ //
+ testClassWithoutDefaultConstructor();
+ testClassWithFailingConstructor();
+
+ //
+ testLifeCycleSequence();
+ }
+
+ private static void testLifeCycleSequence()
+ {
+ testLifeCycleSequence(LifeCycleSequence01.class, InvokeResult.NOT_CALLED_ERROR, null);
+ testLifeCycleSequence(LifeCycleSequence02.class, InvokeResult.NOT_CALLED_FAIL, null);
+ testLifeCycleSequence(LifeCycleSequence03.class, InvokeResult.NOT_CALLED_ERROR, "C");
+ testLifeCycleSequence(LifeCycleSequence04.class, InvokeResult.NOT_CALLED_FAIL, "C");
+ testLifeCycleSequence(LifeCycleSequence05.class, InvokeResult.NOT_CALLED_ERROR, "CSD");
+ testLifeCycleSequence(LifeCycleSequence06.class, InvokeResult.NOT_CALLED_FAIL, "CSD");
+ testLifeCycleSequence(LifeCycleSequence07.class, InvokeResult.NOT_CALLED_ERROR, "CSRD");
+ testLifeCycleSequence(LifeCycleSequence08.class, InvokeResult.NOT_CALLED_FAIL, "CSRD");
+ testLifeCycleSequence(LifeCycleSequence09.class, InvokeResult.PASS, "CSRD");
+ testLifeCycleSequence(LifeCycleSequence10.class, InvokeResult.PASS, "CSRD");
+ testLifeCycleSequence(LifeCycleSequence11.class, InvokeResult.PASS, "CSRD");
+
+
+
+
+// testMethodAnnotatedWithFailingCreate(LifeCycleSequence02_.class, InvokeResult.NOT_CALLED_ERROR);
+// testMethodAnnotatedWithFailingCreate(LifeCycleSequence03_.class, InvokeResult.NOT_CALLED_ERROR);
+// testMethodAnnotatedWithFailingCreate(LifeCycleSequence04_.class, InvokeResult.NOT_CALLED_FAIL);
+// testMethodAnnotatedWithCreate(LifeCycleSequence05_.class);
+ }
+
+ private static void testLifeCycleSequence(Class clazz, InvokeResult result, String expected)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", result);
+
+ //
+ assertEquals(expected, POJOAssert.buffer1);
+ }
+
+ private static void testMethodAnnotatedWithCreate()
+ {
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate01.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate02.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate03.class);
+ testMethodAnnotatedWithCreate(MethodAnnotatedWithCreate04.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate05.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate06.class);
+ assertCannotBuildSuite(MethodAnnotatedWithCreate07.class);
+ }
+
+ private static void testMethodAnnotatedWithCreate(Class clazz)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", InvokeResult.PASS);
+ }
+
+ private static void testClassHavingSamePropertyParameterAndMethodArgumentParameter()
+ {
+ TestDriver driver = assertCanBuildSuite(ClassHavingSamePropertyParameterAndMethodArgumentParameter.class);
+
+ //
+ invoke(driver, ClassHavingSamePropertyParameterAndMethodArgumentParameter.class, "testFoo", InvokeResult.PASS);
+ }
+
+ private static void testClassWithFailingConstructor()
+ {
+ testClassWithFailingConstructor(ClassWithFailingConstructor1.class, InvokeResult.NOT_CALLED_ERROR);
+ testClassWithFailingConstructor(ClassWithFailingConstructor2.class, InvokeResult.NOT_CALLED_ERROR);
+ testClassWithFailingConstructor(ClassWithFailingConstructor3.class, InvokeResult.NOT_CALLED_ERROR);
+ testClassWithFailingConstructor(ClassWithFailingConstructor4.class, InvokeResult.NOT_CALLED_FAIL);
+ }
+
+ private static void testClassWithFailingConstructor(Class clazz, InvokeResult result)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ invoke(driver, clazz, "testFoo", result);
+ }
+
+ private static void testClassWithoutDefaultConstructor()
+ {
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor1.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor2.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor3.class);
+ assertCannotBuildSuite(ClassWithoutDefaultConstructor4.class);
+ }
+
+ private static void testMethodAnnotatedWithParameter()
+ {
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter01.class, false, InvokeResult.PASS, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter02.class, false, InvokeResult.PASS, "bar");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter05.class, true, InvokeResult.PASS, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter06.class, true, InvokeResult.PASS, "bar");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter07.class, true, InvokeResult.PASS, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter09.class, true, InvokeResult.PASS, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter10.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter11.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter12.class, true, InvokeResult.NOT_CALLED_ERROR, "foo");
+ testMethodAnnotatedWithParameter(MethodAnnotatedWithParameter13.class, true, InvokeResult.NOT_CALLED_FAIL, "foo");
+ }
+
+ private static void testMethodAnnotatedWithParameter(Class clazz, boolean invoke, InvokeResult result, String... expectedParameterNames)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+
+ //
+ Map<String, ? extends ParameterInfo> parametersInfo = info.getParameters();
+ assertParametersEquals(parametersInfo, expectedParameterNames);
+
+ //
+ if (invoke)
+ {
+ assertEquals(1, info.getNames().size());
+ TestCaseInfo caseInfo = (TestCaseInfo)info.getTest("test");
+ assertNotNull(caseInfo);
+ assertParametersEquals(caseInfo.getParameters(), expectedParameterNames);
+
+ //
+ invoke(driver, clazz, "test", result);
+ }
+ else
+ {
+ assertEquals(0, info.getNames().size());
+ }
+ }
+
+ private static void testTestMethodAnnotatedWithConflictingAnnotations()
+ {
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations1.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations2.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations3.class);
+ assertCannotBuildSuite(TestMethodAnnotatedWithConflictingAnnotations4.class);
+ }
+
+ private static void testTestMethodHavingArgumentsAnnotatedWithParameter(Class clazz, String... expectedParameterNames)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ TestSuiteInfo suiteInfo = (TestSuiteInfo)driver.getInfo();
+
+ //
+ assertEquals(Collections.singleton("testFoo"), suiteInfo.getNames());
+ TestInfo testFooInfo = suiteInfo.getTest("testFoo");
+ assertNotNull(testFooInfo);
+ assertInstanceOf(testFooInfo, TestCaseInfo.class);
+
+ //
+ Map<String, ? extends ParameterInfo> parametersInfo = testFooInfo.getParameters();
+ assertParametersEquals(parametersInfo, expectedParameterNames);
+
+ //
+ invoke(driver, clazz, "testFoo", InvokeResult.PASS);
+ }
+
+ private static void testTestMethodHavingArgumentsAnnotatedWithParameter()
+ {
+ testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter1.class, "paramFoo");
+ testTestMethodHavingArgumentsAnnotatedWithParameter(TestMethodHavingArgumentsAnnotatedWithParameter2.class, "paramFoo", "paramBar");
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter3.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter4.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter5.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter6.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter7.class);
+ assertCannotBuildSuite(TestMethodHavingArgumentsAnnotatedWithParameter8.class);
+ }
+
+ private static void testMethodAnnotatedWithTest()
+ {
+ testMethodAnnotatedWithTest(MethodAnnotatedWithTest1.class, "testFoo");
+ testMethodAnnotatedWithTest(MethodAnnotatedWithTest2.class, "testBar");
+ assertCannotBuildSuite(MethodAnnotatedWithTest5.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest6.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest7.class);
+ assertClassHasNoTests(MethodAnnotatedWithTest8.class);
+ assertCannotBuildSuite(MethodAnnotatedWithTest9.class);
+ }
+
+ private static void testMethodAnnotatedWithTest(Class clazz, String testName)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+
+ //
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+ assertEquals(Collections.singleton(testName), info.getNames());
+ TestInfo testFooInfo = info.getTest(testName);
+ assertNotNull(testFooInfo);
+ assertInstanceOf(testFooInfo, TestCaseInfo.class);
+ assertEquals(testName, testFooInfo.getName());
+ assertEquals(Collections.EMPTY_MAP, testFooInfo.getParameters());
+
+ //
+ POJOAssert.clear();
+ DriverResponse response = driver.invoke(new TestId(testName), new StartTestCommand());
+ assertInstanceOf(response, EndTestResponse.class);
+ POJOAssert.assertWasCalled(clazz);
+ }
+
+ private static void testAbstractClassWithoutAnnotations()
+ {
+ assertCannotBuildSuite(AbstractClassWithoutAnnotations.class);
+ }
+
+ private static void testClassWithoutAnnotations()
+ {
+ TestDriver driver = assertCanBuildSuite(ClassWithoutAnnotations.class);
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+ assertEquals(new HashMap(), info.getParameters());
+ assertEquals(new HashSet(), info.getNames());
+ }
+
+ private static void testAbstractClassAnnotatedWithTest()
+ {
+ assertCannotBuildSuite(AbstractClassAnnotatedWithTest1.class);
+ assertCannotBuildSuite(AbstractClassAnnotatedWithTest2.class);
+ }
+
+ private static void testClassAnnotatedWithTest()
+ {
+ testClassAnnotatedPOJO(ClassAnnotatedWithTest1.class, ClassAnnotatedWithTest1.class.getName(), null);
+ testClassAnnotatedPOJO(ClassAnnotatedWithTest2.class, "foo", null);
+ }
+
+ private static void testClassAnnotatedPOJO(Class clazz, String name, String description)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+ assertEquals(new HashMap(), info.getParameters());
+ assertEquals(new HashSet(), info.getNames());
+ }
+
+ private static void assertParametersEquals(Map<String, ? extends ParameterInfo> parametersInfo, String... expectedParameterNames)
+ {
+ assertEquals(expectedParameterNames.length, parametersInfo.size());
+ for (String expectedParameterName : expectedParameterNames)
+ {
+ ParameterInfo parameterInfo = parametersInfo.get(expectedParameterName);
+ assertNotNull(parameterInfo);
+ assertEquals(expectedParameterName, parameterInfo.getName());
+ }
+ }
+
+ // *************************
+
+ private enum InvokeResult
+ {
+ PASS, NOT_CALLED_FAIL, NOT_CALLED_ERROR
+ }
+
+ private static void invoke(TestDriver driver, Class clazz, String testName, InvokeResult result)
+ {
+ TestCaseInfo testInfo = (TestCaseInfo)((TestSuiteInfo)driver.getInfo()).getTest(testName);
+ assertNotNull(testInfo);
+
+ //
+ Map<String, String> expectedParametrization = new HashMap<String, String>();
+ Map<String,Object> expectedParameterValues = new HashMap<String, Object>();
+ for (String expectedParameterName : testInfo.getParameters().keySet())
+ {
+ String expectedParameterValue = expectedParameterName + "_value";
+ expectedParametrization.put(expectedParameterName, expectedParameterValue);
+ expectedParameterValues.put(expectedParameterName, expectedParameterValue);
+ }
+
+ //
+ POJOAssert.clear();
+ DriverResponse response = driver.invoke(new TestId(testName), new StartTestCommand(expectedParametrization));
+ switch(result)
+ {
+ case PASS:
+ {
+ assertInstanceOf(response, EndTestResponse.class);
+ POJOAssert.assertWasCalled(clazz, expectedParameterValues);
+ break;
+ }
+ case NOT_CALLED_FAIL:
+ {
+ FailureResponse failureResponse = assertInstanceOf(response, FailureResponse.class);
+ Failure failure = failureResponse.getFailure();
+ assertEquals(FailureType.ASSERTION, failure.getLevel());
+ POJOAssert.assertWasNotCalled();
+ break;
+ }
+ case NOT_CALLED_ERROR:
+ {
+ FailureResponse failureResponse = assertInstanceOf(response, FailureResponse.class);
+ Failure failure = failureResponse.getFailure();
+ assertEquals(FailureType.ERROR, failure.getLevel());
+ POJOAssert.assertWasNotCalled();
+ break;
+ }
+ }
+ }
+
+ private static void assertClassHasNoTests(Class clazz)
+ {
+ TestDriver driver = assertCanBuildSuite(clazz);
+ TestSuiteInfo suiteInfo = (TestSuiteInfo)driver.getInfo();
+ assertEquals(Collections.EMPTY_SET, suiteInfo.getNames());
+ }
+
+ private static void assertCannotBuildSuite(Class clazz)
+ {
+ try
+ {
+ new POJOTestSuiteDriver(clazz);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private static TestDriver assertCanBuildSuite(Class clazz)
+ {
+ TestDriver driver = new POJOTestSuiteDriver(clazz);
+
+ //
+ assertNotNull(driver);
+
+ //
+ TestInfo info = driver.getInfo();
+ assertNotNull(info);
+ assertInstanceOf(info, TestSuiteInfo.class);
+
+ //
+ return driver;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodAnnotatedWithConflictingAnnotations1
+{
+
+ @Test
+ @Parameter
+ public void setFoo(@Parameter(name="foo") String foo)
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodAnnotatedWithConflictingAnnotations2
+{
+
+ @Test
+ @Create
+ public void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations3.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodAnnotatedWithConflictingAnnotations3
+{
+
+ @Test
+ @Destroy
+ public void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations4.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations4.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodAnnotatedWithConflictingAnnotations4.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodAnnotatedWithConflictingAnnotations4
+{
+
+ @Create
+ @Destroy
+ public void testFoo()
+ {
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter1.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter1.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter1.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter1
+{
+
+ @Test public void testFoo(@Parameter(name="paramFoo") String foo)
+ {
+ POJOAssert.call(TestMethodHavingArgumentsAnnotatedWithParameter1.class, Collections.singletonMap("paramFoo", foo));
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter2.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter2.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter2.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter2
+{
+
+ @Test
+ public void testFoo(@Parameter(name="paramFoo") String foo, @Parameter(name="paramBar") String bar)
+ {
+ HashMap<String,String> tmp = new HashMap<String, String>();
+ tmp.put("paramFoo", foo);
+ tmp.put("paramBar", bar);
+ POJOAssert.call(TestMethodHavingArgumentsAnnotatedWithParameter2.class, tmp);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter3.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter3.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter3.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter3
+{
+
+ @Test
+ public void testFoo(String foo)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter4.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter4.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter4.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter4
+{
+
+ @Test
+ public void testFoo(@Parameter String foo)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter5.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter5.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter5.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter5
+{
+
+ @Test
+ public void testFoo(@Parameter String foo)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter6.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter6.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter6.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter6
+{
+
+ @Test
+ public void testFoo(@Parameter(name="fooParam") String foo, String bar)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter7.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter7.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter7.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter7
+{
+
+ @Test
+ public void testFoo(@Parameter(name="fooParam") String foo, @Parameter String bar)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter8.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter8.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/pojo/TestMethodHavingArgumentsAnnotatedWithParameter8.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.pojo;
+
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestMethodHavingArgumentsAnnotatedWithParameter8
+{
+
+ @Test
+ public void testFoo(@Parameter(name="fooParam") String foo, @Parameter String bar)
+ {
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.runner;
+
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.impl.composite.CompositeTestRunner;
+import org.jboss.unit.runner.impl.event.EventDrivenTestRunner;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompositeTestRunnerTests
+{
+
+ public static void main(String[] args)
+ {
+
+ EventDrivenTestRunner srunner = new EventDrivenTestRunner(
+ new StartRunnerEvent(),
+ new EndRunnerEvent()
+ );
+
+ Collection<TestRunner> runners = new ArrayList<TestRunner>();
+ runners.add(srunner);
+
+ CompositeTestRunner runner = new CompositeTestRunner(runners);
+
+ runner.run();
+
+
+
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/ParametrizationTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/ParametrizationTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/ParametrizationTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.runner;
+
+import static org.jboss.unit.api.Assert.assertEquals;
+import org.jboss.unit.runner.Parametrization;
+import org.jboss.unit.util.CollectionTools;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParametrizationTests
+{
+
+ public static void main(String[] args)
+ {
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ }
+
+ private static void test1()
+ {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ Parametrization def = new Parametrization(map);
+
+ //
+ Set<String> contraints = CollectionTools.set();
+ Set<Map<String,String>> expectedResult = new HashSet<Map<String, String>>();
+ expectedResult.add(new HashMap<String, String>());
+ assertEquals(expectedResult, new HashSet<Map<String, String>>(def.enumerate(contraints)));
+ }
+
+ private static void test2()
+ {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ map.put("a", new String[]{"b"});
+ Parametrization def = new Parametrization(map);
+
+ //
+ Set<String> contraints1= CollectionTools.set();
+ Set<Map<String,String>> expectedResult1 = new HashSet<Map<String, String>>();
+ expectedResult1.add(new HashMap<String, String>());
+ assertEquals(expectedResult1, new HashSet<Map<String, String>>(def.enumerate(contraints1)));
+
+ //
+ Set<String> contraints2= CollectionTools.set("a");
+ Set<Map<String,String>> expectedResult2 = new HashSet<Map<String, String>>();
+ Map<String,String> map2_1 = new HashMap<String, String>();
+ map2_1.put("a", "b");
+ expectedResult2.add(map2_1);
+ assertEquals(expectedResult2, new HashSet<Map<String, String>>(def.enumerate(contraints2)));
+
+ //
+ Set<String> contraints3= CollectionTools.set("c");
+ Set<Map<String,String>> expectedResult3 = new HashSet<Map<String, String>>();
+ expectedResult3.add(new HashMap<String, String>());
+ assertEquals(expectedResult3, new HashSet<Map<String, String>>(def.enumerate(contraints3)));
+ }
+
+ private static void test3()
+ {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ map.put("a", new String[]{"b","c"});
+ Parametrization def = new Parametrization(map);
+
+ //
+ Set<String> contraints1= CollectionTools.set();
+ Set<Map<String,String>> expectedResult1 = new HashSet<Map<String, String>>();
+ expectedResult1.add(new HashMap<String, String>());
+ assertEquals(expectedResult1, new HashSet<Map<String, String>>(def.enumerate(contraints1)));
+
+ //
+ Set<String> contraints2= CollectionTools.set("a");
+ Set<Map<String,String>> expectedResult2 = new HashSet<Map<String, String>>();
+ Map<String,String> map2_1 = new HashMap<String, String>();
+ map2_1.put("a", "b");
+ expectedResult2.add(map2_1);
+ Map<String,String> map2_2 = new HashMap<String, String>();
+ map2_2.put("a", "c");
+ expectedResult2.add(map2_2);
+ assertEquals(expectedResult2, new HashSet<Map<String, String>>(def.enumerate(contraints2)));
+
+ //
+ Set<String> contraints3= CollectionTools.set("c");
+ Set<Map<String,String>> expectedResult3 = new HashSet<Map<String, String>>();
+ expectedResult3.add(new HashMap<String, String>());
+ assertEquals(expectedResult3, new HashSet<Map<String, String>>(def.enumerate(contraints3)));
+ }
+
+ private static void test4()
+ {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ map.put("a", new String[]{"b","c"});
+ map.put("d", new String[]{"e"});
+ Parametrization def = new Parametrization(map);
+
+ //
+ Set<String> contraints1= CollectionTools.set();
+ Set<Map<String,String>> expectedResult1 = new HashSet<Map<String, String>>();
+ expectedResult1.add(new HashMap<String, String>());
+ assertEquals(expectedResult1, new HashSet<Map<String, String>>(def.enumerate(contraints1)));
+
+ //
+ Set<String> contraints2= CollectionTools.set("a");
+ Set<Map<String,String>> expectedResult2 = new HashSet<Map<String, String>>();
+ Map<String,String> map2_1 = new HashMap<String, String>();
+ map2_1.put("a", "b");
+ expectedResult2.add(map2_1);
+ Map<String,String> map2_2 = new HashMap<String, String>();
+ map2_2.put("a", "c");
+ expectedResult2.add(map2_2);
+ assertEquals(expectedResult2, new HashSet<Map<String, String>>(def.enumerate(contraints2)));
+
+ //
+ Set<String> contraints3= CollectionTools.set("d");
+ Set<Map<String,String>> expectedResult3 = new HashSet<Map<String, String>>();
+ Map<String,String> map3_1 = new HashMap<String, String>();
+ map3_1.put("d", "e");
+ expectedResult3.add(map3_1);
+ assertEquals(expectedResult3, new HashSet<Map<String, String>>(def.enumerate(contraints3)));
+
+ //
+ Set<String> contraints4= CollectionTools.set("a", "d");
+ Set<Map<String,String>> expectedResult4 = new HashSet<Map<String, String>>();
+ Map<String,String> map4_1 = new HashMap<String, String>();
+ map4_1.put("a", "b");
+ map4_1.put("d", "e");
+ expectedResult4.add(map4_1);
+ Map<String,String> map4_2 = new HashMap<String, String>();
+ map4_2.put("a", "c");
+ map4_2.put("d", "e");
+ expectedResult4.add(map4_2);
+ assertEquals(expectedResult4, new HashSet<Map<String, String>>(def.enumerate(contraints4)));
+ }
+
+ private static void test5()
+ {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ map.put("a", new String[]{"b","c"});
+ map.put("d", new String[]{"e","f"});
+ Parametrization def = new Parametrization(map);
+
+ //
+ Set<String> contraints1= CollectionTools.set();
+ Set<Map<String,String>> expectedResult1 = new HashSet<Map<String, String>>();
+ expectedResult1.add(new HashMap<String, String>());
+ assertEquals(expectedResult1, new HashSet<Map<String, String>>(def.enumerate(contraints1)));
+
+ //
+ Set<String> contraints2= CollectionTools.set("a");
+ Set<Map<String,String>> expectedResult2 = new HashSet<Map<String, String>>();
+ Map<String,String> map2_1 = new HashMap<String, String>();
+ map2_1.put("a", "b");
+ expectedResult2.add(map2_1);
+ Map<String,String> map2_2 = new HashMap<String, String>();
+ map2_2.put("a", "c");
+ expectedResult2.add(map2_2);
+ assertEquals(expectedResult2, new HashSet<Map<String, String>>(def.enumerate(contraints2)));
+
+ //
+ Set<String> contraints3= CollectionTools.set("d");
+ Set<Map<String,String>> expectedResult3 = new HashSet<Map<String, String>>();
+ Map<String,String> map3_1 = new HashMap<String, String>();
+ map3_1.put("d", "e");
+ expectedResult3.add(map3_1);
+ Map<String,String> map3_2 = new HashMap<String, String>();
+ map3_2.put("d", "f");
+ expectedResult3.add(map3_2);
+ assertEquals(expectedResult3, new HashSet<Map<String, String>>(def.enumerate(contraints3)));
+
+ //
+ Set<String> contraints4= CollectionTools.set("a", "d");
+ Set<Map<String,String>> expectedResult4 = new HashSet<Map<String, String>>();
+ Map<String,String> map4_1 = new HashMap<String, String>();
+ map4_1.put("a", "b");
+ map4_1.put("d", "e");
+ expectedResult4.add(map4_1);
+ Map<String,String> map4_2 = new HashMap<String, String>();
+ map4_2.put("a", "c");
+ map4_2.put("d", "e");
+ expectedResult4.add(map4_2);
+ Map<String,String> map4_3 = new HashMap<String, String>();
+ map4_3.put("a", "b");
+ map4_3.put("d", "f");
+ expectedResult4.add(map4_3);
+ Map<String,String> map4_4 = new HashMap<String, String>();
+ map4_4.put("a", "c");
+ map4_4.put("d", "f");
+ expectedResult4.add(map4_4);
+ assertEquals(expectedResult4, new HashSet<Map<String, String>>(def.enumerate(contraints4)));
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerEventBroadcasterSupportTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerEventBroadcasterSupportTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerEventBroadcasterSupportTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,218 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.runner.event;
+
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.event.TestRunnerEventBroadcasterSupport;
+import static org.jboss.unit.util.CollectionTools.list;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRunnerEventBroadcasterSupportTests
+{
+
+ /** . */
+ private TestRunnerEventBroadcasterSupport support = new TestRunnerEventBroadcasterSupport();
+
+ /** . */
+ private MyListener listener1 = new MyListener();
+
+ /** . */
+ private MyListener listener2 = new MyListener();
+
+ public static void main(String[] args)
+ {
+ new TestRunnerEventBroadcasterSupportTests().testAddNullListener();
+ new TestRunnerEventBroadcasterSupportTests().testRemoveNullListener();
+ new TestRunnerEventBroadcasterSupportTests().testBroadcastNullEvent();
+ new TestRunnerEventBroadcasterSupportTests().testDualRegistration();
+ new TestRunnerEventBroadcasterSupportTests().testRegistration();
+ new TestRunnerEventBroadcasterSupportTests().testUnregistration();
+ new TestRunnerEventBroadcasterSupportTests().testBroadcast();
+ new TestRunnerEventBroadcasterSupportTests().testFailure();
+ }
+
+ private void testAddNullListener()
+ {
+ try
+ {
+ support.addListener(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private void testRemoveNullListener()
+ {
+ try
+ {
+ support.removeListener(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private void testBroadcastNullEvent()
+ {
+ try
+ {
+ support.fireEvent(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private void testDualRegistration()
+ {
+ MyEvent event = new MyEvent();
+ support.addListener(listener1);
+ support.addListener(listener1);
+ support.fireEvent(event);
+ assertEquals(list(event), listener1.events);
+ }
+
+ private void testRegistration()
+ {
+ MyEvent event = new MyEvent();
+ support.addListener(listener1);
+ support.fireEvent(event);
+ assertEquals(list(event), listener1.events);
+ }
+
+ private void testUnregistration()
+ {
+ MyEvent event = new MyEvent();
+ support.addListener(listener1);
+ support.removeListener(listener1);
+ support.fireEvent(event);
+ assertEquals(0, listener1.events.size());
+ }
+
+ private void testBroadcast()
+ {
+ MyEvent event = new MyEvent();
+ support.addListener(listener1);
+ support.addListener(listener2);
+ support.fireEvent(event);
+ assertEquals(list(event), listener1.events);
+ assertEquals(list(event), listener2.events);
+ }
+
+ private void testFailure()
+ {
+ MyEvent event = new MyEvent();
+ support.addListener(listener1);
+ support.addListener(listener2);
+
+ //
+ listener1.throwable = new RuntimeException();
+ support.fireEvent(event);
+ assertEquals(list(event), listener2.events);
+
+ //
+ listener1.events.clear();
+ listener2.events.clear();
+ listener1.throwable = null;
+ listener2.throwable = new RuntimeException();
+ support.fireEvent(event);
+ assertEquals(list(event), listener1.events);
+
+ //
+ boolean b = false;
+
+ //
+ listener1.events.clear();
+ listener2.events.clear();
+ listener1.throwable = new Error();
+ listener2.throwable = null;
+ try
+ {
+ support.fireEvent(event);
+ fail("Was expecting an error");
+ }
+ catch (Error expected)
+ {
+ assertSame(listener1.throwable, expected);
+ b |= listener2.events.size() == 1 && listener2.events.get(0) == event;
+ }
+
+ //
+ listener1.events.clear();
+ listener2.events.clear();
+ listener1.throwable = null;
+ listener2.throwable = new Error();
+ try
+ {
+ support.fireEvent(event);
+ fail("Was expecting an error");
+ }
+ catch (Error expected)
+ {
+ assertSame(listener2.throwable, expected);
+ b |= listener1.events.size() == 1 && listener1.events.get(0) == event;
+ }
+
+ //
+ assertTrue(b);
+ }
+
+ private class MyEvent extends TestRunnerEvent
+ {
+ }
+
+ private class MyListener implements TestRunnerEventListener
+ {
+
+ /** . */
+ List<TestRunnerEvent> events = new ArrayList<TestRunnerEvent>();
+
+ /** . */
+ Throwable throwable;
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ if (throwable instanceof RuntimeException)
+ {
+ throw (RuntimeException)throwable;
+ }
+ else if (throwable instanceof Error)
+ {
+ throw (Error)throwable;
+ }
+ events.add(event);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerLifeCycleFilterTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerLifeCycleFilterTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/event/TestRunnerLifeCycleFilterTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.runner.event;
+
+import static org.jboss.unit.api.Assert.assertNull;
+import static org.jboss.unit.api.Assert.assertSame;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventBroadcaster;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRunnerLifeCycleFilterTests
+{
+
+ /** . */
+ private static TestRunnerEvent event = null;
+
+ public static void main(String[] args)
+ {
+ TestRunnerEventBroadcaster broadcaster = new TestRunnerEventBroadcaster()
+ {
+ public void fireEvent(TestRunnerEvent event)
+ {
+ TestRunnerLifeCycleFilterTests.event = event;
+ }
+ };
+ TestRunnerLifeCycleFilter filter = new TestRunnerLifeCycleFilter(broadcaster);
+
+ //
+ StartRunnerEvent startEvent = new StartRunnerEvent();
+ filter.onEvent(startEvent);
+ assertNull(event);
+
+ //
+ EndRunnerEvent endEvent = new EndRunnerEvent();
+ filter.onEvent(endEvent);
+ assertNull(event);
+
+ //
+ TestRunnerEvent anEvent = new TestRunnerEvent()
+ {
+ };
+ filter.onEvent(anEvent);
+ assertSame(anEvent, event);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.test.unit.runner.model;
+
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.runner.model.ModelBuilder;
+import org.jboss.unit.runner.model.ParameterValueDef;
+import org.jboss.unit.runner.model.ParametersDef;
+import org.jboss.unit.runner.model.TestDef;
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
+import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
+import org.jboss.unit.runner.model.pojo.TestDefDef;
+import static org.jboss.unit.util.CollectionTools.list;
+import static org.jboss.unit.util.CollectionTools.set;
+import org.xml.sax.InputSource;
+
+import java.io.InputStream;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ModelTests
+{
+ public static void main(String[] args)
+ {
+ testParameterValueDef();
+
+ try
+ {
+ InputStream in = ModelTests.class.getResourceAsStream("f1.xml");
+ ModelBuilder builder = new ModelBuilder(new InputSource(in));
+ TestSuiteDef suite = builder.build();
+
+ CompositeTestSuiteDef composite = assertInstanceOf(suite, CompositeTestSuiteDef.class);
+
+ assertNotNull(composite.getSuites());
+ assertFalse(composite.getSuites().isEmpty());
+
+ POJOTestSuiteDef pojoSuite = assertInstanceOf(composite.getSuites().iterator().next(), POJOTestSuiteDef.class);
+
+ TestDefDef myTestDef = pojoSuite.getTestDef("MyTest");
+ assertNotNull(myTestDef);
+ assertEquals("MyTest", myTestDef.getId());
+ assertNotNull(myTestDef.getTestClass());
+ assertEquals("org.foo.bar.MyTest", myTestDef.getTestClass().getName());
+ assertNotNull(myTestDef.getTestClass().getTestCases());
+ assertEquals(0, myTestDef.getTestClass().getTestCases().size());
+
+ TestDefDef myTestDef2 = pojoSuite.getTestDef("MyTest2");
+ assertNotNull(myTestDef2);
+ assertEquals("MyTest2", myTestDef2.getId());
+ assertNotNull(myTestDef2.getTestClass());
+ assertEquals("org.foo.bar.MyTest2", myTestDef2.getTestClass().getName());
+ assertNotNull(myTestDef2.getTestClass().getTestCases());
+ assertEquals(2, myTestDef2.getTestClass().getTestCases().size());
+ assertNotNull(myTestDef2.getTestClass().getTestCase("foo"));
+ assertEquals("foo", myTestDef2.getTestClass().getTestCase("foo").getName());
+ assertNotNull(myTestDef2.getTestClass().getTestCase("bar"));
+ assertEquals("bar", myTestDef2.getTestClass().getTestCase("bar").getName());
+
+ assertEquals(2, pojoSuite.getTests().size());
+
+ //
+ Iterator<TestDef> iterator = pojoSuite.getTests().iterator();
+ TestDef test1 = iterator.next();
+ assertEquals("MyTest", test1.getRefId());
+ ParametersDef parameters = test1.getParameters();
+ assertNotNull(parameters);
+ assertEquals(set("blah", "foo"), parameters.getNames());
+ ParameterValueDef blah = parameters.getParameter("blah");
+ assertEquals(list("bluh"), blah.list());
+ ParameterValueDef foo = parameters.getParameter("foo");
+ assertEquals(list("bar1", null), foo.list());
+
+ //
+ TestDef test2 = iterator.next();
+ assertNotNull(test2.getRefId());
+ ParametersDef test2Parameters = test2.getParameters();
+ assertNotNull(test2Parameters);
+ assertEquals(set("foo"), test2Parameters.getNames());
+ ParameterValueDef fff = test2Parameters.getParameter("foo");
+ assertEquals(list("bar"), fff.list());
+
+ //
+ TestDefDef myTestDef3 = pojoSuite.getTestDef(test2.getRefId());
+ assertNotNull(myTestDef3);
+
+ assertEquals(test2.getRefId(), myTestDef3.getId());
+ assertNotNull(myTestDef3.getTestClass());
+ assertEquals("org.foo.bar.OtherTest", myTestDef3.getTestClass().getName());
+ assertNotNull(myTestDef3.getTestClass().getTestCases());
+ assertEquals(0, myTestDef3.getTestClass().getTestCases().size());
+
+
+ //
+// ParametersDef suiteParams = pojoSuite.getParameters();
+// assertNotNull(suiteParams);
+// assertEquals(set("red"), suiteParams.getMap().keySet());
+// ParameterValueDef blue = suiteParams.getMap().get("red");
+// assertEquals(list("blue"), blue.list());
+
+ }
+ catch (Exception e)
+ {
+ fail(e);
+ }
+
+
+ }
+
+ private static void testParameterValueDef()
+ {
+ ParameterValueDef pvd1 = new ParameterValueDef();
+ assertEquals(list(), pvd1.list());
+
+ ParameterValueDef pvd2 = new ParameterValueDef("a");
+ assertEquals(list("a"), pvd2.list());
+
+ ParameterValueDef pvd3 = new ParameterValueDef("a", "b");
+ assertEquals(list("a", "b"), pvd3.list());
+
+ ParameterValueDef pvd4 = new ParameterValueDef((String)null);
+ assertEquals(list((String)null), pvd4.list());
+
+ try
+ {
+ new ParameterValueDef((String[])null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/Failure.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit;
+
+/**
+ * A failure.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Failure
+{
+
+ /** The optional failure message. */
+ private final String message;
+
+ /** The optional failure cause. */
+ private final Throwable cause;
+
+ /** The type of failure. */
+ private final FailureType type;
+
+ public Failure(String message, FailureType type)
+ {
+ this.message = message;
+ this.cause = null;
+ this.type = type;
+ }
+
+ public Failure(Throwable cause, FailureType type)
+ {
+ this.message = cause.getMessage();
+ this.cause = cause;
+ this.type = type;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public Throwable getCause()
+ {
+ return cause;
+ }
+
+ public FailureType getLevel()
+ {
+ return type;
+ }
+
+ public static Failure createErrorFailure(String messge)
+ {
+ return new Failure(messge, FailureType.ERROR);
+ }
+
+ public static Failure createErrorFailure(Throwable throwable)
+ {
+ return new Failure(throwable, FailureType.ERROR);
+ }
+
+ public static Failure createAssertionFailure(AssertionError throwable)
+ {
+ return new Failure(throwable, FailureType.ASSERTION);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/FailureType.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/FailureType.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/FailureType.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit;
+
+/**
+ * The type of a failure.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public enum FailureType
+{
+
+ ERROR,
+ ASSERTION,
+
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,251 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Collection;
+
+/**
+ * A test id made of a sequence of non null names.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class TestId implements Serializable
+{
+
+ /** . */
+ private final String[] names;
+
+ public TestId()
+ {
+ this.names = new String[0];
+ }
+
+ public TestId(TestId prefix, String name)
+ {
+ if (prefix == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String[] names = new String[prefix.names.length + 1];
+ System.arraycopy(prefix.names, 0, names, 0, prefix.names.length);
+ names[prefix.names.length] = name;
+
+ //
+ this.names = names;
+ }
+
+ public TestId(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.names = new String[]{name};
+ }
+
+ public TestId(String... names)
+ {
+ if (names == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String[] tmp = names.clone();
+
+ //
+ for (String name : tmp)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ //
+ this.names = tmp;
+ }
+
+ public TestId(Collection<String> names)
+ {
+ if (names == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String[] tmp = names.toArray(new String[names.size()]);
+
+ //
+ for (String name : tmp)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ //
+ this.names = tmp;
+ }
+
+ public Iterator<String> iterator()
+ {
+ return new Iterator<String>()
+ {
+ /** . */
+ int index = 0;
+
+ public boolean hasNext()
+ {
+ return index < names.length;
+ }
+
+ public String next()
+ {
+ if (hasNext())
+ {
+ return names[index++];
+ }
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ public String getName(int index)
+ {
+ return names[index];
+ }
+
+ public int getLength()
+ {
+ return names.length;
+ }
+
+ public TestId range(int from)
+ {
+ if (from < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (from > names.length)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String[] subNames = new String[names.length - from];
+ System.arraycopy(names, from, subNames, 0, subNames.length);
+ return new TestId(subNames);
+ }
+
+ public int hashCode()
+ {
+ int hashCode = 0;
+
+ //
+ for (String name : names)
+ {
+ hashCode = hashCode * 41 + name.hashCode();
+ }
+
+ //
+ return hashCode;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+
+ //
+ if (object instanceof TestId)
+ {
+ TestId that = (TestId)object;
+
+ //
+ if (this.names.length != that.names.length)
+ {
+ return false;
+ }
+
+ //
+ for (int i = 0;i < this.names.length;i++)
+ {
+ String thisName = this.names[i];
+ String thatName = that.names[i];
+
+ //
+ if (!thisName.equals(thatName))
+ {
+ return false;
+ }
+ }
+ }
+
+ //
+ return false;
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("TestId[");
+
+ //
+ for (int i = 0;i < names.length;i++)
+ {
+ if (i > 0)
+ {
+ tmp.append(',');
+ }
+
+ //
+ tmp.append("\"").append(names[i]).append("\"");
+ }
+
+ //
+ tmp.append(']');
+
+ //
+ return tmp.toString();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,351 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api;
+
+import java.util.Arrays;
+
+/**
+ * A bunch of convenient utilities methods for asserting facts.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Assert
+{
+
+ public static <T> T assertInstanceOf(Object o, Class<T> c)
+ {
+ if (o == null)
+ {
+ throw createAssertionError(null, "Cannot test null object");
+ }
+ else if (c == null)
+ {
+ throw createAssertionError(null, "Cannot test null class");
+ }
+ else if (c.isInstance(o))
+ {
+ return c.cast(o);
+ }
+ else
+ {
+ throw createAssertionError(null, "Object " + o + " with class " + o.getClass().getName() + " is not an instance of " + c.getName());
+ }
+ }
+
+ public static void assertNotNull(Object actual)
+ {
+ assertNotSame(null, actual);
+ }
+
+ public static void assertNotNull(String msg, Object actual)
+ {
+ assertNotSame(msg, null, actual);
+ }
+
+ public static void assertNull(Object actual)
+ {
+ assertSame(null, actual);
+ }
+
+ public static void assertNull(String msg, Object actual)
+ {
+ assertSame(msg, null, actual);
+ }
+
+ public static void assertNotSame(String msg, Object expected, Object actual)
+ {
+ if (actual == null)
+ {
+ if (msg != null)
+ {
+ msg = "Expected a non null object";
+ }
+ if (expected == null)
+ {
+ fail(msg);
+ }
+ }
+ else
+ {
+ if (msg == null)
+ {
+ if (expected != null)
+ {
+ msg = "Expected " + format(actual) + " object to have a different reference than " + format(expected);
+ }
+ else
+ {
+ msg = "Expected " + format(actual) + " object to be not null";
+ }
+ }
+ if (actual == expected)
+ {
+ fail(msg);
+ }
+ }
+ }
+
+ public static void assertNotSame(Object expected, Object actual)
+ {
+ assertNotSame(null, expected, actual);
+ }
+
+ public static void assertSame(String msg, Object expected, Object actual)
+ {
+ if (actual == null)
+ {
+ if (msg == null)
+ {
+ msg = "Expected a null value";
+ }
+ if (expected != null)
+ {
+ fail(msg);
+ }
+ }
+ else
+ {
+ if (msg == null)
+ {
+ if (expected != null)
+ {
+ msg = "Expected " + format(actual) + " valobjectue to have the same reference than " + format(expected);
+ }
+ else
+ {
+ msg = "Expected " + format(actual) + " object to be null";
+ }
+ }
+ if (actual != expected)
+ {
+ fail(msg);
+ }
+ }
+ }
+
+ public static void assertSame(Object expected, Object actual)
+ {
+ assertSame(null, expected, actual);
+ }
+
+ public static void assertNotEquals(String msg, Object expected, Object actual)
+ {
+ if (actual == null)
+ {
+ if (msg != null)
+ {
+ msg = "Expected a non null object";
+ }
+ if (expected == null)
+ {
+ fail(msg);
+ }
+ }
+ else
+ {
+ if (msg == null)
+ {
+ msg = "Expected " + format(actual) + " object to be not equals to " + format(expected);
+ }
+ if (actual.equals(expected))
+ {
+ fail(msg);
+ }
+ }
+ }
+
+ public static void assertNotEquals(Object expected, Object actual)
+ {
+ assertNotEquals(null, expected, actual);
+ }
+
+ public static void assertEquals(String msg, Object expected, Object actual)
+ {
+ if (actual == null)
+ {
+ if (msg == null)
+ {
+ msg = "Expected a null object";
+ }
+ if (expected != null)
+ {
+ fail(msg);
+ }
+ }
+ else
+ {
+ if (msg == null)
+ {
+ msg = "Expected " + format(actual) + " object to be equals to " + format(expected);
+ }
+ if (!actual.equals(expected))
+ {
+ fail(msg);
+ }
+ }
+ }
+
+ public static void assertEquals(Object expected, Object actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ public static void assertTrue(boolean b)
+ {
+ assertTrue(null, b);
+ }
+
+ public static void assertTrue(String msg, boolean b)
+ {
+ assertEquals(msg, true, b);
+ }
+
+ public static void assertFalse(boolean b)
+ {
+ assertFalse(null, b);
+ }
+
+ public static void assertFalse(String msg, boolean b)
+ {
+ assertEquals(msg, false, b);
+ }
+
+ public static void fail(Throwable cause)
+ {
+ throw createAssertionError(cause, null);
+ }
+
+ public static void fail()
+ {
+ throw createAssertionError(null, null);
+ }
+
+ public static void fail(String msg)
+ {
+ throw createAssertionError(null, msg);
+ }
+
+ public static void fail(Throwable cause, String msg)
+ {
+ throw createAssertionError(cause, msg);
+ }
+
+ public static Error createAssertionError(Throwable cause, String msg)
+ {
+ if (msg == null)
+ {
+ msg = "Failure";
+ }
+ AssertionError assertionError = new AssertionError(msg);
+ if (cause != null)
+ {
+ assertionError.initCause(cause);
+ }
+ return assertionError;
+ }
+
+ //
+
+ /** @see #assertEquals(Object[],Object[]) */
+ public static void assertEquals(Object[] expected, Object[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */
+ public static void assertEquals(String message, Object[] expected, Object[] actual)
+ {
+ if (!Arrays.equals(expected, actual))
+ {
+ fail(format(message, expected, expected));
+ }
+ }
+
+ /** @see #assertEquals(char[],char[]) */
+ public static void assertEquals(char[] expected, char[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, char[] expected, char[] actual)
+ {
+ if (!Arrays.equals(expected, actual))
+ {
+ fail(format(message, expected, expected));
+ }
+ }
+
+ /** @see #assertEquals(byte[],byte[]) */
+ public static void assertEquals(byte[] expected, byte[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, byte[] expected, byte[] actual)
+ {
+ if (!Arrays.equals(expected, actual))
+ {
+ fail(format(message, expected, expected));
+ }
+ }
+
+ private static String format(String message, Object expected, Object actual)
+ {
+ String formatted = "";
+
+ //
+ if (message != null)
+ {
+ formatted = message + " ";
+ }
+
+ //
+ return formatted + "expected:" + format(expected) + " but was:" + format(actual) + "";
+ }
+
+ private static String format(Object o)
+ {
+ if (o == null)
+ {
+ return "null";
+ }
+ else if (o instanceof Object[])
+ {
+ Object[] array = (Object[])o;
+ StringBuffer buffer = new StringBuffer("<[");
+ for (int i = 0; i < array.length; i++)
+ {
+ buffer.append(i == 0 ? "" : ",").append(String.valueOf(array[i]));
+ }
+ buffer.append("]>");
+ return buffer.toString();
+ }
+ else
+ {
+ return " <" + o + ">";
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ArgumentTestParameter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class ArgumentTestParameter extends TestParameter
+{
+ public ArgumentTestParameter(String name, String description)
+ {
+ super(name, description);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/MethodKey.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class MethodKey implements Comparable
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private List<String> types;
+
+ MethodKey(Method method)
+ {
+ List<String> types = new ArrayList<String>();
+ for (Class type : method.getParameterTypes())
+ {
+ types.add(type.getName());
+ }
+
+ this.name = method.getName();
+ this.types = types;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode() + types.hashCode();
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == this)
+ {
+ return true;
+ }
+ if (object instanceof MethodKey)
+ {
+ MethodKey that = (MethodKey)object;
+ return that.name.equals(this.name) && that.types.equals(this.types);
+ }
+ return false;
+ }
+
+ public int compareTo(Object o)
+ {
+ MethodKey that = (MethodKey)o;
+
+ //
+ int sign = name.compareTo(that.name);
+ if (sign != 0)
+ {
+ return sign;
+ }
+
+ //
+ for (int index = 0;index < this.types.size() && index < that.types.size();index++)
+ {
+ String thisName = this.types.get(index);
+ String thatName = that.types.get(index);
+
+ //
+ int order = thisName.compareTo(thatName);
+ if (order != 0)
+ {
+ return order;
+ }
+ }
+
+ //
+ return that.types.size() - this.types.size();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/ParameterDescriptor.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.util.List;
+
+/**
+ * An object describing a parameter.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterDescriptor
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String description;
+
+ /** . */
+ private List<String> defaultValues;
+
+ public ParameterDescriptor(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public List<String> getDefaultValues()
+ {
+ return defaultValues;
+ }
+
+ public void setDefaultValues(List<String> defaultValues)
+ {
+ this.defaultValues = defaultValues;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/PropertyTestParameter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class PropertyTestParameter extends TestParameter
+{
+
+ /** . */
+ final List<Method> setters = new ArrayList<Method>();
+
+ public PropertyTestParameter(String name, String description)
+ {
+ super(name, description);
+ }
+
+ void addSetter(Method setter)
+ {
+ setters.add(setter);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCase.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestCase
+{
+
+ final TestCaseDef def;
+
+ /** . */
+ final Object pojo;
+
+ /** . */
+ Map<String,String> parametrization;
+
+ public TestCase(TestCaseDef def, Object pojo)
+ {
+ this.def = def;
+ this.pojo = pojo;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.lang.reflect.Method;
+import java.util.LinkedHashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestCaseDef
+{
+
+ /** . */
+ TestHandlerSupport driver;
+
+ /** . */
+ final Method method;
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String description;
+
+ /** . */
+ final LinkedHashMap<String,ArgumentTestParameter> parameters;
+
+// /** . */
+// private final TestCaseInfo info = new TestCaseInfo()
+// {
+// public String getName()
+// {
+// return name;
+// }
+// public String getDescription()
+// {
+// return description;
+// }
+// public Map<String, ? extends ParameterInfo> getParameters()
+// {
+// Map<String, ParameterInfo> merge = new HashMap<String, ParameterInfo>();
+// merge.putAll(driver.getInfo().getParameters());
+// merge.putAll(parameters);
+// return merge;
+// }
+// public Set<String> getTags()
+// {
+// return Collections.emptySet();
+// }
+// };
+
+ TestCaseDef(Method method, String name, String description, LinkedHashMap<String, ArgumentTestParameter> parameters)
+ {
+ this.method = method;
+ this.name = name;
+ this.description = description;
+ this.parameters = parameters;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseDescriptor.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestCaseDescriptor
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String description;
+
+ /** . */
+ private Map<String,ParameterDescriptor> parameters;
+
+ public TestCaseDescriptor(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public Map<String, ParameterDescriptor> getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, ParameterDescriptor> parameters)
+ {
+ this.parameters = parameters;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestCaseLifeCycleException.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestCaseLifeCycleException extends Exception
+{
+ public TestCaseLifeCycleException()
+ {
+ }
+
+ public TestCaseLifeCycleException(String string)
+ {
+ super(string);
+ }
+
+ public TestCaseLifeCycleException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public TestCaseLifeCycleException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandler.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+
+import java.util.Map;
+
+/**
+ * Allow a pojo class to take care of providing its description and perform test case life cycle management.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestHandler
+{
+
+ /**
+ * Return the test name.
+ *
+ * @return the test name
+ */
+ String getName();
+
+ /**
+ * Return the test description.
+ *
+ * @return the test description
+ */
+ String getDescription();
+
+ /**
+ * Return the test parameters.
+ *
+ * @return the test parameters
+ */
+ Map<String,ParameterDescriptor> getParameters();
+
+ /**
+ * Return the test case descriptions.
+ *
+ * @return the test case descriptions
+ */
+ Map<String, TestCaseDescriptor> getTestCases();
+
+ /**
+ * Instantiate life cycle operation of a test case.
+ *
+ * @param name the test case name
+ * @return the test case object
+ * @throws TestCaseLifeCycleException
+ */
+ Object newTestCase(String name) throws TestCaseLifeCycleException;
+
+ /**
+ * Parametrize life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @param parametrization the parametrization
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseParametrize(Object testCase, Map<String,String> parametrization) throws TestCaseLifeCycleException;
+
+ /**
+ * Create life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseCreate(Object testCase) throws TestCaseLifeCycleException;
+
+ /**
+ * Invocation life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ * @throws TestCaseLifeCycleException
+ */
+ void testCaseInvoke(Object testCase) throws TestCaseLifeCycleException;
+
+ /**
+ * Destroy life cycle operation of a test case.
+ *
+ * @param testCase the test case
+ */
+ void testCaseDestroy(Object testCase);
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestHandlerSupport.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,577 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.api.pojo.annotations.Parameter;
+import org.jboss.unit.api.pojo.annotations.Create;
+import org.jboss.unit.api.pojo.annotations.Destroy;
+import org.jboss.unit.api.pojo.annotations.Description;
+
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.annotation.Annotation;
+import java.beans.Introspector;
+
+/**
+ * Provide a default implementation that relies on the annotation defined in the <code>annotations</code> package.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestHandlerSupport implements TestHandler
+{
+
+ /** . */
+ private String suiteName;
+
+ /** . */
+ private String suiteDescription;
+
+ /** . */
+ private Map<String, TestCaseDef> testCases;
+
+ /** . */
+ private Method create;
+
+ /** . */
+ private Method destroy;
+
+ /** . */
+ private Map<String, PropertyTestParameter> parameters;
+
+ /** . */
+ private Map<String, ParameterDescriptor> parameterDescriptors;
+
+ /** . */
+ private Map<String, TestCaseDescriptor> testCasesDescriptors;
+
+ /** . */
+ private Constructor ctor;
+
+ public TestHandlerSupport(Class testClass)
+ {
+ if (testClass == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (Modifier.isAbstract(testClass.getModifiers()))
+ {
+ throw new IllegalArgumentException("Test class is abstract");
+ }
+
+ // Check constructor
+ try
+ {
+ ctor = testClass.getConstructor();
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+
+ //
+ Test testAnnotation = ((AnnotatedElement)testClass).getAnnotation(Test.class);
+ suiteName = testAnnotation != null ? testAnnotation.name() : "";
+ if (suiteName.length() == 0)
+ {
+ suiteName = testClass.getName();
+ }
+
+ //
+ Description descriptionAnnotation = ((AnnotatedElement)testClass).getAnnotation(Description.class);
+ suiteDescription = descriptionAnnotation != null ? descriptionAnnotation.description() : "";
+ if (suiteDescription.length() == 0)
+ {
+ suiteDescription = "Test of class " + testClass.getName();
+ }
+
+ //
+ SortedMap<MethodKey, Method> methods = new TreeMap<MethodKey, Method>();
+ for (Method method : testClass.getMethods())
+ {
+ MethodKey key = new MethodKey(method);
+ methods.put(key, method);
+ }
+
+ //
+ parameters = new HashMap<String, PropertyTestParameter>();
+ testCases = new HashMap<String, TestCaseDef>();
+
+ //
+ for (Method method : methods.values())
+ {
+ String methodName = method.getName();
+ int modifiers = method.getModifiers();
+
+ //
+ Parameter parameterMethodAnnotation = method.getAnnotation(Parameter.class);
+
+ //
+ Test testMethodAnnotation = method.getAnnotation(Test.class);
+
+ //
+ if (testMethodAnnotation != null && parameterMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ Create createMethodAnnotation = method.getAnnotation(Create.class);
+
+ //
+ if (createMethodAnnotation != null && parameterMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (createMethodAnnotation != null && testMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ Destroy destroyMethodAnnotation = method.getAnnotation(Destroy.class);
+
+ //
+ if (destroyMethodAnnotation != null && parameterMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (destroyMethodAnnotation != null && testMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (destroyMethodAnnotation != null && createMethodAnnotation != null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (parameterMethodAnnotation != null)
+ {
+ if (!methodName.startsWith("set"))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (methodName.length() < 4)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getParameterTypes().length != 1)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String name = parameterMethodAnnotation.name();
+ if (name.length() == 0)
+ {
+ name = Introspector.decapitalize(method.getName().substring(3));
+ }
+
+ //
+ Description descriptionMethodAnnotation = method.getAnnotation(Description.class);
+ String description = descriptionMethodAnnotation != null ? descriptionMethodAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Parameter " + name;
+ }
+
+ //
+ PropertyTestParameter parameter = parameters.get(name);
+ if (parameter == null)
+ {
+ parameter = new PropertyTestParameter(name, description);
+ parameters.put(name, parameter);
+ }
+
+ //
+ parameter.addSetter(method);
+ }
+ else if (testMethodAnnotation != null)
+ {
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ LinkedHashMap<String, ArgumentTestParameter> argumentParameters = new LinkedHashMap<String, ArgumentTestParameter>();
+ for (Annotation[] parameterAnnotations : method.getParameterAnnotations())
+ {
+ Map<Class<? extends Annotation>,Annotation> parameterAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation parameterAnnotation : parameterAnnotations)
+ {
+ Class<? extends Annotation> blah = parameterAnnotation.annotationType();
+ parameterAnnotationMap.put(blah, parameterAnnotation);
+ }
+
+ //
+ Parameter argumentParameterAnnotation = (Parameter)parameterAnnotationMap.get(Parameter.class);
+
+ //
+ if (argumentParameterAnnotation != null)
+ {
+ //
+ String name = argumentParameterAnnotation.name();
+ if (name.length() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (argumentParameters.containsKey(name))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Description descriptionArgumentParameterAnnotation = (Description)parameterAnnotationMap.get(Description.class);
+ String description = descriptionArgumentParameterAnnotation != null ? descriptionArgumentParameterAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Method parameter " + name;
+ }
+
+ //
+ argumentParameters.put(name, new ArgumentTestParameter(name, description));
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ //
+ String name = testMethodAnnotation.name();
+ if (testMethodAnnotation.name().length() == 0)
+ {
+ name = method.getName();
+ }
+
+ //
+ Description descriptionMethodAnnotation = method.getAnnotation(Description.class);
+ String description = descriptionMethodAnnotation != null ? descriptionMethodAnnotation.description() : "";
+ if (description.length() == 0)
+ {
+ description = "Test of method " + method.getName();
+ }
+
+ //
+ TestCaseDef testCaseDef = new TestCaseDef(method, name, description, argumentParameters);
+
+ //
+ if (testCases.put(testCaseDef.getName(), testCaseDef) != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ else if (createMethodAnnotation != null)
+ {
+ if (create != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getParameterTypes().length > 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ create = method;
+ }
+ else if (destroyMethodAnnotation != null)
+ {
+ if (destroy != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getReturnType() != void.class)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isAbstract(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!Modifier.isPublic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (Modifier.isStatic(modifiers))
+ {
+ throw new IllegalArgumentException();
+ }
+ if (method.getParameterTypes().length > 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ destroy = method;
+ }
+ }
+
+ // Init parameter descriptors
+ parameterDescriptors = buildDescriptorMap(parameters);
+
+ //
+ testCasesDescriptors = new LinkedHashMap<String, TestCaseDescriptor>();
+ for (TestCaseDef testCaseDef : testCases.values())
+ {
+ TestCaseDescriptor testCaseDescriptor = new TestCaseDescriptor(testCaseDef.getName());
+ testCaseDescriptor.setDescription(testCaseDef.name);
+ Map<String, ParameterDescriptor> merge = new LinkedHashMap<String, ParameterDescriptor>();
+ merge.putAll(parameterDescriptors);
+ merge.putAll(buildDescriptorMap(testCaseDef.parameters));
+ testCaseDescriptor.setParameters(merge);
+ testCasesDescriptors.put(testCaseDescriptor.getName(), testCaseDescriptor);
+ }
+ }
+
+ private static Map<String, ParameterDescriptor> buildDescriptorMap(Map<String, ? extends TestParameter> parameters)
+ {
+ Map<String, ParameterDescriptor> parameterDescriptors = new LinkedHashMap<String, ParameterDescriptor>();
+ for (TestParameter parameter : parameters.values())
+ {
+ ParameterDescriptor parameterDescriptor = new ParameterDescriptor(parameter.getName());
+ parameterDescriptor.setDescription(parameter.getDescription());
+ parameterDescriptor.setDefaultValues(new ArrayList<String>());
+ parameterDescriptors.put(parameter.getName(), parameterDescriptor);
+ }
+ return parameterDescriptors;
+ }
+
+ public String getName()
+ {
+ return suiteName;
+ }
+
+ public String getDescription()
+ {
+ return suiteDescription;
+ }
+
+ public Map<String, ParameterDescriptor> getParameters()
+ {
+ return parameterDescriptors;
+ }
+
+ public Map<String, TestCaseDescriptor> getTestCases()
+ {
+ return testCasesDescriptors;
+ }
+
+ public Object newTestCase(String name) throws TestCaseLifeCycleException
+ {
+ TestCaseDef testCaseDef = testCases.get(name);
+
+ //
+ if (testCaseDef == null)
+ {
+ throw new TestCaseLifeCycleException();
+ }
+
+ //
+ Object instance;
+ try
+ {
+ instance = ctor.newInstance();
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case " + name, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter " + name, e);
+ }
+
+ //
+ return new TestCase(testCaseDef, instance);
+ }
+
+ public void testCaseParametrize(Object _testCase, Map<String,String> parametrization) throws TestCaseLifeCycleException
+ {
+ TestCase testCase = (TestCase)_testCase;
+
+ // Save parametrization
+ testCase.parametrization = parametrization;
+
+ //
+ for (PropertyTestParameter parameter : parameters.values())
+ {
+ if (!parametrization.containsKey(parameter.getName()))
+ {
+ throw new TestCaseLifeCycleException("Missing parameter " + parameter.getName());
+ }
+ String parameterValue = parametrization.get(parameter.getName());
+ for (Method setter : parameter.setters)
+ {
+ try
+ {
+ setter.invoke(testCase.pojo, parameterValue);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter " + parameter.getName(), e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot configure parameter " + parameter.getName(), e);
+ }
+ }
+ }
+ }
+
+ public void testCaseCreate(Object _testCase) throws TestCaseLifeCycleException
+ {
+ TestCase testCase = (TestCase)_testCase;
+
+ //
+ if (create != null)
+ {
+ try
+ {
+ create.invoke(testCase.pojo);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case", e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot create test case", e);
+ }
+ }
+ }
+
+ public void testCaseInvoke(Object _testCase) throws TestCaseLifeCycleException
+ {
+ TestCase testCase = (TestCase)_testCase;
+
+ List<Object> argList = new ArrayList<Object>();
+ for (String parameterName : testCase.def.parameters.keySet())
+ {
+ if (!testCase.parametrization.containsKey(parameterName))
+ {
+ throw new TestCaseLifeCycleException("Missing parameter " + parameterName);
+ }
+ String parameterValue = testCase.parametrization.get(parameterName);
+ if (parameterValue == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ argList.add(parameterValue);
+ }
+ Object[] args = argList.toArray();
+
+ try
+ {
+ testCase.def.method.invoke(testCase.pojo, args);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TestCaseLifeCycleException("Cannot invoke test case", e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TestCaseLifeCycleException("Cannot invoke test case", e);
+ }
+ }
+
+ public void testCaseDestroy(Object _testCase)
+ {
+ TestCase testCase = (TestCase)_testCase;
+
+ //
+ if (destroy != null)
+ {
+ try
+ {
+ destroy.invoke(testCase.pojo);
+ }
+ catch (Throwable t)
+ {
+ // Log this as a warn
+ // t.printStackTrace();
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/TestParameter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo;
+
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+class TestParameter
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String description;
+
+ public TestParameter(String name, String description)
+ {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public List<String> getDefaultValues()
+ {
+ return Collections.emptyList();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Create.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Create.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Create.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Annotates a method to be aware of the create life cycle phase.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD})
+public @interface Create
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/DefaultValues.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/DefaultValues.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/DefaultValues.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+/**
+ * Not used yet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface DefaultValues
+{
+ String[] values() default {};
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Description.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Description.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Description.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Describe an item with this annotation.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE, ElementType.METHOD,ElementType.PARAMETER})
+public @interface Description
+{
+
+ String description();
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Destroy.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Destroy.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Destroy.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Annotates a method to be aware of the destroy life cycle phase.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD})
+public @interface Destroy
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Parameter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Parameter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Parameter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD,ElementType.PARAMETER})
+public @interface Parameter
+{
+
+ /**
+ * The name of the parameter.
+ *
+ * @return the name of the parameter
+ */
+ String name() default "";
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Tag.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE,ElementType.METHOD})
+public @interface Tag
+{
+
+ String[] value();
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Test.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Test.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Test.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.annotations;
+
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Denotes something we want to test having an optional name and description.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE,ElementType.METHOD})
+public @interface Test
+{
+
+ String name() default "";
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/junit/JUnitTestHandler.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.api.pojo.junit;
+
+import org.jboss.unit.api.pojo.TestHandler;
+import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+
+import java.util.Map;
+
+/**
+ * @todo
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JUnitTestHandler implements TestHandler
+{
+
+ public String getName()
+ {
+ return null;
+ }
+
+ public String getDescription()
+ {
+ return null;
+ }
+
+ public Map<String, ParameterDescriptor> getParameters()
+ {
+ return null;
+ }
+
+ public Map<String, TestCaseDescriptor> getTestCases()
+ {
+ return null;
+ }
+
+ public Object newTestCase(String name) throws TestCaseLifeCycleException
+ {
+ return null;
+ }
+
+ public void testCaseParametrize(Object testCase, Map<String, String> parametrization) throws TestCaseLifeCycleException
+ {
+
+ }
+
+ public void testCaseCreate(Object testCase) throws TestCaseLifeCycleException
+ {
+
+ }
+
+ public void testCaseInvoke(Object testCase) throws TestCaseLifeCycleException
+ {
+
+ }
+
+ public void testCaseDestroy(Object testCase)
+ {
+
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverCommand.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverCommand.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverCommand.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DriverCommand implements Serializable
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DriverResponse
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+/**
+ * Defines what a test driver is.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestDriver
+{
+
+ /**
+ * Return a runtime meta data about this test driver.
+ *
+ * @return the description
+ */
+ TestInfo getInfo();
+
+ /**
+ * Execute a command of the testing protocol.
+ *
+ * @param id the test case id relative to this driver
+ * @param command the command to execute
+ * @return the response the response to the command
+ */
+ DriverResponse invoke(TestId id, DriverCommand command);
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/command/StartTestCommand.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/command/StartTestCommand.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/command/StartTestCommand.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver.command;
+
+import org.jboss.unit.driver.DriverCommand;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StartTestCommand extends DriverCommand
+{
+
+ /** The test parametrization. */
+ private Map<String,String> parametrization;
+
+ public StartTestCommand(Map<String,String> parametrization) throws IllegalArgumentException
+ {
+ if (parametrization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.parametrization = parametrization;
+ }
+
+ public StartTestCommand()
+ {
+ this.parametrization = new HashMap<String, String>();
+ }
+
+ public Map<String,String> getParametrization()
+ {
+ return parametrization;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/EndTestResponse.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/EndTestResponse.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/EndTestResponse.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver.response;
+
+import org.jboss.unit.driver.DriverResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EndTestResponse extends DriverResponse
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/FailureResponse.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/FailureResponse.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/response/FailureResponse.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.driver.response;
+
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.Failure;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FailureResponse extends DriverResponse
+{
+
+ /** . */
+ private Failure failure;
+
+ public FailureResponse(Failure failure)
+ {
+ this.failure = failure;
+ }
+
+ public FailureResponse(FailureType type)
+ {
+ this(new Failure(new Throwable(), type));
+ }
+
+ public Failure getFailure()
+ {
+ return failure;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/info/ParameterInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/info/ParameterInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/info/ParameterInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.info;
+
+import java.util.List;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ParameterInfo extends Serializable
+{
+
+ /**
+ * The parameter name.
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * The parameter description.
+ *
+ * @return the description
+ */
+ String getDescription();
+
+ /**
+ * Return the list of values that should be used for the test.
+ * @return
+ */
+ List<String> getDefaultValues();
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/info/TestCaseInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/info/TestCaseInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/info/TestCaseInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.info;
+
+/**
+ * An executable test.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestCaseInfo extends TestInfo
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/info/TestInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.info;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Describe something we can test.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestInfo extends Serializable
+{
+
+ /**
+ * Returns the name.
+ *
+ * @return the name.
+ */
+ String getName();
+
+ /**
+ * Returns the description.
+ *
+ * @return the description
+ */
+ String getDescription();
+
+ /**
+ * Return a map of parameters.
+ *
+ * @return the parameters
+ */
+ Map<String,? extends ParameterInfo> getParameters();
+
+ /**
+ * Returns the set of tags.
+ *
+ * @return the set of tags
+ */
+ Set<String> getTags();
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/info/TestSuiteInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/info/TestSuiteInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/info/TestSuiteInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.info;
+
+import org.jboss.unit.TestId;
+
+import java.util.Set;
+
+/**
+ * A suite of tests.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestSuiteInfo extends TestInfo
+{
+
+ /**
+ * Returns a specified item info or null if it does not exist.
+ *
+ * @param name the item name
+ * @return an item info
+ */
+ TestInfo getTest(String name);
+
+ /**
+ * Returns the item names.
+ *
+ * @return the item names.
+ */
+ Set<String> getNames();
+
+ /**
+ * Find a specific item from the specified id, relative to this object or null if it does not exist.
+ *
+ * @param id the relative id
+ * @return an item info
+ */
+ TestInfo findTest(TestId id);
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.report.junit;
+
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.TestRunnerEvent;
+
+/**
+ * @todo
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JUnitReporter implements TestRunnerEventListener
+{
+
+ public void onEvent(TestRunnerEvent event)
+ {
+
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.report.junit;
+
+/**
+ * <p> Interface groups XML constants.
+ * Interface that groups all constants used throughout the <tt>XML</tt>
+ * documents that are generated by the <tt>XMLJUnitResultFormatter</tt>
+ * As of now the DTD is:
+ * <code><pre>
+ *
+ * </pre></code>
+ */
+public class XMLConstants {
+
+ /** the testsuites element for the aggregate document */
+ public static final String TESTSUITES = "testsuites";
+
+ /** the testsuite element */
+ public static final String TESTSUITE = "testsuite";
+
+ /** the testcase element */
+ public static final String TESTCASE = "testcase";
+
+ /** the error element */
+ public static final String ERROR = "error";
+
+ /** the failure element */
+ public static final String FAILURE = "failure";
+
+ /** the system-err element */
+ public static final String SYSTEM_ERR = "system-err";
+
+ /** the system-out element */
+ public static final String SYSTEM_OUT = "system-out";
+
+ /** package attribute for the aggregate document */
+ public static final String ATTR_PACKAGE = "package";
+
+ /** name attribute for property, testcase and testsuite elements */
+ public static final String ATTR_NAME = "name";
+
+ /** time attribute for testcase and testsuite elements */
+ public static final String ATTR_TIME = "time";
+
+ /** errors attribute for testsuite elements */
+ public static final String ATTR_ERRORS = "errors";
+
+ /** failures attribute for testsuite elements */
+ public static final String ATTR_FAILURES = "failures";
+
+ /** tests attribute for testsuite elements */
+ public static final String ATTR_TESTS = "tests";
+
+ /** type attribute for failure and error elements */
+ public static final String ATTR_TYPE = "type";
+
+ /** message attribute for failure elements */
+ public static final String ATTR_MESSAGE = "message";
+
+ /** the properties element */
+ public static final String PROPERTIES = "properties";
+
+ /** the property element */
+ public static final String PROPERTY = "property";
+
+ /** value attribute for property elements */
+ public static final String ATTR_VALUE = "value";
+
+ /** classname attribute for testcase elements */
+ public static final String ATTR_CLASSNAME = "classname";
+
+ /** id attribute */
+ public static final String ATTR_ID = "id";
+}
+
+/*
+ * Copyright 2001,2004-2005 The Apache Software Foundation
+ *
+ * Licensed 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+import org.jboss.unit.runner.filter.NullFilter;
+import org.jboss.unit.runner.event.TestRunnerEventBroadcasterSupport;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractTestRunner implements TestRunner
+{
+
+ /** . */
+ protected final TestRunnerEventBroadcasterSupport broadcaster;
+
+ protected AbstractTestRunner()
+ {
+ this(new TestRunnerEventBroadcasterSupport());
+ }
+
+ protected AbstractTestRunner(TestRunnerEventBroadcasterSupport broadcaster)
+ {
+ this.broadcaster = broadcaster;
+ }
+
+ public void addListener(TestRunnerEventListener listener)
+ {
+ broadcaster.addListener(listener);
+ }
+
+ public void removeListener(TestRunnerEventListener listener)
+ {
+ broadcaster.removeListener(listener);
+ }
+
+ protected final void fireEvent(TestRunnerEvent event)
+ {
+ broadcaster.fireEvent(event);
+ }
+
+ public final void run()
+ {
+ run(NullFilter.getInstance());
+ }
+
+ public final void run(TestFilter filter)
+ {
+ fireEvent(new StartRunnerEvent());
+ internalRun(filter);
+ fireEvent(new EndRunnerEvent());
+ }
+
+ protected abstract void internalRun(TestFilter filter);
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/Parametrization.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/Parametrization.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/Parametrization.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Parametrization implements Cloneable
+{
+
+ /** . */
+ private Map<String,String[]> map;
+
+ public Parametrization(Map<String, String[]> map)
+ {
+ this.map = map;
+ }
+
+ public Parametrization()
+ {
+ this.map = new HashMap<String, String[]>();
+ }
+
+ public void merge(Parametrization other)
+ {
+ for (Map.Entry<String,String[]> entry : other.map.entrySet())
+ {
+ if (!map.containsKey(entry.getKey()))
+ {
+ map.put(entry.getKey(), entry.getValue().clone());
+ }
+ }
+ }
+
+ public Parametrization clone()
+ {
+ try
+ {
+ return (Parametrization)super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ public List<Map<String,String>> enumerate(Set<String> expectedParameters)
+ {
+ // Clone so we can modify it safely
+ expectedParameters = expectedParameters != null ? new HashSet<String>(expectedParameters) : null;
+
+ //
+ List<Map<String,String>> enumeration = new ArrayList<Map<String, String>>();
+
+ //
+ enumeration.add(new HashMap<String, String>());
+
+ //
+ for (Map.Entry<String, String[]> entry : map.entrySet())
+ {
+ String parameterName = entry.getKey();
+
+ //
+ if (expectedParameters == null || expectedParameters.remove(parameterName))
+ {
+
+ List<Map<String,String>> tmp = new ArrayList<Map<String, String>>();
+
+ for (String occurrence : entry.getValue())
+ {
+ for (Map<String,String> blah : enumeration)
+ {
+ Map<String,String> copy = new HashMap<String,String>(blah);
+ copy.put(parameterName, occurrence);
+ tmp.add(copy);
+ }
+ }
+
+ enumeration = tmp;
+ }
+ }
+
+ //
+ return enumeration;
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestFilter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestFilter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestFilter
+{
+
+ /**
+ * Filter a test before execution.
+ *
+ * @param testId the test id
+ * @param testInfo the test info
+ * @return true if the test should be included
+ */
+ boolean include(TestId testId, TestInfo testInfo);
+
+ /**
+ * Filter a test before execution.
+ *
+ * @param testId the test id
+ * @param parametrization the test parametrization
+ * @param testInfo the test info
+ * @return true if the test should be included
+ */
+ boolean include(TestId testId, Map<String, String> parametrization, TestInfo testInfo);
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestResult.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+import java.util.Map;
+
+/**
+ * Base class for test results.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class TestResult
+{
+
+ /** . */
+ private long durationMillis;
+
+ /** . */
+ private Map<String,String> parametrization;
+
+ public TestResult(long durationMillis)
+ {
+ this.durationMillis = durationMillis;
+ }
+
+ public long getDurationMillis()
+ {
+ return durationMillis;
+ }
+
+ public Map<String,String> getParametrization()
+ {
+ return parametrization;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+/**
+ * The runtime interface for dealing with tests.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestRunner
+{
+
+ void addListener(TestRunnerEventListener listener);
+
+ void removeListener(TestRunnerEventListener listener);
+
+ void run();
+
+ void run(TestFilter filter);
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+/**
+ * Base class for test runner events.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class TestRunnerEvent
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventBroadcaster.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventBroadcaster.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventBroadcaster.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+/**
+ * A test runner event broadcaster.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestRunnerEventBroadcaster
+{
+ /**
+ * Fire an event through the broadcaster.
+ *
+ * @param event the event to fire
+ * @throws IllegalArgumentException if the event object is null
+ */
+ void fireEvent(TestRunnerEvent event) throws IllegalArgumentException;
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventListener.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventListener.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerEventListener.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner;
+
+/**
+ * Contract for being aware of what a test runner do.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestRunnerEventListener
+{
+
+ /**
+ * A test runner event occured.
+ *
+ * @param event the event
+ */
+ void onEvent(TestRunnerEvent event);
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndRunnerEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndRunnerEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndRunnerEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EndRunnerEvent extends TestRunnerEvent
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndTestEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndTestEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/EndTestEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestResult;
+import org.jboss.unit.TestId;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EndTestEvent extends TestRunnerEvent
+{
+
+ /** . */
+ private final TestId testId;
+
+ /** . */
+ private final TestResult testResult;
+
+ public EndTestEvent(TestId testId, TestResult testResult)
+ {
+ this.testId = testId;
+ this.testResult = testResult;
+ }
+
+ public TestId getTestId()
+ {
+ return testId;
+ }
+
+ public TestResult getTestResult()
+ {
+ return testResult;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/RunnerFailureEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.FailureType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RunnerFailureEvent extends TestRunnerEvent
+{
+
+ /** . */
+ private String message;
+
+ /** . */
+ private Throwable throwable;
+
+ /** . */
+ private FailureType type;
+
+ public RunnerFailureEvent(String message, FailureType type)
+ {
+ this.message = message;
+ this.type = type;
+ }
+
+ public RunnerFailureEvent(String message, FailureType type, Throwable throwable)
+ {
+ this.message = message;
+ this.type = type;
+ this.throwable = throwable;
+ }
+
+ public RunnerFailureEvent(Throwable throwable)
+ {
+ this.throwable = throwable;
+ }
+
+ public FailureType getLevel()
+ {
+ return type;
+ }
+
+ public String getMessage()
+ {
+ return message != null ? message : throwable.getMessage();
+ }
+
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartRunnerEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartRunnerEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartRunnerEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StartRunnerEvent extends TestRunnerEvent
+{
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestEvent.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestEvent.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestEvent.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class StartTestEvent extends TestRunnerEvent
+{
+
+ /** . */
+ private final TestId testId;
+
+ /** . */
+ private final TestInfo testInfo;
+
+ public StartTestEvent(TestId testId, TestInfo testInfo)
+ {
+ this.testId = testId;
+ this.testInfo = testInfo;
+ }
+
+ public TestId getTestId()
+ {
+ return testId;
+ }
+
+ public TestInfo getTestInfo()
+ {
+ return testInfo;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerEventBroadcasterSupport.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerEventBroadcasterSupport.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerEventBroadcasterSupport.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventBroadcaster;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Maintains a set of listeners that will receive events when the <code>fireEvent(TestRunnerEvent event)</code> method
+ * is invoked. When a listener method is invoked, any exception is caught and logged, this include checked and unchecked
+ * exception. Any other kind of unchecked throwable will not be handled.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRunnerEventBroadcasterSupport implements TestRunnerEventBroadcaster
+{
+
+ /** . */
+ private List<TestRunnerEventListener> listeners = new ArrayList<TestRunnerEventListener>();
+
+ /**
+ * Add a listener to the set of listeners.
+ *
+ * @param listener the listener to add
+ * @throws IllegalArgumentException if the listener is null
+ */
+ public void addListener(TestRunnerEventListener listener) throws IllegalArgumentException
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException("No null listener accepted");
+ }
+ if (!listeners.contains(listener))
+ {
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ * Remove a listener from the set of listeners.
+ *
+ * @param listener the listener to remove
+ * @throws IllegalArgumentException if the listener is null
+ */
+ public void removeListener(TestRunnerEventListener listener)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException("No null listener accepted");
+ }
+ if (listeners.contains(listener))
+ {
+ listeners.remove(listener);
+ }
+ }
+
+ public void fireEvent(TestRunnerEvent event)
+ {
+ if (event == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (TestRunnerEventListener listener : listeners)
+ {
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception e)
+ {
+// e.printStackTrace();
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerLifeCycleFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerLifeCycleFilter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/TestRunnerLifeCycleFilter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.event;
+
+import org.jboss.unit.runner.TestRunnerEventBroadcaster;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventListener;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRunnerLifeCycleFilter implements TestRunnerEventListener
+{
+
+ /** . */
+ private final TestRunnerEventBroadcaster broadcaster;
+
+ public TestRunnerLifeCycleFilter(TestRunnerEventBroadcaster broadcaster)
+ {
+ this.broadcaster = broadcaster;
+ }
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ if (event instanceof StartRunnerEvent || event instanceof EndRunnerEvent)
+ {
+ return;
+ }
+ broadcaster.fireEvent(event);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/filter/NullFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/filter/NullFilter.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/filter/NullFilter.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.filter;
+
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NullFilter implements TestFilter
+{
+
+ /** . */
+ private static final NullFilter instance = new NullFilter();
+
+ public static NullFilter getInstance()
+ {
+ return instance;
+ }
+
+ public boolean include(TestId testId, TestInfo testInfo)
+ {
+ return true;
+ }
+
+ public boolean include(TestId testId, Map<String, String> parametrization, TestInfo testInfo)
+ {
+ return true;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.composite;
+
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
+
+import java.util.Collection;
+
+/**
+ * A composite test runner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompositeTestRunner extends AbstractTestRunner
+{
+
+ /** . */
+ private final Collection<TestRunner> runners;
+
+ /** . */
+ private final TestRunnerLifeCycleFilter lifeCycleFilter;
+
+ public CompositeTestRunner(Collection<TestRunner> runners)
+ {
+ this.runners = runners;
+ this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
+ }
+
+ public void internalRun(TestFilter filter)
+ {
+ for (TestRunner runner : runners)
+ {
+ try
+ {
+ runner.addListener(lifeCycleFilter);
+
+ //
+ runner.run(filter);
+ }
+ finally
+ {
+ runner.removeListener(lifeCycleFilter);
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.driver;
+
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.info.TestCaseInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.TestId;
+import org.jboss.unit.Failure;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.runner.results.TestSuccess;
+import org.jboss.unit.runner.results.TestFailure;
+import org.jboss.unit.runner.event.StartTestEvent;
+import org.jboss.unit.runner.event.EndTestEvent;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.TestResult;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * An implementation that uses a test driver and transform test driver
+ * interactions into runner interactions.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDriverRunner extends AbstractTestRunner
+{
+
+ /** . */
+ private final TestDriver driver;
+
+ /** . */
+ private final Map<String,String> parametrization;
+
+ /** . */
+ private final TestId testId;
+
+ public TestDriverRunner(TestDriver driver, Map<String,String> parametrization, TestId testId)
+ {
+ this.driver = driver;
+ this.parametrization = parametrization;
+ this.testId = testId;
+ }
+
+ public TestDriverRunner(TestDriver driver, TestId testId)
+ {
+ this(driver, new HashMap<String, String>(), testId);
+ }
+
+ public void internalRun(TestFilter filter)
+ {
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+
+ //
+ TestInfo testInfo = info.findTest(testId);
+
+ //
+ if (filter.include(testId, testInfo))
+ {
+
+ if (testInfo instanceof TestCaseInfo)
+ {
+
+ TestCaseInfo testCaseInfo = (TestCaseInfo)testInfo;
+
+ fireEvent(new StartTestEvent(testId, testCaseInfo));
+
+ DriverResponse response = driver.invoke(testId, new StartTestCommand(parametrization));
+
+ TestResult result = null;
+
+ if (response instanceof EndTestResponse)
+ {
+ result = new TestSuccess(0);
+ }
+ else if (response instanceof FailureResponse)
+ {
+ FailureResponse failureResponse = (FailureResponse)response;
+ Failure failure = failureResponse.getFailure();
+ result = new TestFailure(failure, 0);
+ }
+
+ //
+ fireEvent(new EndTestEvent(testId, result));
+ }
+ else
+ {
+ fireEvent(new RunnerFailureEvent("Cannot execute test id " + testId, FailureType.ERROR));
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.event;
+
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestFilter;
+
+import java.util.Collection;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EventDrivenTestRunner extends AbstractTestRunner
+{
+
+ /** . */
+ private Collection<TestRunnerEvent> events;
+
+ public EventDrivenTestRunner(TestRunnerEvent... events)
+ {
+ this.events = Arrays.asList(events);
+ }
+
+ public EventDrivenTestRunner(Collection<TestRunnerEvent> events)
+ {
+ this.events = events;
+ }
+
+ public void internalRun(TestFilter filter)
+ {
+ for (TestRunnerEvent event : events)
+ {
+ fireEvent(event);
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestCaseInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.failure;
+
+import org.jboss.unit.info.TestCaseInfo;
+import org.jboss.unit.info.ParameterInfo;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FailureTestCaseInfo implements TestCaseInfo
+{
+
+ /** . */
+ private final String name;
+
+ public FailureTestCaseInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return "No description for test " + name;
+ }
+
+ public Map<String, ? extends ParameterInfo> getParameters()
+ {
+ return Collections.emptyMap();
+ }
+
+ public Set<String> getTags()
+ {
+ return Collections.emptySet();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.failure;
+
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestResult;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FailureTestRunner extends AbstractTestRunner
+{
+
+ private TestResult result;
+
+ /** . */
+ private final TestId testId;
+
+ /** . */
+ private final TestInfo testInfo;
+
+ public FailureTestRunner(TestId prefix, String name)
+ {
+ this.testId = new TestId(prefix, name);
+ this.testInfo = new FailureTestCaseInfo(name);
+ }
+
+ public void internalRun(TestFilter filter)
+ {
+ if (filter.include(testId, null, testInfo))
+ {
+// failures.add(new StartTestEvent(tmp, new ));
+// failures.add(new EndTestEvent(blah, new TestError(e, 0)));
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.impl.pojo;
+
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.Parametrization;
+import org.jboss.unit.runner.impl.driver.TestDriverRunner;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
+import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
+import org.jboss.unit.runner.model.pojo.TestDefDef;
+import org.jboss.unit.runner.model.pojo.TestClassDef;
+import org.jboss.unit.runner.model.pojo.TestCaseDef;
+import org.jboss.unit.runner.model.TestDef;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.info.TestCaseInfo;
+import org.jboss.unit.unit.pojo.POJOTestSuiteDriver;
+import org.jboss.unit.driver.TestDriver;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestRunner extends AbstractTestRunner
+{
+
+ /** . */
+ private final POJOTestSuiteDef suite;
+
+ /** . */
+ private final TestRunnerLifeCycleFilter lifeCycleFilter;
+
+ public POJOTestRunner(POJOTestSuiteDef suiteDef)
+ {
+ this.suite = suiteDef;
+ this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
+ }
+
+ protected void internalRun(TestFilter filter)
+ {
+ for (TestDef test : suite.getTests())
+ {
+ // Get def id
+ String testDefId = test.getRefId();
+
+ //
+ if (testDefId != null)
+ {
+ // Get related test definition
+ TestDefDef testDef = suite.getTestDef(testDefId);
+
+ //
+ if (testDef != null)
+ {
+ TestClassDef testClass = testDef.getTestClass();
+ String className = testClass.getName();
+
+ //
+ try
+ {
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+
+ //
+ TestDriver driver = new POJOTestSuiteDriver(clazz);
+ TestSuiteInfo testSuiteInfo = (TestSuiteInfo)driver.getInfo();
+
+ //
+ List<String> testCaseNames = new ArrayList<String>();
+ for (TestCaseDef testCase : testClass.getTestCases())
+ {
+ testCaseNames.add(testCase.getName());
+ }
+ if (testCaseNames.size() == 0)
+ {
+ testCaseNames.addAll(testSuiteInfo.getNames());
+ }
+
+ // Create parametrization
+
+
+ Parametrization parametrization = suite.getParameters().getParametrization();
+ parametrization.merge(test.getParameters().getParametrization());
+// Map<String,Iterable<String>> generator = new HashMap<String, Iterable<String>>();
+
+
+ //
+ for (String testCaseName : testCaseNames)
+ {
+ TestId testCaseId = new TestId(testCaseName);
+
+ TestCaseInfo testCaseInfo = (TestCaseInfo)testSuiteInfo.findTest(testCaseId);
+
+ for (Map<String,String> blah : parametrization.enumerate(testCaseInfo.getParameters().keySet()))
+ {
+ TestDriverRunner runner = new TestDriverRunner(driver, blah, testCaseId);
+ runner.addListener(lifeCycleFilter);
+ runner.run(filter);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ fireEvent(new RunnerFailureEvent("Cannot execute test id " + testDefId, FailureType.ERROR,e));
+ }
+ }
+ else
+ {
+ fireEvent(new RunnerFailureEvent("No test definition found for id " + testDefId, FailureType.ERROR));
+ }
+ }
+ else
+ {
+ fireEvent(new RunnerFailureEvent("No test definition found for id " + testDefId, FailureType.ERROR));
+ }
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/BuilderException.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/BuilderException.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/BuilderException.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BuilderException extends Exception
+{
+ public BuilderException()
+ {
+ }
+
+ public BuilderException(String string)
+ {
+ super(string);
+ }
+
+ public BuilderException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public BuilderException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/Constants.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/Constants.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/Constants.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class Constants
+{
+
+ public static final String JBOSS_UNIT_SYSTEM_ID = "http://www.jboss.org/portal/dtd/jboss-unit.dtd";
+
+ public static final String RELATIVE_RESOURCE_NAME = "jboss-unit.dtd";
+
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,332 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+
+import static org.jboss.unit.util.XMLTools.*;
+import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
+import org.jboss.unit.runner.model.pojo.TestClassDef;
+import org.jboss.unit.runner.model.pojo.TestCaseDef;
+import org.jboss.unit.runner.model.TestDef;
+import org.jboss.unit.runner.model.ParametersDef;
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.DocumentBuilder;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Builds a test suite from an XML stream.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ModelBuilder
+{
+
+ /** . */
+ private final Element rootElt;
+
+ /** . */
+ private static final EntityResolver resolver = new EntityResolver()
+ {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ if (Constants.JBOSS_UNIT_SYSTEM_ID.equals(systemId))
+ {
+ InputStream in = ModelBuilder.class.getResourceAsStream(Constants.RELATIVE_RESOURCE_NAME);
+ if (in != null)
+ {
+ return new InputSource(in);
+ }
+ }
+ return null;
+ }
+ };
+
+ public ModelBuilder(InputSource source) throws ParserConfigurationException, IOException, SAXException
+ {
+ if (source == null)
+ {
+ throw new IllegalArgumentException("No null source allowed");
+ }
+
+ //
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(resolver);
+ Document doc = builder.parse(source);
+
+ //
+ this.rootElt = doc.getDocumentElement();
+ }
+ catch (SAXParseException e)
+ {
+ System.out.println("Parse exception at line " + e.getLineNumber() + " and column " + e.getColumnNumber() + ": " + e.getMessage());
+ throw e;
+ }
+ }
+
+ public ModelBuilder(Element rootElt)
+ {
+ if (rootElt == null)
+ {
+ throw new IllegalArgumentException("No null suite element allowed");
+ }
+
+ //
+ this.rootElt = rootElt;
+ }
+
+ public TestSuiteDef build()
+ {
+ return buildTestSuite(rootElt);
+ }
+
+ private TestSuiteDef buildTestSuite(Element suiteElt)
+ {
+ if (suiteElt.getNodeName().equals("jboss-unit") || suiteElt.getNodeName().equals("suite"))
+ {
+ CompositeTestSuiteDef composite = new CompositeTestSuiteDef();
+ for (Element childSuiteElt : children(suiteElt))
+ {
+ TestSuiteDef childSuite = buildTestSuite(childSuiteElt);
+ composite.addSuite(childSuite);
+ }
+ return composite;
+ }
+ else if (suiteElt.getNodeName().equals("pojo"))
+ {
+ return buildPOJOTestSuite(suiteElt);
+ }
+
+ //
+ throw new AssertionError();
+ }
+
+ private TestClassDef buildTestClassDef(Element classElt)
+ {
+ Node nameAttr = classElt.getAttributes().getNamedItem("name");
+ if (nameAttr == null || !(nameAttr instanceof Attr))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String classname = ((Attr)nameAttr).getValue();
+ TestClassDef testClass = new TestClassDef(classname);
+
+ //
+ for (Element caseElt : children(classElt, "case"))
+ {
+
+ Node caseNameAttr = caseElt.getAttributes().getNamedItem("name");
+ if (caseNameAttr == null || !(caseNameAttr instanceof Attr))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ testClass.addTestCase(new TestCaseDef(((Attr)caseNameAttr).getValue()));
+ }
+
+ //
+ return testClass;
+ }
+
+ private TestSuiteDef buildPOJOTestSuite(Element suiteElt)
+ {
+ POJOTestSuiteDef suite = new POJOTestSuiteDef();
+
+ //
+ for (Element testDefElt : children(suiteElt, "test-def"))
+ {
+ Node idAttr = testDefElt.getAttributes().getNamedItem("id");
+ if (idAttr == null || !(idAttr instanceof Attr))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String id = ((Attr)idAttr).getValue();
+
+ //
+ Element classElt = child(testDefElt, "class");
+ if (classElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ TestClassDef testClass = buildTestClassDef(classElt);
+
+ //
+ org.jboss.unit.runner.model.pojo.TestDefDef testDef = new org.jboss.unit.runner.model.pojo.TestDefDef(id);
+ testDef.setTestClass(testClass);
+
+ //
+ suite.addDef(testDef);
+ }
+
+ //
+ for (Element testElt : children(suiteElt, "test"))
+ {
+ Node refidAttr = testElt.getAttributes().getNamedItem("refid");
+ Element classElt = child(testElt, "class");
+
+ //
+ String refid;
+
+ //
+ if (refidAttr != null)
+ {
+ if (!(refidAttr instanceof Attr))
+ {
+ throw new IllegalArgumentException();
+ }
+ refid = ((Attr)refidAttr).getValue();
+ }
+ else if (classElt != null)
+ {
+ String id = "blah";
+
+ TestClassDef testClass = buildTestClassDef(classElt);
+
+ org.jboss.unit.runner.model.pojo.TestDefDef testDef = new org.jboss.unit.runner.model.pojo.TestDefDef(id);
+
+ testDef.setTestClass(testClass);
+
+ suite.addDef(testDef);
+
+ refid = id;
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ TestDef test = new TestDef(refid);
+
+ //
+ test.setParameters(buildParameters(testElt));
+
+ //
+ suite.addTest(test);
+ }
+
+ //
+ suite.setParameters(buildParameters(suiteElt));
+
+ //
+ return suite;
+ }
+
+ private static final int NO_SOURCE = 0;
+ private static final int ELEMENT_SOURCE = 1;
+ private static final int ATTRIBUTE_SOURCE = 2;
+
+ private ParametersDef buildParameters(Element parameterEltContainer)
+ {
+ ParametersDef parameters = new ParametersDef();
+ for (Element parameterElt : children(parameterEltContainer, "parameter"))
+ {
+ String parameterName = parameterElt.getAttribute("name");
+
+ List<String> values = new ArrayList<String>();
+
+ Attr attr = (Attr)parameterElt.getAttributes().getNamedItem("value");
+
+ int src = NO_SOURCE;
+
+ if (attr != null)
+ {
+ src = ATTRIBUTE_SOURCE;
+ values.add(attr.getValue());
+ }
+
+ NodeList children = parameterElt.getChildNodes();
+
+ for (int i = 0;i < children.getLength();i++)
+ {
+ Node child = children.item(i);
+ switch(child.getNodeType())
+ {
+ case Node.ELEMENT_NODE:
+ Element elt = (Element)child;
+ if (src == ATTRIBUTE_SOURCE)
+ {
+ throw new IllegalArgumentException();
+ }
+ src = ELEMENT_SOURCE;
+ String eltName = elt.getNodeName();
+ if ("value".equals(eltName))
+ {
+ values.add(text(elt));
+ }
+ else if ("null".equals(eltName))
+ {
+ values.add(null);
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ break;
+ }
+ }
+
+
+ if (values.size() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ ParameterValueDef parameterValue = new ParameterValueDef(values);
+
+ parameters.setParameter(parameterName, parameterValue);
+
+ }
+
+ return parameters;
+ }
+
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParameterValueDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParameterValueDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParameterValueDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+import org.jboss.unit.util.CollectionTools;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterValueDef implements Iterable<String>
+{
+
+ /** . */
+ private List<String> list;
+
+ public ParameterValueDef(String... ts)
+ {
+ this(CollectionTools.list(ts));
+ }
+
+ public ParameterValueDef(Iterable<String> iterable)
+ {
+ if (iterable == null)
+ {
+ throw new IllegalArgumentException("No null iterable should be provided");
+ }
+ ArrayList<String> list = new ArrayList<String>();
+ for (String s : iterable)
+ {
+ list.add(s);
+ }
+ this.list = list;
+ }
+
+ public List<String> list()
+ {
+ return list;
+ }
+
+ public Iterator<String> iterator()
+ {
+ return list.iterator();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParametersDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParametersDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ParametersDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+import org.jboss.unit.runner.Parametrization;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * A set of parameters.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParametersDef
+{
+
+ /** . */
+ private final Map<String, ParameterValueDef> map = new HashMap<String, ParameterValueDef>();
+
+ public void setParameter(String name, String value)
+ {
+ setParameter(name, new ParameterValueDef(value));
+ }
+
+ public void setParameter(String name, ParameterValueDef value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null parameter name");
+ }
+ if (value == null)
+ {
+ map.remove(name);
+ }
+ else
+ {
+ map.put(name, value);
+ }
+ }
+
+ public void removeParameter(String name)
+ {
+ setParameter(name, (ParameterValueDef)null);
+ }
+
+ public ParameterValueDef getParameter(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null parameter name");
+ }
+
+ //
+ return map.get(name);
+ }
+
+ public Set<String> getNames()
+ {
+ return map.keySet();
+ }
+
+ public Parametrization getParametrization()
+ {
+ Map<String,String[]> tmp = new HashMap<String,String[]>();
+ for (Map.Entry<String,ParameterValueDef> entry : map.entrySet())
+ {
+ tmp.put(entry.getKey(), entry.getValue().list().toArray(new String[0]));
+ }
+ return new Parametrization(tmp);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDef
+{
+
+ /** . */
+ private String refId;
+
+ /** . */
+ private ParametersDef parameters = new ParametersDef();
+
+ public TestDef(String testId)
+ {
+ if (testId == null)
+ {
+ throw new IllegalArgumentException("No null test id accepted");
+ }
+ this.refId = testId;
+ }
+
+ public String getRefId()
+ {
+ return refId;
+ }
+
+ public ParametersDef getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ParametersDef parameters)
+ {
+ this.parameters = parameters;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model;
+
+import org.jboss.unit.runner.TestRunner;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class TestSuiteDef
+{
+
+ /** The tests. */
+ protected final List<TestDef> tests = new ArrayList<TestDef>();
+
+ /** . */
+ protected ParametersDef parameters = new ParametersDef();
+
+ public void addTest(TestDef test)
+ {
+ if (test == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ tests.add(test);
+ }
+
+ public Collection<TestDef> getTests()
+ {
+ return tests;
+ }
+
+ public ParametersDef getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ParametersDef parameters)
+ {
+ this.parameters = parameters;
+ }
+
+ public abstract TestRunner createRunner() throws BuilderException;
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model.composite;
+
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.BuilderException;
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.impl.composite.CompositeTestRunner;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompositeTestSuiteDef extends TestSuiteDef
+{
+
+ /** The suites. */
+ protected final List<TestSuiteDef> suites = new ArrayList<TestSuiteDef>();
+
+ public void addSuite(TestSuiteDef suite)
+ {
+ if (suite == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ suites.add(suite);
+ }
+
+ public Collection<TestSuiteDef> getSuites()
+ {
+ return suites;
+ }
+
+ public TestRunner createRunner() throws BuilderException
+ {
+ List<TestRunner> runners = new ArrayList<TestRunner>();
+ for (TestSuiteDef suite : suites)
+ {
+ TestRunner runner = suite.createRunner();
+ runners.add(runner);
+ }
+ return new CompositeTestRunner(runners);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model.pojo;
+
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.BuilderException;
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.impl.pojo.POJOTestRunner;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestSuiteDef extends TestSuiteDef
+{
+
+ /** The definitions. */
+ private Map<String, TestDefDef> testDefs = new HashMap<String, TestDefDef>();
+
+ public void addDef(TestDefDef testDef)
+ {
+ if (testDef == null)
+ {
+ throw new IllegalArgumentException("No null test def accepted");
+ }
+ testDefs.put(testDef.getId(), testDef);
+ }
+
+ public Collection<TestDefDef> getTestDefs()
+ {
+ return testDefs.values();
+ }
+
+ public TestDefDef getTestDef(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null test def name accepted");
+ }
+ return testDefs.get(name);
+ }
+
+ public TestRunner createRunner() throws BuilderException
+ {
+ return new POJOTestRunner(this);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestCaseDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestCaseDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestCaseDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model.pojo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestCaseDef
+{
+
+ /** . */
+ private final String name;
+
+ public TestCaseDef(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model.pojo;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassDef
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private Map<String,TestCaseDef> testCases = new HashMap<String, TestCaseDef>();
+
+ public TestClassDef(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+
+ //
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Collection<TestCaseDef> getTestCases()
+ {
+ return testCases.values();
+ }
+
+ public void addTestCase(TestCaseDef testCaseDef)
+ {
+ if (testCaseDef == null)
+ {
+ throw new IllegalArgumentException("No null test case accepted");
+ }
+ testCases.put(testCaseDef.getName(), testCaseDef);
+ }
+
+ public TestCaseDef getTestCase(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null test case name accepted");
+ }
+ return testCases.get(name);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.model.pojo;
+
+/**
+ * The definition of a tested class.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDefDef
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private TestClassDef testClass;
+
+ public TestDefDef(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.id = id;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public TestClassDef getTestClass()
+ {
+ return testClass;
+ }
+
+ public void setTestClass(TestClassDef testClass)
+ {
+ this.testClass = testClass;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestFailure.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.results;
+
+import org.jboss.unit.Failure;
+import org.jboss.unit.runner.TestResult;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestFailure extends TestResult
+{
+
+ /** . */
+ private final Failure failure;
+
+ public TestFailure(Failure failure, long durationMillis)
+ {
+ super(durationMillis);
+
+ //
+ this.failure = failure;
+ }
+
+ public Failure getFailure()
+ {
+ return failure;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/results/TestSuccess.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.runner.results;
+
+import org.jboss.unit.runner.TestResult;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestSuccess extends TestResult
+{
+ public TestSuccess(long durationMillis)
+ {
+ super(durationMillis);
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOParameterInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.unit.pojo;
+
+import org.jboss.unit.api.pojo.ParameterDescriptor;
+import org.jboss.unit.info.ParameterInfo;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOParameterInfo implements ParameterInfo
+{
+
+ /** . */
+ private final ParameterDescriptor descriptor;
+
+ public POJOParameterInfo(ParameterDescriptor descriptor)
+ {
+ this.descriptor = descriptor;
+ }
+
+ public String getName()
+ {
+ return descriptor.getName();
+ }
+
+ public String getDescription()
+ {
+ return descriptor.getDescription();
+ }
+
+ public List<String> getDefaultValues()
+ {
+ return descriptor.getDefaultValues();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestCaseInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.unit.pojo;
+
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+import org.jboss.unit.info.TestCaseInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestCaseInfo extends POJOTestInfo implements TestCaseInfo
+{
+
+ /** . */
+ private TestCaseDescriptor descriptor;
+
+ public POJOTestCaseInfo(TestCaseDescriptor descriptor)
+ {
+ super(descriptor.getParameters());
+
+ //
+ this.descriptor = descriptor;
+ }
+
+ public String getName()
+ {
+ return descriptor.getName();
+ }
+
+ public String getDescription()
+ {
+ return descriptor.getDescription();
+ }
+
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.unit.pojo;
+
+import org.jboss.unit.info.ParameterInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.api.pojo.ParameterDescriptor;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class POJOTestInfo implements TestInfo
+{
+
+ /** . */
+ private Map<String,POJOParameterInfo> parameters;
+
+ public POJOTestInfo(Map<String,ParameterDescriptor> parameterDescriptors)
+ {
+ Map<String, POJOParameterInfo> parameters = new HashMap<String, POJOParameterInfo>();
+ for (ParameterDescriptor parameterDescriptor : parameterDescriptors.values())
+ {
+ POJOParameterInfo parameterInfo = new POJOParameterInfo(parameterDescriptor);
+ parameters.put(parameterInfo.getName(), parameterInfo);
+ }
+
+ //
+ this.parameters = parameters;
+ }
+
+ public Map<String, ? extends ParameterInfo> getParameters()
+ {
+ return parameters;
+ }
+
+ public Set<String> getTags()
+ {
+ return Collections.emptySet();
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteDriver.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.unit.pojo;
+
+import org.jboss.unit.api.pojo.TestHandler;
+import org.jboss.unit.api.pojo.TestHandlerSupport;
+import org.jboss.unit.api.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.TestId;
+import org.jboss.unit.Failure;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestSuiteDriver implements TestDriver
+{
+
+ /** . */
+ private TestHandler handler;
+
+ /** . */
+ private TestSuiteInfo info;
+
+ public POJOTestSuiteDriver(Class testClass)
+ {
+ handler = new TestHandlerSupport(testClass);
+ info = new POJOTestSuiteInfo(handler);
+ }
+
+ public TestInfo getInfo()
+ {
+ return info;
+ }
+
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ if (command instanceof StartTestCommand)
+ {
+ StartTestCommand start = (StartTestCommand)command;
+
+ //
+ if (id.getLength() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String name = id.getName(0);
+
+ //
+ Object pojo;
+ try
+ {
+ pojo = handler.newTestCase(name);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+
+ //
+ Map<String,String> parametrization = start.getParametrization();
+
+ //
+ try
+ {
+ handler.testCaseParametrize(pojo, parametrization);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+
+ //
+ try
+ {
+ handler.testCaseCreate(pojo);
+
+ //
+ handler.testCaseInvoke(pojo);
+ }
+ catch (Exception e)
+ {
+ return createResponse(e);
+ }
+ finally
+ {
+ handler.testCaseDestroy(pojo);
+ }
+
+ //
+ return new EndTestResponse();
+ }
+ else
+ {
+ throw new IllegalArgumentException(); // convert to response style
+ }
+ }
+
+ private DriverResponse createResponse(Throwable t)
+ {
+ if (t instanceof TestCaseLifeCycleException)
+ {
+ if (t.getCause() != null)
+ {
+ t = t.getCause();
+ }
+ }
+
+ //
+ if (t instanceof AssertionError)
+ {
+ return new FailureResponse(Failure.createAssertionFailure((AssertionError)t));
+ }
+ else
+ {
+ return new FailureResponse(Failure.createErrorFailure(t));
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/unit/pojo/POJOTestSuiteInfo.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.unit.pojo;
+
+import org.jboss.unit.api.pojo.TestHandler;
+import org.jboss.unit.api.pojo.TestCaseDescriptor;
+import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.TestId;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOTestSuiteInfo extends POJOTestInfo implements TestSuiteInfo
+{
+
+ /** . */
+ private TestHandler handler;
+
+ /** . */
+ private Map<String,POJOTestCaseInfo> testCases;
+
+ public POJOTestSuiteInfo(TestHandler handler)
+ {
+ super(handler.getParameters());
+
+ //
+ HashMap<String, POJOTestCaseInfo> testCases = new HashMap<String, POJOTestCaseInfo>();
+ for (TestCaseDescriptor testCaseDescriptor : handler.getTestCases().values())
+ {
+ POJOTestCaseInfo testCase = new POJOTestCaseInfo(testCaseDescriptor);
+ testCases.put(testCase.getName(), testCase);
+ }
+
+ //
+ this.handler = handler;
+ this.testCases = testCases;
+ }
+
+ public String getName()
+ {
+ return handler.getName();
+ }
+
+ public String getDescription()
+ {
+ return handler.getDescription();
+ }
+
+ public TestInfo getTest(String name)
+ {
+ return testCases.get(name);
+ }
+
+ public Set<String> getNames()
+ {
+ return testCases.keySet();
+ }
+
+ public TestInfo findTest(TestId id)
+ {
+ switch(id.getLength())
+ {
+ case 0:
+ return this;
+ case 1:
+ return getTest(id.getName(0));
+ default:
+ return null;
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionTools
+{
+
+ public static <U> Set<U> set()
+ {
+ return new HashSet<U>();
+ }
+
+ /**
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public static <U> Set<U> set(U... us) throws IllegalArgumentException
+ {
+ return collection(new HashSet<U>(), us);
+ }
+
+ /**
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public static <U> Set<U> set(Iterable<U> us) throws IllegalArgumentException
+ {
+ return collection(new HashSet<U>(), us);
+ }
+
+ public static <U> List<U> list()
+ {
+ return new ArrayList<U>();
+ }
+
+ /**
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public static <U> List<U> list(U... us) throws IllegalArgumentException
+ {
+ return collection(new ArrayList<U>(), us);
+ }
+
+ /**
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public static <U> List<U> list(Iterable<U> us) throws IllegalArgumentException
+ {
+ return collection(new ArrayList<U>(), us);
+ }
+
+ private static <U,T extends Collection<U>> T collection(T collection, U... us)
+ {
+ if (us == null)
+ {
+ throw new IllegalArgumentException("No null array accepted");
+ }
+ for (U u : us)
+ {
+ collection.add(u);
+ }
+ return collection;
+ }
+
+ private static <U,T extends Collection<U>> T collection(T collection, Iterable<U> us)
+ {
+ if (us == null)
+ {
+ throw new IllegalArgumentException("No null array accepted");
+ }
+ for (U u : us)
+ {
+ collection.add(u);
+ }
+ return collection;
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/util/XMLTools.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/util/XMLTools.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/util/XMLTools.java 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.util;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class XMLTools
+{
+
+ public static Collection<Element> children(Element element, String... names)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (names == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ NodeList childNodes = element.getChildNodes();
+
+ //
+ Collection<Element> childElements = new ArrayList<Element>(childNodes.getLength());
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node childNode = childNodes.item(i);
+ if (childNode.getNodeType() == Node.ELEMENT_NODE)
+ {
+ String childName = childNode.getNodeName();
+ if (names.length == 0)
+ {
+ childElements.add((Element)childNode);
+ }
+ else
+ {
+ for (String name : names)
+ {
+ if (childName.equals(name))
+ {
+ childElements.add((Element)childNode);
+ }
+ }
+ }
+ }
+ }
+
+ //
+ return childElements;
+ }
+
+ public static Element child(Element element, String name)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ NodeList childNodes = element.getChildNodes();
+
+ //
+ Element childElement = null;
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node childNode = childNodes.item(i);
+ if (childNode.getNodeType() == Node.ELEMENT_NODE && name.equals(childNode.getNodeName()))
+ {
+ if (childElement != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ childElement = (Element)childNode;
+ }
+ }
+ }
+
+ //
+ return childElement;
+ }
+
+ public static String text(Element element)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ NodeList childNodes = element.getChildNodes();
+
+ //
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node childNode = childNodes.item(i);
+ switch (childNode.getNodeType())
+ {
+ case Node.TEXT_NODE:
+ Text text = (Text)childNode;
+ tmp.append(text.getData());
+ break;
+ case Node.ELEMENT_NODE:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ //
+ return tmp.toString();
+ }
+}
Added: modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit.dtd
===================================================================
--- modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit.dtd (rev 0)
+++ modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit.dtd 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+
+A jboss-element is a top container element.
+
+-->
+<!ELEMENT jboss-unit (pojo|suite)*>
+
+<!--
+
+A suite elements define a test suite and contain nested suites.
+
+-->
+<!ELEMENT suite (pojo)*>
+
+<!--
+
+The pojo element defines a test suite for plain old java objects. It contains a global parameter set,
+a set of test definitions and a set of tests to execute.
+
+-->
+<!ELEMENT pojo (parameter|test-def|test)*>
+
+<!--
+
+Defines a pojo test with a mandatory id attribute. The id attribute is used by test elements which can refer to it.
+
+-->
+<!ELEMENT test-def (class)>
+<!ATTLIST test-def id CDATA #REQUIRED>
+
+<!--
+
+Defines a tested class. A tested class can contain any number of case. If the class element contains no case then
+all test cases returned by the class meta data will be executed. The name attribute is the full qualified name of the class.
+
+-->
+<!ELEMENT class (case)*>
+<!ATTLIST class name CDATA #REQUIRED>
+
+<!--
+
+A case element specifies a particular test case on a test class. The name attribute in the name of the test case.
+
+-->
+<!ELEMENT case (#PCDATA)>
+<!ATTLIST case name CDATA #REQUIRED>
+
+<!--
+
+A test element specifies a test to execute. It either can contain an anonymous nested class element or it can refer
+to an existing test definition. The nested parameters are used to parameterize the test configuration, they override
+any existing parameter defined at the pojo level.
+
+-->
+<!ELEMENT test ((class,parameter*)|(parameter*,class,parameter*)|(parameter*,class)|parameter*)>
+<!ATTLIST test refid CDATA #IMPLIED>
+
+<!--
+
+A parameter element.
+
+-->
+<!ELEMENT parameter (value|null)*>
+<!ATTLIST parameter
+ name CDATA #REQUIRED
+ value CDATA #IMPLIED>
+
+<!ELEMENT null (#PCDATA)>
+<!ELEMENT value (#PCDATA)>
+
+
Added: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml (rev 0)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-unit PUBLIC
+ "-//JBoss Portal//JBoss Unit 1.0//EN"
+ "http://www.jboss.org/portal/dtd/jboss-unit.dtd">
+<jboss-unit>
+ <pojo>
+ <test-def id="blahblah">
+ <class name="org.jboss.test.unit.blah.TestedClass1"/>
+ </test-def>
+ <test-def id="bluh">
+ <class name="org.jboss.test.unit.blah.TestedClass1">
+ <case name="testFoo"/>
+ </class>
+ </test-def>
+ <test-def id="blih">
+ <class name="org.jboss.test.unit.blah.TestedClass2"/>
+ </test-def>
+ <test refid="blahblah">
+ </test>
+ <test refid="XYZ">
+ </test>
+ <test refid="bluh">
+ </test>
+ <test>
+ <class name="blah"/>
+ </test>
+ <test refid="blih">
+ <parameter name="foo">
+ <value>foo</value>
+ <value>fii</value>
+ </parameter>
+ </test>
+ </pojo>
+</jboss-unit>
Added: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml (rev 0)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml 2007-09-30 22:38:06 UTC (rev 8500)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-unit PUBLIC
+ "-//JBoss Portal//JBoss Unit 1.0//EN"
+ "http://www.jboss.org/portal/dtd/jboss-unit.dtd">
+<jboss-unit>
+ <pojo>
+
+ <parameter name="red" value="blue"/>
+
+ <test-def id="MyTest">
+ <class name="org.foo.bar.MyTest"/>
+ <!--
+ <parameters>
+ </parameters>
+ -->
+ </test-def>
+ <test-def id="MyTest2">
+ <class name="org.foo.bar.MyTest2">
+ <case name="foo"/>
+ <case name="bar"/>
+ </class>
+ </test-def>
+
+ <test refid="MyTest">
+ <parameter name="blah" value="bluh"/>
+ <parameter name="foo">
+ <value>bar1</value>
+ <null/>
+ </parameter>
+ </test>
+
+ <test>
+ <class name="org.foo.bar.OtherTest"/>
+ <parameter name="foo" value="bar"/>
+ </test>
+
+ <!--
+ <test>
+ <class name="">
+ <case name="abc"/>
+ </class>
+ <parameters>
+ <parameter name="blah" value="bluh"/>
+ <parameter name="foo">
+ <value>bar1</value>
+ <null/>
+ </parameter>
+ </parameters>
+ </test>
+ -->
+
+ </pojo>
+</jboss-unit>
16 years, 6 months
JBoss Portal SVN: r8499 - branches/JBoss_Portal_Branch_2_6/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-09-28 09:08:27 -0400 (Fri, 28 Sep 2007)
New Revision: 8499
Modified:
branches/JBoss_Portal_Branch_2_6/build/build.xml
Log:
Adding javadoc configuration for modules
Modified: branches/JBoss_Portal_Branch_2_6/build/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build.xml 2007-09-27 21:23:58 UTC (rev 8498)
+++ branches/JBoss_Portal_Branch_2_6/build/build.xml 2007-09-28 13:08:27 UTC (rev 8499)
@@ -337,6 +337,13 @@
<javadoc destdir="javadoc">
<classpath>
<fileset dir="../thirdparty" includes="**/*.jar"/>
+ <fileset dir="../../common/thirdparty" includes="**/*.jar"/>
+ <fileset dir="../../common/tools/lib" includes="**/*.jar"/>
+ <fileset dir="../../identity/thirdparty" includes="**/*.jar"/>
+ <fileset dir="../../portlet/thirdparty" includes="**/*.jar"/>
+ <fileset dir="../../test/thirdparty" includes="**/*.jar"/>
+ <fileset dir="../../test/test" includes="**/*.jar"/>
+ <fileset dir="../../web/thirdparty" includes="**/*.jar"/>
</classpath>
<packageset dir="../server/src/main">
<exclude name="org/jboss/portal/test/**"/>
@@ -356,6 +363,9 @@
<packageset dir="../format/src/main">
<exclude name="org/jboss/portal/test/**"/>
</packageset>
+ <packageset dir="../format/output/gen/classes">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
<packageset dir="../theme/src/main">
<exclude name="org/jboss/portal/test/**"/>
</packageset>
@@ -401,9 +411,61 @@
<packageset dir="../core-search/src/main">
<exclude name="org/jboss/portal/test/**"/>
</packageset>
+
+ <!-- Common module -->
+ <packageset dir="../../common/common/src/main/java">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../common/mc/src/main/java">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../common/portal/src/main/java">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+
+ <!-- Identity module -->
+ <packageset dir="../../identity/identity/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../identity/sso/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+
+ <!-- Portlet module -->
+ <packageset dir="../../portlet/bridge/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../portlet/federation/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../portlet/jsr168api/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../portlet/management/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../portlet/portlet/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+ <packageset dir="../../portlet/test/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+
+ <!-- Test module -->
+ <packageset dir="../../test/test/src/main">
+ <exclude name="org/jboss/test/**"/>
+ </packageset>
+
+ <!-- Web module -->
+ <packageset dir="../../web/web/src/main">
+ <exclude name="org/jboss/portal/test/**"/>
+ </packageset>
+
+ <link href="/tmp/2.6.2/portlet/build/javadoc" packagelistLoc="/tmp/2.6.2/portlet/build/javadoc"/>
</javadoc>
</target>
+
<!-- create the thirdparty folder from items in the repository -->
<!-- then generate a new libraries.ent file and include it in -->
<!-- the build -->
16 years, 6 months
JBoss Portal SVN: r8498 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-27 17:23:58 -0400 (Thu, 27 Sep 2007)
New Revision: 8498
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
- JBPORTAL-1725: set failed status to false if WSDL was properly set.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 21:23:21 UTC (rev 8497)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 21:23:58 UTC (rev 8498)
@@ -133,7 +133,6 @@
{
if (isMandatoryInterface)
{
- failed = true;
throw new IllegalStateException("Mandatory interface URLs were not properly initialized: no proper service URL for "
+ serviceClass.getName());
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 21:23:21 UTC (rev 8497)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 21:23:58 UTC (rev 8498)
@@ -84,6 +84,7 @@
{
initServices();
available = true;
+ failed = false;
}
catch (MalformedURLException e)
{
16 years, 6 months
JBoss Portal SVN: r8497 - tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-09-27 17:23:21 -0400 (Thu, 27 Sep 2007)
New Revision: 8497
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
- JBPORTAL-1725: set failed status to false if WSDL was properly set.
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 21:20:38 UTC (rev 8496)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 21:23:21 UTC (rev 8497)
@@ -133,7 +133,6 @@
{
if (isMandatoryInterface)
{
- failed = true;
throw new IllegalStateException("Mandatory interface URLs were not properly initialized: no proper service URL for "
+ serviceClass.getName());
}
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 21:20:38 UTC (rev 8496)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 21:23:21 UTC (rev 8497)
@@ -84,6 +84,7 @@
{
initServices();
available = true;
+ failed = false;
}
catch (MalformedURLException e)
{
16 years, 6 months
JBoss Portal SVN: r8496 - trunk/wsrp/src/main/org/jboss/portal/wsrp/services.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-27 17:20:38 -0400 (Thu, 27 Sep 2007)
New Revision: 8496
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
- JBPORTAL-1725: set failed status to false if WSDL was properly set.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 10:18:29 UTC (rev 8495)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/PerEndpointSOAPInvokerServiceFactory.java 2007-09-27 21:20:38 UTC (rev 8496)
@@ -133,7 +133,6 @@
{
if (isMandatoryInterface)
{
- failed = true;
throw new IllegalStateException("Mandatory interface URLs were not properly initialized: no proper service URL for "
+ serviceClass.getName());
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 10:18:29 UTC (rev 8495)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-09-27 21:20:38 UTC (rev 8496)
@@ -84,6 +84,7 @@
{
initServices();
available = true;
+ failed = false;
}
catch (MalformedURLException e)
{
16 years, 6 months
JBoss Portal SVN: r8495 - tags/JBoss_Portal_2_6_2/core.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-09-27 06:18:29 -0400 (Thu, 27 Sep 2007)
New Revision: 8495
Modified:
tags/JBoss_Portal_2_6_2/core/build.xml
Log:
- missing jar with SSO integration stuff
Modified: tags/JBoss_Portal_2_6_2/core/build.xml
===================================================================
--- tags/JBoss_Portal_2_6_2/core/build.xml 2007-09-27 09:39:34 UTC (rev 8494)
+++ tags/JBoss_Portal_2_6_2/core/build.xml 2007-09-27 10:18:29 UTC (rev 8495)
@@ -326,6 +326,7 @@
<include name="portal-portlet-bridge-lib.jar"/>
</fileset>
<fileset dir="${jboss.portal/modules/identity.root}/lib" includes="portal-identity-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/identity.root}/lib" includes="portal-identity-sso-lib.jar"/>
<fileset dir="${jboss.portal-server.root}/lib" includes="portal-server-lib.jar"/>
<fileset dir="${jboss.portal-portlet-server.root}/lib" includes="portal-portlet-server-lib.jar"/>
<fileset dir="${jboss.portal-jems.root}/lib" includes="portal-jems-lib.jar"/>
16 years, 6 months
JBoss Portal SVN: r8494 - branches/JBoss_Portal_Branch_2_6/core.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-09-27 05:39:34 -0400 (Thu, 27 Sep 2007)
New Revision: 8494
Modified:
branches/JBoss_Portal_Branch_2_6/core/build.xml
Log:
missing jar with SSO integration stuff
Modified: branches/JBoss_Portal_Branch_2_6/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-09-27 06:50:50 UTC (rev 8493)
+++ branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-09-27 09:39:34 UTC (rev 8494)
@@ -326,6 +326,7 @@
<include name="portal-portlet-bridge-lib.jar"/>
</fileset>
<fileset dir="${jboss.portal/modules/identity.root}/lib" includes="portal-identity-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/identity.root}/lib" includes="portal-identity-sso-lib.jar"/>
<fileset dir="${jboss.portal-server.root}/lib" includes="portal-server-lib.jar"/>
<fileset dir="${jboss.portal-portlet-server.root}/lib" includes="portal-portlet-server-lib.jar"/>
<fileset dir="${jboss.portal-jems.root}/lib" includes="portal-jems-lib.jar"/>
16 years, 6 months
JBoss Portal SVN: r8493 - tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-09-27 02:50:50 -0400 (Thu, 27 Sep 2007)
New Revision: 8493
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-1722: Surrounded access to portlet invoker by calls to RegistrationLocal.setRegistration(registration) and finally { RegistrationLocal.setRegistration(null); }
to make sure that the proper registration is seen.
- Improved service description logic. Should now be possible to write code to filter service description based on registration data.
- Renamed methods more appropriately.
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -154,7 +154,7 @@
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(initCookie, "InitCookie");
- producer.checkRegistration(initCookie.getRegistrationContext());
+ producer.getRegistrationOrFailIfInvalid(initCookie.getRegistrationContext());
// Force HTTP session creation... this is required for BEA Weblogic version < 9.2.
// See http://jira.jboss.com/jira/browse/JBPORTAL-1220
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.state.DestroyCloneFailure;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -56,6 +58,7 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
@@ -97,7 +100,7 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, GET_PORTLET_DESCRIPTION);
- producer.checkRegistration(getPortletDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletDescription.getRegistrationContext());
PortletContext portletContext = getPortletDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_DESCRIPTION);
@@ -105,7 +108,9 @@
UserContext userContext = getPortletDescription.getUserContext();
checkUserAuthorization(userContext);
- return WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales()));
+ // RegistrationLocal.setRegistration is called further down the invocation in ServiceDescriptionHandler.getPortletDescription
+ PortletDescription description = producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales(), registration);
+ return WSRPTypeFactory.createPortletDescriptionResponse(description);
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
@@ -117,13 +122,13 @@
PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
- producer.checkRegistration(getPortletPropertyDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
UserContext userContext = getPortletPropertyDescription.getUserContext();
checkUserAuthorization(userContext);
String[] desiredLocales = getPortletPropertyDescription.getDesiredLocales();
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PreferencesInfo prefsInfo = info.getPreferences();
@@ -162,7 +167,7 @@
PortletContext portletContext = clonePortlet.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", "ClonePortlet");
- producer.checkRegistration(clonePortlet.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(clonePortlet.getRegistrationContext());
UserContext userContext = clonePortlet.getUserContext();
checkUserAuthorization(userContext);
@@ -170,6 +175,7 @@
org.jboss.portal.portlet.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext response = producer.getInvoker().createClone(portalPC);
return WSRPUtils.convertToWSRPPortletContext(response);
}
@@ -188,6 +194,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault,
@@ -198,7 +208,7 @@
String[] handles = destroyPortlets.getPortletHandles();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(handles, "portlet handles to be destroyed", "DestroyPortlets");
- producer.checkRegistration(destroyPortlets.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(destroyPortlets.getRegistrationContext());
List portletContexts = new ArrayList(handles.length);
for (int i = 0; i < handles.length; i++)
@@ -208,6 +218,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
List failuresList = producer.getInvoker().destroyClones(portletContexts);
int failuresNumber = failuresList.size();
DestroyFailed[] destroyFailed;
@@ -233,6 +244,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to destroy clones", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault,
@@ -247,7 +262,7 @@
PropertyList propertyList = setPortletProperties.getPropertyList();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(propertyList, "PropertyList", "SetPortletProperties");
- producer.checkRegistration(setPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(setPortletProperties.getRegistrationContext());
checkUserAuthorization(setPortletProperties.getUserContext());
@@ -293,6 +308,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext resultContext =
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
(PropertyChange[])changes.toArray(new PropertyChange[0]));
@@ -313,6 +329,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to set properties for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
return portletContext;
@@ -327,7 +347,7 @@
PortletContext portletContext = getPortletProperties.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTIES);
- producer.checkRegistration(getPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletProperties.getRegistrationContext());
UserContext userContext = getPortletProperties.getUserContext();
checkUserAuthorization(userContext);
@@ -340,6 +360,7 @@
PropertyMap properties;
org.jboss.portal.portlet.PortletContext jbpContext = WSRPUtils.convertToPortalPortletContext(portletContext);
+ RegistrationLocal.setRegistration(registration);
if (keys != null)
{
properties = producer.getInvoker().getProperties(jbpContext, keys);
@@ -350,7 +371,7 @@
}
//todo: we need to check that the user can actually modify the properties
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PropertyList result = WSRPTypeFactory.createPropertyList();
@@ -386,6 +407,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve properties for portlet '" + portletContext + "'", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
private void checkUserAuthorization(UserContext userContext)
@@ -427,18 +452,23 @@
return keys;
}
- private Portlet getPortletFrom(PortletContext portletContext) throws InvalidHandleFault
+ private Portlet getPortletFrom(PortletContext portletContext, Registration registration) throws InvalidHandleFault
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = producer.getInvoker().getPortlet(WSRPUtils.convertToPortalPortletContext(portletContext));
+ return portlet;
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve portlet '" + portletContext.getPortletHandle() + "'", e);
}
- return portlet;
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
}
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -29,7 +29,6 @@
import org.jboss.portal.registration.NoSuchRegistrationException;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
-import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationStatus;
import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -138,9 +137,6 @@
capabilities.setSupportedUserProfileData(getListFromArray(customUserProfileData, false));
capabilities.setSupportedUserScopes(getListFromArray(consumerUserScopes, false));
capabilities.setSupportsGetMethod(isMethodGetSupported);
-
- // update RegistrationLocal for downstream use of Registration data
- RegistrationLocal.setRegistration(registration);
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
@@ -159,7 +155,6 @@
try
{
producer.getRegistrationManager().removeRegistration(registrationHandle);
- RegistrationLocal.setRegistration(null);
}
catch (NoSuchRegistrationException e)
{
@@ -221,45 +216,71 @@
return null;
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ /**
+ * @param reg
+ * @param throwExceptionIfExistsAndInvalid
+ *
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration reg, boolean throwExceptionIfExistsAndInvalid)
{
+ if (reg == null)
+ {
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("Registration is required yet no RegistrationContext was provided: registration invalid!");
+ return false;
+ }
+
+ log.debug("Registration not required, no registration: registration valid!");
+ return true;
+ }
+ else
+ {
+ boolean result = RegistrationStatus.VALID.equals(reg.getStatus());
+ log.debug("Registration required: registration is " + (result ? "valid!" : "invalid!"));
+
+ if (throwExceptionIfExistsAndInvalid && !result)
+ {
+ throwInvalidRegistrationFault("registration with handle '" + reg.getRegistrationHandle() + "' is not valid!");
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
- log.debug("registration required: checking registration");
if (registrationContext == null)
{
- log.debug("registration is required yet no RegistrationContext was provided!");
- return false;
+ return null;
}
String regHandle = registrationContext.getRegistrationHandle();
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(regHandle, "registration handle");
- Registration reg;
try
{
- reg = producer.getRegistrationManager().getRegistration(regHandle);
+ Registration registration = producer.getRegistrationManager().getRegistration(regHandle);
+ if (registration == null)
+ {
+ throwInvalidRegistrationFault("provided registration handle '" + regHandle + "' is not registered with this producer");
+ }
+ return registration;
}
catch (RegistrationException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to retrieve registration information associated with handle " + regHandle, e);
}
-
- if (reg == null)
- {
- throwInvalidRegistrationFault("provided registration handle '" + regHandle +
- "' is not registered with this producer");
- }
-
- if (!RegistrationStatus.VALID.equals(reg.getStatus()))
- {
- throwInvalidRegistrationFault("provided registration is no longer valid");
- }
-
- log.debug("registration is valid!");
- RegistrationLocal.setRegistration(reg); // set the current registration for downstream use
- return true;
}
else
{
@@ -267,12 +288,11 @@
{
throwInvalidRegistrationFault("no registration necessary yet one was provided!");
}
- RegistrationLocal.setRegistration(null);
- return true;
+ return null;
}
}
- private boolean throwInvalidRegistrationFault(String message) throws InvalidRegistrationFault
+ boolean throwInvalidRegistrationFault(String message)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
"Invalid registration: " + message, null);
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.wsrp.UserContextConverter;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -90,7 +91,7 @@
void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault, InvalidHandleFault,
UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
- producer.checkRegistration(getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getRegistrationContext());
// get session information and deal with it
final RuntimeContext runtimeContext = getRuntimeContext();
@@ -110,7 +111,8 @@
// retrieve the portlet
try
{
- portlet = producer.getPortletWith(portletContext);
+ // calls RegistrationLocal.setRegistration so no need to here
+ portlet = producer.getPortletWith(portletContext, registration);
}
catch (PortletInvokerException e)
{
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -76,12 +77,52 @@
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- if (!producer.isRegistrationValid(gs.getRegistrationContext()))
+ Registration registration = producer.getRegistrationFrom(gs.getRegistrationContext());
+ boolean registrationValid = producer.isRegistrationValid(registration);
+
+ ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
+
+ PortletDescription[] offeredPortlets = null;
+ ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
+ serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
+ serviceDescription.setLocales(producer.getSupportedLocales());
+
+ if (!requirements.requiresRegistration())
{
- return getRegistrationNotProvidedServiceDescription(gs.getDesiredLocales());
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
}
- log.debug("Returning complete service description");
- return refreshServiceDescription(gs.getDesiredLocales());
+ else
+ {
+ if (!registrationValid)
+ {
+ log.debug("Unregistered consumer while registration is required. Sending registration information.");
+
+ if (requirements.fullServiceDescriptionRequiresRegistration())
+ {
+ log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
+ }
+
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
+ {
+ description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
+ }
+
+ serviceDescription.setRegistrationPropertyDescription(description);
+ }
+ else
+ {
+ log.debug("Sending registered service description.");
+ // should we be sending the registration properties description as well?
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), registration);
+ }
+ }
+
+ serviceDescription.setOfferedPortlets(offeredPortlets);
+ return serviceDescription;
}
@@ -110,78 +151,34 @@
return offeredPortletDescriptions;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
Portlet portlet;
try
{
- portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext));
+ portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext), registration);
+ return getPortletDescription(portlet, desiredLocales);
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Could not retrieve portlet '" + portletContext + "'", e);
}
- return getPortletDescription(portlet, desiredLocales);
}
/**
- * Refreshes the service description by asking the portal container about contained portlets.
- *
- * @param desiredLocales the desired locales for the service description
- * @return the updated service description
+ * @param desiredLocales
+ * @param registration here so that we can do filtering of portlets based on registration data.
+ * @return
*/
- private ServiceDescription refreshServiceDescription(String[] desiredLocales)
+ private PortletDescription[] getPortletDescriptions(String[] desiredLocales, Registration registration)
{
- // todo: find out how to cache this
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
- // should we be sending the registration properties description as well?
- ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
- serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
- PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
- serviceDescription.setOfferedPortlets(descriptions);
- return serviceDescription;
- }
-
- private PortletDescription[] getPortletDescriptions(String[] desiredLocales)
- {
return (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
.toArray(new PortletDescription[]{});
}
/**
- * Retrieves the service description offered to unregistered consumers when registration is required.
- *
- * @param desiredLocales
- * @return the service description offered to unregistered consumers when registration is required
- */
- protected ServiceDescription getRegistrationNotProvidedServiceDescription(String[] desiredLocales)
- {
- log.debug("Unregistered consumer while registration is required. Sending registration information.");
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
-
-
- PortletDescription[] offeredPortlets = null;
- if (requirements.fullServiceDescriptionRequiresRegistration())
- {
- log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
- offeredPortlets = getPortletDescriptions(desiredLocales);
- }
-
- // do not create a ModelDescription if there is no registration properties
- Map info = requirements.getRegistrationProperties();
- ModelDescription description = null;
- if (info != null && !info.isEmpty())
- {
- description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
- }
-
- return new ServiceDescription(true, offeredPortlets, null, null, null, null, BEA_8_CONSUMER_FIX,
- description, producer.getSupportedLocales(), null, null);
- }
-
- /**
* Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
* specified component.
*
Modified: tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27 01:53:46 UTC (rev 8492)
+++ tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27 06:50:50 UTC (rev 8493)
@@ -30,6 +30,8 @@
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -382,11 +384,12 @@
this.invoker = invoker;
}
- Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext) throws InvalidHandleFault, PortletInvokerException
+ Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext, Registration registration) throws InvalidHandleFault, PortletInvokerException
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = invoker.getPortlet(portletContext);
}
catch (NoSuchPortletException e)
@@ -394,6 +397,11 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Couldn't find portlet with handle '" + portletContext.getId() + "'", null);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
+
if (!isRemotable(portlet))
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
@@ -421,9 +429,9 @@
return remotablePortlets;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
- return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
+ return serviceDescriptionHandler.getPortletDescription(portletContext, locales, registration);
}
public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
@@ -432,38 +440,43 @@
}
/**
- * Checks that the specified registration information is valid if this Producer requires registration.
- *
* @param registrationContext
- * @return <code>true</code> if the registration (when registration is required) information is valid or if no
- * registration is required, <code>false</code> otherwise (registration required, invalid information).
+ * @return
+ * @throws InvalidRegistrationFault
+ * @throws OperationFailedFault
+ * @since 2.6.2
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ Registration getRegistrationOrFailIfInvalid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
- return registrationHandler.isRegistrationValid(registrationContext);
+ Registration registration = getRegistrationFrom(registrationContext);
+ if (!isRegistrationValid(registration))
+ {
+ registrationHandler.throwInvalidRegistrationFault("Invalid registration");
+ }
+
+ return registration;
}
- protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ /**
+ * @param registration
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration registration)
{
- if (!isRegistrationValid(registrationContext))
- {
- String message;
- if (registrationContext != null)
- {
- message = "Registration associated with registration handle '" + registrationContext.getRegistrationHandle()
- + "' is not a valid registration";
- }
- else
- {
- message = "The given registration context was null";
- }
+ return registrationHandler.isRegistrationValid(registration, true);
+ }
- log.debug(message);
- throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION, message, null);
- }
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
+ return registrationHandler.getRegistrationFrom(registrationContext);
}
-
private Boolean remotableByDefault;
public Boolean isRemotableByDefault()
16 years, 6 months
JBoss Portal SVN: r8492 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-26 21:53:46 -0400 (Wed, 26 Sep 2007)
New Revision: 8492
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-1722: Surrounded access to portlet invoker by calls to RegistrationLocal.setRegistration(registration) and finally { RegistrationLocal.setRegistration(null); }
to make sure that the proper registration is seen.
- Improved service description logic. Should now be possible to write code to filter service description based on registration data.
- Renamed methods more appropriately.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -154,7 +154,7 @@
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(initCookie, "InitCookie");
- producer.checkRegistration(initCookie.getRegistrationContext());
+ producer.getRegistrationOrFailIfInvalid(initCookie.getRegistrationContext());
// Force HTTP session creation... this is required for BEA Weblogic version < 9.2.
// See http://jira.jboss.com/jira/browse/JBPORTAL-1220
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.state.DestroyCloneFailure;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -56,6 +58,7 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
@@ -97,7 +100,7 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, GET_PORTLET_DESCRIPTION);
- producer.checkRegistration(getPortletDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletDescription.getRegistrationContext());
PortletContext portletContext = getPortletDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_DESCRIPTION);
@@ -105,7 +108,9 @@
UserContext userContext = getPortletDescription.getUserContext();
checkUserAuthorization(userContext);
- return WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales()));
+ // RegistrationLocal.setRegistration is called further down the invocation in ServiceDescriptionHandler.getPortletDescription
+ PortletDescription description = producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales(), registration);
+ return WSRPTypeFactory.createPortletDescriptionResponse(description);
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
@@ -117,13 +122,13 @@
PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
- producer.checkRegistration(getPortletPropertyDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
UserContext userContext = getPortletPropertyDescription.getUserContext();
checkUserAuthorization(userContext);
String[] desiredLocales = getPortletPropertyDescription.getDesiredLocales();
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PreferencesInfo prefsInfo = info.getPreferences();
@@ -162,7 +167,7 @@
PortletContext portletContext = clonePortlet.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", "ClonePortlet");
- producer.checkRegistration(clonePortlet.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(clonePortlet.getRegistrationContext());
UserContext userContext = clonePortlet.getUserContext();
checkUserAuthorization(userContext);
@@ -170,6 +175,7 @@
org.jboss.portal.portlet.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext response = producer.getInvoker().createClone(portalPC);
return WSRPUtils.convertToWSRPPortletContext(response);
}
@@ -188,6 +194,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault,
@@ -198,7 +208,7 @@
String[] handles = destroyPortlets.getPortletHandles();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(handles, "portlet handles to be destroyed", "DestroyPortlets");
- producer.checkRegistration(destroyPortlets.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(destroyPortlets.getRegistrationContext());
List portletContexts = new ArrayList(handles.length);
for (int i = 0; i < handles.length; i++)
@@ -208,6 +218,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
List failuresList = producer.getInvoker().destroyClones(portletContexts);
int failuresNumber = failuresList.size();
DestroyFailed[] destroyFailed;
@@ -233,6 +244,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to destroy clones", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault,
@@ -247,7 +262,7 @@
PropertyList propertyList = setPortletProperties.getPropertyList();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(propertyList, "PropertyList", "SetPortletProperties");
- producer.checkRegistration(setPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(setPortletProperties.getRegistrationContext());
checkUserAuthorization(setPortletProperties.getUserContext());
@@ -293,6 +308,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext resultContext =
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
(PropertyChange[])changes.toArray(new PropertyChange[0]));
@@ -313,6 +329,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to set properties for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
return portletContext;
@@ -327,7 +347,7 @@
PortletContext portletContext = getPortletProperties.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTIES);
- producer.checkRegistration(getPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletProperties.getRegistrationContext());
UserContext userContext = getPortletProperties.getUserContext();
checkUserAuthorization(userContext);
@@ -340,6 +360,7 @@
PropertyMap properties;
org.jboss.portal.portlet.PortletContext jbpContext = WSRPUtils.convertToPortalPortletContext(portletContext);
+ RegistrationLocal.setRegistration(registration);
if (keys != null)
{
properties = producer.getInvoker().getProperties(jbpContext, keys);
@@ -350,7 +371,7 @@
}
//todo: we need to check that the user can actually modify the properties
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PropertyList result = WSRPTypeFactory.createPropertyList();
@@ -386,6 +407,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve properties for portlet '" + portletContext + "'", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
private void checkUserAuthorization(UserContext userContext)
@@ -427,18 +452,23 @@
return keys;
}
- private Portlet getPortletFrom(PortletContext portletContext) throws InvalidHandleFault
+ private Portlet getPortletFrom(PortletContext portletContext, Registration registration) throws InvalidHandleFault
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = producer.getInvoker().getPortlet(WSRPUtils.convertToPortalPortletContext(portletContext));
+ return portlet;
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve portlet '" + portletContext.getPortletHandle() + "'", e);
}
- return portlet;
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
}
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -29,7 +29,6 @@
import org.jboss.portal.registration.NoSuchRegistrationException;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
-import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationStatus;
import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -138,9 +137,6 @@
capabilities.setSupportedUserProfileData(getListFromArray(customUserProfileData, false));
capabilities.setSupportedUserScopes(getListFromArray(consumerUserScopes, false));
capabilities.setSupportsGetMethod(isMethodGetSupported);
-
- // update RegistrationLocal for downstream use of Registration data
- RegistrationLocal.setRegistration(registration);
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
@@ -159,7 +155,6 @@
try
{
producer.getRegistrationManager().removeRegistration(registrationHandle);
- RegistrationLocal.setRegistration(null);
}
catch (NoSuchRegistrationException e)
{
@@ -221,45 +216,71 @@
return null;
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ /**
+ * @param reg
+ * @param throwExceptionIfExistsAndInvalid
+ *
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration reg, boolean throwExceptionIfExistsAndInvalid)
{
+ if (reg == null)
+ {
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("Registration is required yet no RegistrationContext was provided: registration invalid!");
+ return false;
+ }
+
+ log.debug("Registration not required, no registration: registration valid!");
+ return true;
+ }
+ else
+ {
+ boolean result = RegistrationStatus.VALID.equals(reg.getStatus());
+ log.debug("Registration required: registration is " + (result ? "valid!" : "invalid!"));
+
+ if (throwExceptionIfExistsAndInvalid && !result)
+ {
+ throwInvalidRegistrationFault("registration with handle '" + reg.getRegistrationHandle() + "' is not valid!");
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
- log.debug("registration required: checking registration");
if (registrationContext == null)
{
- log.debug("registration is required yet no RegistrationContext was provided!");
- return false;
+ return null;
}
String regHandle = registrationContext.getRegistrationHandle();
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(regHandle, "registration handle");
- Registration reg;
try
{
- reg = producer.getRegistrationManager().getRegistration(regHandle);
+ Registration registration = producer.getRegistrationManager().getRegistration(regHandle);
+ if (registration == null)
+ {
+ throwInvalidRegistrationFault("provided registration handle '" + regHandle + "' is not registered with this producer");
+ }
+ return registration;
}
catch (RegistrationException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to retrieve registration information associated with handle " + regHandle, e);
}
-
- if (reg == null)
- {
- throwInvalidRegistrationFault("provided registration handle '" + regHandle +
- "' is not registered with this producer");
- }
-
- if (!RegistrationStatus.VALID.equals(reg.getStatus()))
- {
- throwInvalidRegistrationFault("provided registration is no longer valid");
- }
-
- log.debug("registration is valid!");
- RegistrationLocal.setRegistration(reg); // set the current registration for downstream use
- return true;
}
else
{
@@ -267,12 +288,11 @@
{
throwInvalidRegistrationFault("no registration necessary yet one was provided!");
}
- RegistrationLocal.setRegistration(null);
- return true;
+ return null;
}
}
- private boolean throwInvalidRegistrationFault(String message) throws InvalidRegistrationFault
+ boolean throwInvalidRegistrationFault(String message)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
"Invalid registration: " + message, null);
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.wsrp.UserContextConverter;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -90,7 +91,7 @@
void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault, InvalidHandleFault,
UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
- producer.checkRegistration(getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getRegistrationContext());
// get session information and deal with it
final RuntimeContext runtimeContext = getRuntimeContext();
@@ -110,7 +111,8 @@
// retrieve the portlet
try
{
- portlet = producer.getPortletWith(portletContext);
+ // calls RegistrationLocal.setRegistration so no need to here
+ portlet = producer.getPortletWith(portletContext, registration);
}
catch (PortletInvokerException e)
{
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -76,12 +77,52 @@
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- if (!producer.isRegistrationValid(gs.getRegistrationContext()))
+ Registration registration = producer.getRegistrationFrom(gs.getRegistrationContext());
+ boolean registrationValid = producer.isRegistrationValid(registration);
+
+ ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
+
+ PortletDescription[] offeredPortlets = null;
+ ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
+ serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
+ serviceDescription.setLocales(producer.getSupportedLocales());
+
+ if (!requirements.requiresRegistration())
{
- return getRegistrationNotProvidedServiceDescription(gs.getDesiredLocales());
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
}
- log.debug("Returning complete service description");
- return refreshServiceDescription(gs.getDesiredLocales());
+ else
+ {
+ if (!registrationValid)
+ {
+ log.debug("Unregistered consumer while registration is required. Sending registration information.");
+
+ if (requirements.fullServiceDescriptionRequiresRegistration())
+ {
+ log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
+ }
+
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
+ {
+ description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
+ }
+
+ serviceDescription.setRegistrationPropertyDescription(description);
+ }
+ else
+ {
+ log.debug("Sending registered service description.");
+ // should we be sending the registration properties description as well?
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), registration);
+ }
+ }
+
+ serviceDescription.setOfferedPortlets(offeredPortlets);
+ return serviceDescription;
}
@@ -110,78 +151,34 @@
return offeredPortletDescriptions;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
Portlet portlet;
try
{
- portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext));
+ portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext), registration);
+ return getPortletDescription(portlet, desiredLocales);
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Could not retrieve portlet '" + portletContext + "'", e);
}
- return getPortletDescription(portlet, desiredLocales);
}
/**
- * Refreshes the service description by asking the portal container about contained portlets.
- *
- * @param desiredLocales the desired locales for the service description
- * @return the updated service description
+ * @param desiredLocales
+ * @param registration here so that we can do filtering of portlets based on registration data.
+ * @return
*/
- private ServiceDescription refreshServiceDescription(String[] desiredLocales)
+ private PortletDescription[] getPortletDescriptions(String[] desiredLocales, Registration registration)
{
- // todo: find out how to cache this
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
- // should we be sending the registration properties description as well?
- ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
- serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
- PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
- serviceDescription.setOfferedPortlets(descriptions);
- return serviceDescription;
- }
-
- private PortletDescription[] getPortletDescriptions(String[] desiredLocales)
- {
return (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
.toArray(new PortletDescription[]{});
}
/**
- * Retrieves the service description offered to unregistered consumers when registration is required.
- *
- * @param desiredLocales
- * @return the service description offered to unregistered consumers when registration is required
- */
- protected ServiceDescription getRegistrationNotProvidedServiceDescription(String[] desiredLocales)
- {
- log.debug("Unregistered consumer while registration is required. Sending registration information.");
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
-
-
- PortletDescription[] offeredPortlets = null;
- if (requirements.fullServiceDescriptionRequiresRegistration())
- {
- log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
- offeredPortlets = getPortletDescriptions(desiredLocales);
- }
-
- // do not create a ModelDescription if there is no registration properties
- Map info = requirements.getRegistrationProperties();
- ModelDescription description = null;
- if (info != null && !info.isEmpty())
- {
- description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
- }
-
- return new ServiceDescription(true, offeredPortlets, null, null, null, null, BEA_8_CONSUMER_FIX,
- description, producer.getSupportedLocales(), null, null);
- }
-
- /**
* Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
* specified component.
*
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27 01:50:35 UTC (rev 8491)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27 01:53:46 UTC (rev 8492)
@@ -30,6 +30,8 @@
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -382,11 +384,12 @@
this.invoker = invoker;
}
- Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext) throws InvalidHandleFault, PortletInvokerException
+ Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext, Registration registration) throws InvalidHandleFault, PortletInvokerException
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = invoker.getPortlet(portletContext);
}
catch (NoSuchPortletException e)
@@ -394,6 +397,11 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Couldn't find portlet with handle '" + portletContext.getId() + "'", null);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
+
if (!isRemotable(portlet))
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
@@ -421,9 +429,9 @@
return remotablePortlets;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
- return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
+ return serviceDescriptionHandler.getPortletDescription(portletContext, locales, registration);
}
public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
@@ -432,38 +440,43 @@
}
/**
- * Checks that the specified registration information is valid if this Producer requires registration.
- *
* @param registrationContext
- * @return <code>true</code> if the registration (when registration is required) information is valid or if no
- * registration is required, <code>false</code> otherwise (registration required, invalid information).
+ * @return
+ * @throws InvalidRegistrationFault
+ * @throws OperationFailedFault
+ * @since 2.6.2
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ Registration getRegistrationOrFailIfInvalid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
- return registrationHandler.isRegistrationValid(registrationContext);
+ Registration registration = getRegistrationFrom(registrationContext);
+ if (!isRegistrationValid(registration))
+ {
+ registrationHandler.throwInvalidRegistrationFault("Invalid registration");
+ }
+
+ return registration;
}
- protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ /**
+ * @param registration
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration registration)
{
- if (!isRegistrationValid(registrationContext))
- {
- String message;
- if (registrationContext != null)
- {
- message = "Registration associated with registration handle '" + registrationContext.getRegistrationHandle()
- + "' is not a valid registration";
- }
- else
- {
- message = "The given registration context was null";
- }
+ return registrationHandler.isRegistrationValid(registration, true);
+ }
- log.debug(message);
- throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION, message, null);
- }
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
+ return registrationHandler.getRegistrationFrom(registrationContext);
}
-
private Boolean remotableByDefault;
public Boolean isRemotableByDefault()
16 years, 6 months
JBoss Portal SVN: r8491 - trunk/wsrp/src/main/org/jboss/portal/wsrp/producer.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-09-26 21:50:35 -0400 (Wed, 26 Sep 2007)
New Revision: 8491
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-1722: Surrounded access to portlet invoker by calls to RegistrationLocal.setRegistration(registration) and finally { RegistrationLocal.setRegistration(null); }
to make sure that the proper registration is seen.
- Improved service description logic. Should now be possible to write code to filter service description based on registration data.
- Renamed methods more appropriately.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -154,7 +154,7 @@
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(initCookie, "InitCookie");
- producer.checkRegistration(initCookie.getRegistrationContext());
+ producer.getRegistrationOrFailIfInvalid(initCookie.getRegistrationContext());
// Force HTTP session creation... this is required for BEA Weblogic version < 9.2.
// See http://jira.jboss.com/jira/browse/JBPORTAL-1220
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.state.DestroyCloneFailure;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -56,6 +58,7 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
@@ -97,7 +100,7 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, GET_PORTLET_DESCRIPTION);
- producer.checkRegistration(getPortletDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletDescription.getRegistrationContext());
PortletContext portletContext = getPortletDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_DESCRIPTION);
@@ -105,7 +108,9 @@
UserContext userContext = getPortletDescription.getUserContext();
checkUserAuthorization(userContext);
- return WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales()));
+ // RegistrationLocal.setRegistration is called further down the invocation in ServiceDescriptionHandler.getPortletDescription
+ PortletDescription description = producer.getPortletDescription(portletContext, getPortletDescription.getDesiredLocales(), registration);
+ return WSRPTypeFactory.createPortletDescriptionResponse(description);
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
@@ -117,13 +122,13 @@
PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
- producer.checkRegistration(getPortletPropertyDescription.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
UserContext userContext = getPortletPropertyDescription.getUserContext();
checkUserAuthorization(userContext);
String[] desiredLocales = getPortletPropertyDescription.getDesiredLocales();
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PreferencesInfo prefsInfo = info.getPreferences();
@@ -162,7 +167,7 @@
PortletContext portletContext = clonePortlet.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", "ClonePortlet");
- producer.checkRegistration(clonePortlet.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(clonePortlet.getRegistrationContext());
UserContext userContext = clonePortlet.getUserContext();
checkUserAuthorization(userContext);
@@ -170,6 +175,7 @@
org.jboss.portal.portlet.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext response = producer.getInvoker().createClone(portalPC);
return WSRPUtils.convertToWSRPPortletContext(response);
}
@@ -188,6 +194,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault,
@@ -198,7 +208,7 @@
String[] handles = destroyPortlets.getPortletHandles();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(handles, "portlet handles to be destroyed", "DestroyPortlets");
- producer.checkRegistration(destroyPortlets.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(destroyPortlets.getRegistrationContext());
List portletContexts = new ArrayList(handles.length);
for (int i = 0; i < handles.length; i++)
@@ -208,6 +218,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
List failuresList = producer.getInvoker().destroyClones(portletContexts);
int failuresNumber = failuresList.size();
DestroyFailed[] destroyFailed;
@@ -233,6 +244,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to destroy clones", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault,
@@ -247,7 +262,7 @@
PropertyList propertyList = setPortletProperties.getPropertyList();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(propertyList, "PropertyList", "SetPortletProperties");
- producer.checkRegistration(setPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(setPortletProperties.getRegistrationContext());
checkUserAuthorization(setPortletProperties.getUserContext());
@@ -293,6 +308,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext resultContext =
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
(PropertyChange[])changes.toArray(new PropertyChange[0]));
@@ -313,6 +329,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to set properties for portlet '" + portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
return portletContext;
@@ -327,7 +347,7 @@
PortletContext portletContext = getPortletProperties.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTIES);
- producer.checkRegistration(getPortletProperties.getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getPortletProperties.getRegistrationContext());
UserContext userContext = getPortletProperties.getUserContext();
checkUserAuthorization(userContext);
@@ -340,6 +360,7 @@
PropertyMap properties;
org.jboss.portal.portlet.PortletContext jbpContext = WSRPUtils.convertToPortalPortletContext(portletContext);
+ RegistrationLocal.setRegistration(registration);
if (keys != null)
{
properties = producer.getInvoker().getProperties(jbpContext, keys);
@@ -350,7 +371,7 @@
}
//todo: we need to check that the user can actually modify the properties
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PropertyList result = WSRPTypeFactory.createPropertyList();
@@ -386,6 +407,10 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve properties for portlet '" + portletContext + "'", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
private void checkUserAuthorization(UserContext userContext)
@@ -427,18 +452,23 @@
return keys;
}
- private Portlet getPortletFrom(PortletContext portletContext) throws InvalidHandleFault
+ private Portlet getPortletFrom(PortletContext portletContext, Registration registration) throws InvalidHandleFault
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = producer.getInvoker().getPortlet(WSRPUtils.convertToPortalPortletContext(portletContext));
+ return portlet;
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve portlet '" + portletContext.getPortletHandle() + "'", e);
}
- return portlet;
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -29,7 +29,6 @@
import org.jboss.portal.registration.NoSuchRegistrationException;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
-import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationStatus;
import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -138,9 +137,6 @@
capabilities.setSupportedUserProfileData(getListFromArray(customUserProfileData, false));
capabilities.setSupportedUserScopes(getListFromArray(consumerUserScopes, false));
capabilities.setSupportsGetMethod(isMethodGetSupported);
-
- // update RegistrationLocal for downstream use of Registration data
- RegistrationLocal.setRegistration(registration);
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
@@ -159,7 +155,6 @@
try
{
producer.getRegistrationManager().removeRegistration(registrationHandle);
- RegistrationLocal.setRegistration(null);
}
catch (NoSuchRegistrationException e)
{
@@ -221,45 +216,71 @@
return null;
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ /**
+ * @param reg
+ * @param throwExceptionIfExistsAndInvalid
+ *
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration reg, boolean throwExceptionIfExistsAndInvalid)
{
+ if (reg == null)
+ {
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("Registration is required yet no RegistrationContext was provided: registration invalid!");
+ return false;
+ }
+
+ log.debug("Registration not required, no registration: registration valid!");
+ return true;
+ }
+ else
+ {
+ boolean result = RegistrationStatus.VALID.equals(reg.getStatus());
+ log.debug("Registration required: registration is " + (result ? "valid!" : "invalid!"));
+
+ if (throwExceptionIfExistsAndInvalid && !result)
+ {
+ throwInvalidRegistrationFault("registration with handle '" + reg.getRegistrationHandle() + "' is not valid!");
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
- log.debug("registration required: checking registration");
if (registrationContext == null)
{
- log.debug("registration is required yet no RegistrationContext was provided!");
- return false;
+ return null;
}
String regHandle = registrationContext.getRegistrationHandle();
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(regHandle, "registration handle");
- Registration reg;
try
{
- reg = producer.getRegistrationManager().getRegistration(regHandle);
+ Registration registration = producer.getRegistrationManager().getRegistration(regHandle);
+ if (registration == null)
+ {
+ throwInvalidRegistrationFault("provided registration handle '" + regHandle + "' is not registered with this producer");
+ }
+ return registration;
}
catch (RegistrationException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to retrieve registration information associated with handle " + regHandle, e);
}
-
- if (reg == null)
- {
- throwInvalidRegistrationFault("provided registration handle '" + regHandle +
- "' is not registered with this producer");
- }
-
- if (!RegistrationStatus.VALID.equals(reg.getStatus()))
- {
- throwInvalidRegistrationFault("provided registration is no longer valid");
- }
-
- log.debug("registration is valid!");
- RegistrationLocal.setRegistration(reg); // set the current registration for downstream use
- return true;
}
else
{
@@ -267,12 +288,11 @@
{
throwInvalidRegistrationFault("no registration necessary yet one was provided!");
}
- RegistrationLocal.setRegistration(null);
- return true;
+ return null;
}
}
- private boolean throwInvalidRegistrationFault(String message) throws InvalidRegistrationFault
+ boolean throwInvalidRegistrationFault(String message)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
"Invalid registration: " + message, null);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.wsrp.UserContextConverter;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -90,7 +91,7 @@
void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault, InvalidHandleFault,
UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
- producer.checkRegistration(getRegistrationContext());
+ Registration registration = producer.getRegistrationOrFailIfInvalid(getRegistrationContext());
// get session information and deal with it
final RuntimeContext runtimeContext = getRuntimeContext();
@@ -110,7 +111,8 @@
// retrieve the portlet
try
{
- portlet = producer.getPortletWith(portletContext);
+ // calls RegistrationLocal.setRegistration so no need to here
+ portlet = producer.getPortletWith(portletContext, registration);
}
catch (PortletInvokerException e)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -76,12 +77,52 @@
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- if (!producer.isRegistrationValid(gs.getRegistrationContext()))
+ Registration registration = producer.getRegistrationFrom(gs.getRegistrationContext());
+ boolean registrationValid = producer.isRegistrationValid(registration);
+
+ ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
+
+ PortletDescription[] offeredPortlets = null;
+ ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
+ serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
+ serviceDescription.setLocales(producer.getSupportedLocales());
+
+ if (!requirements.requiresRegistration())
{
- return getRegistrationNotProvidedServiceDescription(gs.getDesiredLocales());
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
}
- log.debug("Returning complete service description");
- return refreshServiceDescription(gs.getDesiredLocales());
+ else
+ {
+ if (!registrationValid)
+ {
+ log.debug("Unregistered consumer while registration is required. Sending registration information.");
+
+ if (requirements.fullServiceDescriptionRequiresRegistration())
+ {
+ log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
+ }
+
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
+ {
+ description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
+ }
+
+ serviceDescription.setRegistrationPropertyDescription(description);
+ }
+ else
+ {
+ log.debug("Sending registered service description.");
+ // should we be sending the registration properties description as well?
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), registration);
+ }
+ }
+
+ serviceDescription.setOfferedPortlets(offeredPortlets);
+ return serviceDescription;
}
@@ -110,78 +151,34 @@
return offeredPortletDescriptions;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] desiredLocales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
Portlet portlet;
try
{
- portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext));
+ portlet = producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext), registration);
+ return getPortletDescription(portlet, desiredLocales);
}
catch (PortletInvokerException e)
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Could not retrieve portlet '" + portletContext + "'", e);
}
- return getPortletDescription(portlet, desiredLocales);
}
/**
- * Refreshes the service description by asking the portal container about contained portlets.
- *
- * @param desiredLocales the desired locales for the service description
- * @return the updated service description
+ * @param desiredLocales
+ * @param registration here so that we can do filtering of portlets based on registration data.
+ * @return
*/
- private ServiceDescription refreshServiceDescription(String[] desiredLocales)
+ private PortletDescription[] getPortletDescriptions(String[] desiredLocales, Registration registration)
{
- // todo: find out how to cache this
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
- // should we be sending the registration properties description as well?
- ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
- serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
- PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
- serviceDescription.setOfferedPortlets(descriptions);
- return serviceDescription;
- }
-
- private PortletDescription[] getPortletDescriptions(String[] desiredLocales)
- {
return (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
.toArray(new PortletDescription[]{});
}
/**
- * Retrieves the service description offered to unregistered consumers when registration is required.
- *
- * @param desiredLocales
- * @return the service description offered to unregistered consumers when registration is required
- */
- protected ServiceDescription getRegistrationNotProvidedServiceDescription(String[] desiredLocales)
- {
- log.debug("Unregistered consumer while registration is required. Sending registration information.");
- ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
-
-
- PortletDescription[] offeredPortlets = null;
- if (requirements.fullServiceDescriptionRequiresRegistration())
- {
- log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
- offeredPortlets = getPortletDescriptions(desiredLocales);
- }
-
- // do not create a ModelDescription if there is no registration properties
- Map info = requirements.getRegistrationProperties();
- ModelDescription description = null;
- if (info != null && !info.isEmpty())
- {
- description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
- }
-
- return new ServiceDescription(true, offeredPortlets, null, null, null, null, BEA_8_CONSUMER_FIX,
- description, producer.getSupportedLocales(), null, null);
- }
-
- /**
* Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
* specified component.
*
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-26 09:44:02 UTC (rev 8490)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27 01:50:35 UTC (rev 8491)
@@ -30,6 +30,8 @@
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -382,11 +384,12 @@
this.invoker = invoker;
}
- Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext) throws InvalidHandleFault, PortletInvokerException
+ Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext, Registration registration) throws InvalidHandleFault, PortletInvokerException
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = invoker.getPortlet(portletContext);
}
catch (NoSuchPortletException e)
@@ -394,6 +397,11 @@
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Couldn't find portlet with handle '" + portletContext.getId() + "'", null);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
+
if (!isRemotable(portlet))
{
throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
@@ -421,9 +429,9 @@
return remotablePortlets;
}
- public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext, String[] locales, Registration registration) throws InvalidHandleFault, OperationFailedFault
{
- return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
+ return serviceDescriptionHandler.getPortletDescription(portletContext, locales, registration);
}
public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
@@ -432,38 +440,43 @@
}
/**
- * Checks that the specified registration information is valid if this Producer requires registration.
- *
* @param registrationContext
- * @return <code>true</code> if the registration (when registration is required) information is valid or if no
- * registration is required, <code>false</code> otherwise (registration required, invalid information).
+ * @return
+ * @throws InvalidRegistrationFault
+ * @throws OperationFailedFault
+ * @since 2.6.2
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ Registration getRegistrationOrFailIfInvalid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
- return registrationHandler.isRegistrationValid(registrationContext);
+ Registration registration = getRegistrationFrom(registrationContext);
+ if (!isRegistrationValid(registration))
+ {
+ registrationHandler.throwInvalidRegistrationFault("Invalid registration");
+ }
+
+ return registration;
}
- protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
+ /**
+ * @param registration
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration registration)
{
- if (!isRegistrationValid(registrationContext))
- {
- String message;
- if (registrationContext != null)
- {
- message = "Registration associated with registration handle '" + registrationContext.getRegistrationHandle()
- + "' is not a valid registration";
- }
- else
- {
- message = "The given registration context was null";
- }
+ return registrationHandler.isRegistrationValid(registration, true);
+ }
- log.debug(message);
- throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION, message, null);
- }
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
+ return registrationHandler.getRegistrationFrom(registrationContext);
}
-
private Boolean remotableByDefault;
public Boolean isRemotableByDefault()
16 years, 6 months