From portal-commits at lists.jboss.org Fri Oct 19 08:28:58 2007 Content-Type: multipart/mixed; boundary="===============9102132251543558372==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r8715 - in modules/test/trunk: unit/src/main/org/jboss/unit/api/pojo/annotations and 1 other directories. Date: Fri, 19 Oct 2007 08:28:58 -0400 Message-ID: --===============9102132251543558372== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-10-19 08:28:58 -0400 (Fri, 19 Oct 2007) New Revision: 8715 Modified: modules/test/trunk/docs/user-guide/en/modules/pojotesting.xml modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/Des= cription.java modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestProviderSup= port.java Log: more documentation Modified: modules/test/trunk/docs/user-guide/en/modules/pojotesting.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/test/trunk/docs/user-guide/en/modules/pojotesting.xml 2007-10-1= 9 10:42:51 UTC (rev 8714) +++ modules/test/trunk/docs/user-guide/en/modules/pojotesting.xml 2007-10-1= 9 12:28:58 UTC (rev 8715) @@ -413,18 +413,237 @@ = <interfacename>@Description</interfacename> - + The @Description annotation = can be used to annotate a test class, a test + case of a test parameter and provide a description + + + + + A test described + + + = <interfacename>@Tag</interfacename> - + The @Tag annotation allow to= tag a tested item with keywords. The main usage + of keywords is at runtime in order to provide filtering of tests.= It is very useful whenever you just want + to execute a subset of the tests based on a set of keywords. + + + + + A test annotated with keywords + + + = = Integration with JBoss Microcontainer + + The JBoss Microcontainer provides a lighweight container for m= anaging POJOs, their deployment and + configuration. The integration within JBoss Unit provides a powerful= way to setup complex assembly of + POJOs that will be part of unit tests. + This section will provide the general syntax and an example of= usage, for further details concerning + JBoss Microcontainer you should look at its documentation. + + + Triggering a microcontainer boostrap with the <interfacena= me>@Bootstrap</interfacename> annotation + The main usage of JBoss Microcontainer is done through the = @Bootstrap annotation. + It has a resourceName parameter which indi= cates the resource name of the microcontainer + bootstrap file. + The current POJO being tested will be inserted in the micro= container kernel and it is possible to reference it + in the bootstrap file under the special TestCase name. It is possible to override the name + using the beanName parameter of the @Bootstrap annotation. There + are several ways to leverage this: + + Inject the test case in a bean + Inject a property of the test case in a bean such= as a parameter of the test case + Inject a bean in the test case POJO using JBoss M= icrocontainer annotations + + + + + + Example + In this example we will show how to create a parameterized = test case that bootstrap a bean using + the microcontainer. The boostrapped bean will be configured fr= om the test case parameters and then + will be injected in the test case. + + + + + The service + + + + + + + The test suite + + + + Our tested system is composed of a service and a test suite= . The service is configured from + a dataSourceName parameter that will be in= jected from the test suite dataSourceName + corresponding property. The test suite is parameterized with the = dataSourceName parameter that will + be set by JBoss Unit. The test suite interacts with the microcont= ainer thanks to the @Bootstrap + annotation configured to use the file available from the classpat= h under the name /jboss-beans.xml. The + @Inject annotation is a microconta= iner annotation that will trigger the injection + of the service in the test case. + + + + + + + + + + +]]> + + The jboss-beans.xml file + + + + The injection of the dataSourceName = property from the TestCase bean + requires to add the state attribute with t= he value Instantiated. Without + this we would have a a bidirectional dependency between the servi= ce and the test case and the kernel would not + be able to resolve it: the test case wants the injection of the s= ervice and the service wants the injection + of a portion of the test case state. Using the Instantia= ted state tells the kernel to use + the test case bean when it is instantiated and that allows the re= solution of all the dependencies. + + One of the benefit of using JBoss Microcontainer is that it= takes care of the overral orchestration of the whole setup + and resolve the dependencies and configuration issues. When JB= oss Unit executes the test case the following sequence happens: + + An instance of MyTest is c= reated by JBoss Unit + JBoss Unit configures the instance and set the dataSourceName property + JBoss Unit creates a new microcontainer kernel an= d registers the MyTest instance under the T= estCase name + JBoss Unit deploys the jboss-beans.xml<= /filename> file + JBoss MC creates an instance of the My= Service service and configures it with the test case dataSourceName + value + JBoss MC starts the service + JBoss MC inject the service in the test case + + + + Once the test is finished a shutdown of the kernel will be = done that will trigger the stopping and destruction of the + involved services. + + + = Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotati= ons/Description.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/De= scription.java 2007-10-19 10:42:51 UTC (rev 8714) +++ modules/test/trunk/unit/src/main/org/jboss/unit/api/pojo/annotations/De= scription.java 2007-10-19 12:28:58 UTC (rev 8715) @@ -38,6 +38,6 @@ public @interface Description { = - String description(); + String value(); = } Modified: modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestProv= iderSupport.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestProviderSu= pport.java 2007-10-19 10:42:51 UTC (rev 8714) +++ modules/test/trunk/unit/src/main/org/jboss/unit/spi/pojo/TestProviderSu= pport.java 2007-10-19 12:28:58 UTC (rev 8715) @@ -118,7 +118,7 @@ = // Description descriptionAnnotation =3D ((AnnotatedElement)testClass).= getAnnotation(Description.class); - String suiteDescription =3D descriptionAnnotation !=3D null ? descri= ptionAnnotation.description() : ""; + String suiteDescription =3D descriptionAnnotation !=3D null ? descri= ptionAnnotation.value() : ""; if (suiteDescription.length() =3D=3D 0) { suiteDescription =3D "Test of class " + testClass.getName(); @@ -226,7 +226,7 @@ = // Description descriptionMethodAnnotation =3D method.getAnnotati= on(Description.class); - String description =3D descriptionMethodAnnotation !=3D null ?= descriptionMethodAnnotation.description() : ""; + String description =3D descriptionMethodAnnotation !=3D null ?= descriptionMethodAnnotation.value() : ""; if (description.length() =3D=3D 0) { description =3D "Parameter " + name; @@ -361,7 +361,7 @@ = // Description descriptionArgumentParameterAnnotation =3D (= Description)parameterAnnotationMap.get(Description.class); - String description =3D descriptionArgumentParameterAnnot= ation !=3D null ? descriptionArgumentParameterAnnotation.description() : ""; + String description =3D descriptionArgumentParameterAnnot= ation !=3D null ? descriptionArgumentParameterAnnotation.value() : ""; if (description.length() =3D=3D 0) { description =3D "Method parameter " + name; @@ -385,7 +385,7 @@ = // Description descriptionMethodAnnotation =3D method.getAnnotati= on(Description.class); - String description =3D descriptionMethodAnnotation !=3D null ?= descriptionMethodAnnotation.description() : ""; + String description =3D descriptionMethodAnnotation !=3D null ?= descriptionMethodAnnotation.value() : ""; if (description.length() =3D=3D 0) { description =3D "Test of method " + method.getName(); --===============9102132251543558372==--