Author: julien(a)jboss.com
Date: 2007-10-11 11:40:00 -0400 (Thu, 11 Oct 2007)
New Revision: 8605
Modified:
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java
modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java
Log:
added support on the @Bootstrap annotation to specify the name under which the annotated
bean will be available in the kernel
Modified: modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java 2007-10-11
15:24:17 UTC (rev 8604)
+++ modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java 2007-10-11
15:40:00 UTC (rev 8605)
@@ -30,7 +30,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-(a)Bootstrap(id="/blah/toto.xml")
+@Bootstrap(resourceName ="/blah/toto.xml")
public class SomeTest
{
Modified: modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java 2007-10-11
15:24:17 UTC (rev 8604)
+++ modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java 2007-10-11
15:40:00 UTC (rev 8605)
@@ -73,16 +73,16 @@
Class<? extends Object> testClass = testCase.getPOJO().getClass();
//
- Bootstrap blah = testClass.getAnnotation(Bootstrap.class);
- if (blah == null)
+ Bootstrap bootstrapAnnotation = testClass.getAnnotation(Bootstrap.class);
+ if (bootstrapAnnotation == null)
{
throw new TestCaseLifeCycleException("No Bootstrap annotation
found");
}
- URL url = testClass.getResource(blah.id());
+ URL url = testClass.getResource(bootstrapAnnotation.resourceName());
if (url == null)
{
- throw new TestCaseLifeCycleException("No URL found for bean xml " +
blah.id());
+ throw new TestCaseLifeCycleException("No URL found for bean xml " +
bootstrapAnnotation.resourceName());
}
// setup MC
@@ -90,7 +90,10 @@
try
{
- AbstractBeanMetaData bmd = new AbstractBeanMetaData("TestCase",
testClass.getName());
+ String beanName = bootstrapAnnotation.beanName();
+
+ //
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData(beanName,
testClass.getName());
AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
bmd.setConstructor(cmd);
TestCaseFactory factory = new TestCaseFactory(testCase.getPOJO());
Modified: modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java
===================================================================
---
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java 2007-10-11
15:24:17 UTC (rev 8604)
+++
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java 2007-10-11
15:40:00 UTC (rev 8605)
@@ -31,7 +31,7 @@
import java.lang.annotation.ElementType;
/**
- * Annotate
+ * Annotate a bean that will trigger the bootstrap of a micro container kernel.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -41,5 +41,17 @@
@Provider(MCTestProvider.class)
public @interface Bootstrap
{
- String id();
+ /**
+ * Returns the resource name by which the bean definition file can be loaded.
+ *
+ * @return the resource name
+ */
+ String resourceName();
+
+ /**
+ * Returns the name under which the annotated bean will be available in the kernel.
The default value is <code>TestCase</code>.
+ *
+ * @return the bean name
+ */
+ String beanName() default "TestCase";
}
Show replies by date