[Jboss-cvs] JBossAS SVN: r55848 - in projects/microcontainer/trunk: container/src/main/org/jboss/reflect/plugins dependency/src/main/org/jboss/dependency/plugins kernel/src/main/org/jboss/beans/metadata/plugins kernel/src/main/org/jboss/beans/metadata/spi/annotations kernel/src/main/org/jboss/kernel/plugins/dependency kernel/src/main/org/jboss/kernel/plugins/deployment/xml kernel/src/main/org/jboss/kernel/plugins/injection kernel/src/resources/org/jboss/test/kernel kernel/src/resources/org/jboss/test/kernel/inject kernel/src/resources/org/jboss/test/kernel/inject/test kernel/src/resources/schema kernel/src/tests/org/jboss/test/kernel kernel/src/tests/org/jboss/test/kernel/deployment/xml/test kernel/src/tests/org/jboss/test/kernel/inject kernel/src/tests/org/jboss/test/kernel/inject/support kernel/src/tests/org/jboss/test/kernel/inject/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Aug 13 11:21:22 EDT 2006
Author: alesj
Date: 2006-08-13 11:20:52 -0400 (Sun, 13 Aug 2006)
New Revision: 55848
Added:
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/ParameterContextualInjection.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeLooseTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeStrictTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameLooseSimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameStrictSimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedSimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeLooseSimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeStrictSimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/DuplicateTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/ParameterTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SimpleTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SingletonTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterface.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterfaceGetter.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ParameterContextualInjectionTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ConfigureAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/injection/InjectionUtil.java
projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd
projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/InjectionTestCase.java
Log:
ContextualInjection TestCases and minor fixes.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/AnnotationHolder.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -70,11 +70,13 @@
public AnnotationValue getAnnotation(String name)
{
+ if (annotationMap == null) return null;
return annotationMap.get(name);
}
public boolean isAnnotationPresent(String name)
{
+ if (annotationMap == null) return false;
return annotationMap.containsKey(name);
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -820,7 +820,7 @@
Object target = context.getTarget();
if (target != null)
{
- traverseBean(context, target.getClass(), addition);
+ traverseBean(context, target.getClass(), addition, log.isTraceEnabled());
}
}
finally
@@ -836,7 +836,7 @@
* @param context context whose target is instance of clazz
* @param clazz current class to map context to
*/
- protected void traverseBean(ControllerContext context, Class clazz, boolean addition)
+ protected void traverseBean(ControllerContext context, Class clazz, boolean addition, boolean trace)
{
if (clazz == null || clazz == Object.class)
{
@@ -850,12 +850,20 @@
beans = new HashSet<ControllerContext>();
contextsByClass.put(clazz, beans);
}
+ if (trace)
+ {
+ log.trace("Mapping contex " + context + " to class: " + clazz);
+ }
beans.add(context);
}
else
{
if (beans != null)
{
+ if (trace)
+ {
+ log.trace("Removing contex " + context + " to class: " + clazz);
+ }
beans.remove(context);
if (beans.isEmpty())
{
@@ -864,12 +872,12 @@
}
}
// traverse superclass
- traverseBean(context, clazz.getSuperclass(), addition);
+ traverseBean(context, clazz.getSuperclass(), addition, trace);
Class[] interfaces = clazz.getInterfaces();
// traverse interfaces
for(Class intface : interfaces)
{
- traverseBean(context, intface, addition);
+ traverseBean(context, intface, addition, trace);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -118,7 +118,7 @@
return InjectionUtil.resolveInjection(
controller,
info.getType(),
- propertyMetaData.getName(), // should not be used - value set before, see visit(MDV visitor)
+ null, // should not be used - value set before, see visit(MDV visitor)
state,
getInjectionMode(),
getInjectionType(),
@@ -141,6 +141,10 @@
if (InjectionMode.BY_NAME.equals(injectionMode))
{
+ if (propertyMetaData == null)
+ {
+ throw new IllegalArgumentException("Illegal usage of mode ByName - injection not used with property = " + this);
+ }
setValue(propertyMetaData.getName());
}
else if (InjectionMode.BY_TYPE.equals(injectionMode))
@@ -167,5 +171,7 @@
buffer.append(" injectionMode=").append(injectionMode);
if (injectionType != null)
buffer.append(" injectionType=").append(injectionType);
+ if (propertyMetaData != null)
+ buffer.append(" propertyMetaData=").append(propertyMetaData.getName()); //else overflow - indefinite recursion
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -26,7 +26,7 @@
*/
public enum InjectType
{
- STRICT("Strinct"),
+ STRICT("Strict"),
LOOSE("Loose");
private String typeString;
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ConfigureAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ConfigureAction.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ConfigureAction.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -26,18 +26,21 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.injection.InjectionMode;
import org.jboss.beans.metadata.injection.InjectionType;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
import org.jboss.joinpoint.spi.TargettedJoinpoint;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.injection.InjectionUtil;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.reflect.spi.*;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.EnumValue;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.StringValue;
/**
* ConfigureAction.
@@ -59,7 +62,7 @@
BeanMetaData metaData = context.getBeanMetaData();
Set joinPoints = configurator.getPropertySetterJoinPoints(info, metaData);
setAttributes(context, object, joinPoints, false);
-// resolveInjections(controller, info, object);
+ resolveInjections(controller, info, object);
}
public void uninstallAction(KernelControllerContext context)
@@ -75,7 +78,7 @@
{
Set joinPoints = configurator.getPropertyNullerJoinPoints(info, metaData);
setAttributes(context, object, joinPoints, true);
-// nullifyInjections(controller, info, object, true);
+ nullifyInjections(controller, info, object, true);
}
catch (Throwable t)
{
@@ -86,9 +89,9 @@
/**
* Set the attributes
*
- * @param context the context
- * @param target the target
- * @param joinPoints the attribute setter joinpoints
+ * @param context the context
+ * @param target the target
+ * @param joinPoints the attribute setter joinpoints
* @param ignoreErrors whether to ignore errors
* @throws Throwable for any unignored error
*/
@@ -125,59 +128,56 @@
protected void resolveInjections(KernelController controller, BeanInfo info, Object target) throws Throwable
{
Set<PropertyInfo> propertys = info.getProperties();
- for(PropertyInfo pi : propertys)
+ for (PropertyInfo pi : propertys)
{
MethodInfo setter = pi.getSetter();
- AnnotationValue annotation = setter.getAnnotation("org.jboss.beans.metadata.spi.annotations.Inject");
- if (annotation != null)
+ if (setter != null)
{
- AnnotationInfo annotationInfo = annotation.getAnnotationType();
- AnnotationAttribute beanAttribute = annotationInfo.getAttribute("bean");
- AnnotationAttribute propertyAttribute = annotationInfo.getAttribute("property");
- AnnotationAttribute stateAttribute = annotationInfo.getAttribute("state");
- AnnotationAttribute modeAttribute = annotationInfo.getAttribute("mode");
- AnnotationAttribute typeAttribute = annotationInfo.getAttribute("type");
- // todo - are these right values?
- StringValue beanValue = (StringValue) beanAttribute.getDefaultValue();
- StringValue propertyValue = (StringValue) propertyAttribute.getDefaultValue();
- StringValue stateValue = (StringValue) stateAttribute.getDefaultValue();
- EnumValue modeValue = (EnumValue) modeAttribute.getDefaultValue();
- EnumValue typeValue = (EnumValue) typeAttribute.getDefaultValue();
+ AnnotationValue annotation = setter.getAnnotation("org.jboss.beans.metadata.spi.annotations.Inject");
+ if (annotation != null)
+ {
+ StringValue beanValue = (StringValue) annotation.getValue("bean");
+ StringValue propertyValue = (StringValue) annotation.getValue("property");
+ StringValue stateValue = (StringValue) annotation.getValue("state");
+ EnumValue modeValue = (EnumValue) annotation.getValue("mode");
+ EnumValue typeValue = (EnumValue) annotation.getValue("type");
- String value = beanValue.getValue();
- String bean = (value != null && value.length() > 0 ? value : null);
- value = propertyValue.getValue();
- String property = (value != null && value.length() > 0 ? value : null);
- ControllerState state = new ControllerState(stateValue.getValue());
- InjectionMode injectionMode = new InjectionMode(modeValue.getValue());
- InjectionType injectionType = new InjectionType(typeValue.getValue());
- Object result = null;
- if (bean != null)
- {
- ControllerContext context = controller.getContext(bean, state);
- if (context != null && context.getTarget() != null)
+ String value = beanValue.getValue();
+ String bean = (value != null && value.length() > 0 ? value : null);
+ value = propertyValue.getValue();
+ String property = (value != null && value.length() > 0 ? value : null);
+ ControllerState state = new ControllerState(stateValue.getValue());
+ InjectionMode injectionMode = new InjectionMode(modeValue.getValue());
+ InjectionType injectionType = new InjectionType(typeValue.getValue());
+
+ Object result = null;
+ if (bean != null)
{
- result = getResult(controller, context.getTarget(), property);
+ ControllerContext context = controller.getContext(bean, state);
+ if (context != null && context.getTarget() != null)
+ {
+ result = getResult(controller, context.getTarget(), property);
+ }
}
- }
- else
- {
- // check for property
- if (property != null)
+ else
{
- log.warn("Ignoring property - contextual injection: " + pi);
+ // check for property
+ if (property != null)
+ {
+ log.warn("Ignoring property - contextual injection: " + pi);
+ }
+ result = InjectionUtil.resolveInjection(
+ controller,
+ pi.getType().getType(),
+ pi.getName(),
+ state,
+ injectionMode,
+ injectionType,
+ pi
+ );
}
- result = InjectionUtil.resolveInjection(
- controller,
- pi.getType().getType(),
- pi.getName(),
- state,
- injectionMode,
- injectionType,
- pi
- );
+ setter.invoke(target, new Object[]{result});
}
- setter.invoke(target, new Object[]{result});
}
}
}
@@ -198,26 +198,29 @@
protected void nullifyInjections(KernelController controller, BeanInfo info, Object target, boolean ignoreErrors) throws Throwable
{
Set<PropertyInfo> propertys = info.getProperties();
- for(PropertyInfo pi : propertys)
+ for (PropertyInfo pi : propertys)
{
MethodInfo setter = pi.getSetter();
- AnnotationValue annotation = setter.getAnnotation("org.jboss.beans.metadata.spi.annotations.Inject");
- if (annotation != null)
+ if (setter != null)
{
- try
+ AnnotationValue annotation = setter.getAnnotation("org.jboss.beans.metadata.spi.annotations.Inject");
+ if (annotation != null)
{
- setter.invoke(target, new Object[]{null});
- }
- catch (Throwable t)
- {
- if (ignoreErrors)
+ try
{
- if (log.isTraceEnabled())
- log.trace("Ignored for " + pi, t);
+ setter.invoke(target, new Object[]{null});
}
- else
+ catch (Throwable t)
{
- throw t;
+ if (ignoreErrors)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Ignored for " + pi, t);
+ }
+ else
+ {
+ throw t;
+ }
}
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -71,7 +71,7 @@
if (object instanceof KernelControllerContextAware)
((KernelControllerContextAware) object).setKernelControllerContext(context);
-// controller.addInstantiatedContext(context);
+ controller.addInstantiatedContext(context);
}
}
catch (Throwable t)
@@ -91,8 +91,8 @@
if (object instanceof KernelControllerContextAware)
((KernelControllerContextAware) object).unsetKernelControllerContext(context);
-// KernelController controller = (KernelController) context.getController();
-// controller.removeInstantiatedContext(context);
+ KernelController controller = (KernelController) context.getController();
+ controller.removeInstantiatedContext(context);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -953,16 +953,15 @@
{
public Object startElement(Object parent, QName name, ElementBinding element)
{
- return new AbstractInjectionValueMetaData();
+ AbstractInjectionValueMetaData vmd = new AbstractInjectionValueMetaData();
+ if (parent instanceof AbstractPropertyMetaData)
+ {
+ AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent;
+ vmd.setPropertyMetaData(x);
+ }
+ return vmd;
}
- public void setParent(Object parent, Object o, QName qName, ElementBinding element, ElementBinding parentElement)
- {
- AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent;
- AbstractInjectionValueMetaData child = (AbstractInjectionValueMetaData) o;
- child.setPropertyMetaData(x);
- }
-
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) o;
@@ -975,10 +974,10 @@
injection.setProperty(attrs.getValue(i));
else if ("state".equals(localName))
injection.setDependentState(new ControllerState(attrs.getValue(i)));
- else if ("injectionMode".equals(localName))
- injection.setInjectionMode(new InjectionMode(localName));
- else if ("injectionType".equals(localName))
- injection.setInjectionType(new InjectionType(localName));
+ else if ("mode".equals(localName))
+ injection.setInjectionMode(new InjectionMode(attrs.getValue(i)));
+ else if ("type".equals(localName))
+ injection.setInjectionType(new InjectionType(attrs.getValue(i)));
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -14,6 +14,7 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.logging.Logger;
import org.xml.sax.Attributes;
/**
@@ -29,16 +30,15 @@
public Object startElement(Object parent, QName name, ElementBinding element)
{
- return new AbstractInjectionValueMetaData();
+ AbstractInjectionValueMetaData vmd = new AbstractInjectionValueMetaData();
+ if (parent instanceof AbstractPropertyMetaData)
+ {
+ AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent;
+ vmd.setPropertyMetaData(x);
+ }
+ return vmd;
}
- public void setParent(Object parent, Object o, QName qName, ElementBinding element, ElementBinding parentElement)
- {
- AbstractPropertyMetaData x = (AbstractPropertyMetaData) parent;
- AbstractInjectionValueMetaData child = (AbstractInjectionValueMetaData) o;
- child.setPropertyMetaData(x);
- }
-
public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
{
AbstractInjectionValueMetaData injection = (AbstractInjectionValueMetaData) o;
@@ -51,10 +51,10 @@
injection.setProperty(attrs.getValue(i));
else if ("state".equals(localName))
injection.setDependentState(new ControllerState(attrs.getValue(i)));
- else if ("injectionMode".equals(localName))
- injection.setInjectionMode(new InjectionMode(localName));
- else if ("injectionType".equals(localName))
- injection.setInjectionType(new InjectionType(localName));
+ else if ("mode".equals(localName))
+ injection.setInjectionMode(new InjectionMode(attrs.getValue(i)));
+ else if ("type".equals(localName))
+ injection.setInjectionType(new InjectionType(attrs.getValue(i)));
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/injection/InjectionUtil.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/injection/InjectionUtil.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/injection/InjectionUtil.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -64,7 +64,11 @@
if (InjectionMode.BY_TYPE.equals(mode))
{
Set<ControllerContext> contexts = controller.getInstantiatedContexts(targetClass);
- int numberOfMatchingBeans = contexts.size();
+ int numberOfMatchingBeans = 0;
+ if (contexts != null)
+ {
+ numberOfMatchingBeans = contexts.size();
+ }
if (numberOfMatchingBeans > 1)
{
throw new Error("Should not be here, too many matching contexts - dependency failed! " + messageObject);
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName" type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleNameStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/MultipleTypeStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName" type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullNameStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/NullTypeStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/ParameterContextualInjection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/ParameterContextualInjection.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/ParameterContextualInjection.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="duplicateTester" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="parameterObject1" class="org.jboss.test.kernel.inject.support.ParameterTestObject">
+ <constructor>
+ <parameter><inject/></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName" type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleNameStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="testerInterface" class="org.jboss.test.kernel.inject.support.SingletonTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject mode="ByName"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeLooseTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeLooseTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeLooseTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject type="Loose"/></property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeStrictTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeStrictTestCase.xml 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/inject/test/SingleTypeStrictTestCase.xml 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="duplicateInterface" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.SimpleTestObject">
+ <property name="testerInterface"><inject/></property>
+ </bean>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd 2006-08-13 15:20:52 UTC (rev 55848)
@@ -291,8 +291,8 @@
<xsd:attribute name="bean" type="xsd:string" use="optional"/>
<xsd:attribute name="property" type="xsd:string" use="optional"/>
<xsd:attribute name="state" type="controllerStateType" use="optional"/>
- <xsd:attribute name="injectionMode" type="xsd:string" use="optional" default="ByType"/>
- <xsd:attribute name="injectionType" type="xsd:string" use="optional" default="Strict"/>
+ <xsd:attribute name="mode" type="injectionModeType" use="optional" default="ByType"/>
+ <xsd:attribute name="type" type="injectionTypeType" use="optional" default="Strict"/>
</xsd:complexType>
<xsd:complexType name="parameterType" mixed="true">
@@ -429,8 +429,7 @@
<xsd:element name="set" type="setType"/>
<xsd:element name="array" type="arrayType"/>
<xsd:element name="map" type="mapType"/>
- <xsd:element name="inject" type="dependencyType"/>
- <!--<xsd:element name="inject" type="injectionType"/>-->
+ <xsd:element name="inject" type="injectionType"/>
<xsd:element name="null">
<xsd:complexType/>
</xsd:element>
@@ -770,7 +769,40 @@
</xsd:restriction>
</xsd:simpleType>
- <!--
+ <xsd:simpleType name="injectionModeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ You can set the type of lookup requirement - class type (ByType) or property name (ByName)
+ Valid values include:
+ ByType (default)
+ ByName
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="injectionTypeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ You can set what is the severity of injected bean not found.
+ When set to Strict (default) it will fail, else it will inject null.
+ Valid values include:
+ Strict
+ Loose
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!--
WARN:
Do not use this in the bean deployer, it won't work!
FIXME:
Modified: projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd 2006-08-13 15:20:52 UTC (rev 55848)
@@ -347,8 +347,8 @@
<xsd:attribute name="bean" type="xsd:string" use="optional"/>
<xsd:attribute name="property" type="xsd:string" use="optional"/>
<xsd:attribute name="state" type="controllerStateType" use="optional"/>
- <xsd:attribute name="injectionMode" type="xsd:string" use="optional" default="ByType"/>
- <xsd:attribute name="injectionType" type="xsd:string" use="optional" default="Strict"/>
+ <xsd:attribute name="mode" type="injectionModeType" use="optional" default="ByType"/>
+ <xsd:attribute name="type" type="injectionTypeType" use="optional" default="Strict"/>
</xsd:complexType>
<xsd:complexType name="factoryType">
@@ -517,8 +517,7 @@
<xsd:element name="set" type="setType"/>
<xsd:element name="array" type="arrayType"/>
<xsd:element name="map" type="mapType"/>
- <xsd:element name="inject" type="dependencyType"/>
- <!--<xsd:element name="inject" type="injectionType"/>-->
+ <xsd:element name="inject" type="injectionType"/>
<xsd:element name="null">
<xsd:complexType/>
</xsd:element>
@@ -860,7 +859,40 @@
</xsd:restriction>
</xsd:simpleType>
- <!--
+ <xsd:simpleType name="injectionModeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ You can set the type of lookup requirement - class type (ByType) or property name (ByName)
+ Valid values include:
+ ByType (default)
+ ByName
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="injectionTypeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ You can set what is the severity of injected bean not found.
+ When set to Strict (default) it will fail, else it will inject null.
+ Valid values include:
+ Strict
+ Loose
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!--
WARN:
Do not use this in the bean deployer, it won't work!
FIXME:
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -33,6 +33,7 @@
import org.jboss.test.kernel.deployment.xml.test.XMLTestSuite;
import org.jboss.test.kernel.event.test.EventTestSuite;
import org.jboss.test.kernel.registry.test.RegistryTestSuite;
+import org.jboss.test.kernel.inject.test.ContextualInjectionTestSuite;
/**
* Kernel Test Suite.
@@ -58,8 +59,9 @@
suite.addTest(DependencyTestSuite.suite());
suite.addTest(ControllerTestSuite.suite());
suite.addTest(DeploymentTestSuite.suite());
+ suite.addTest(ContextualInjectionTestSuite.suite());
suite.addTest(XMLTestSuite.suite());
-
+
return suite;
}
}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/InjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/InjectionTestCase.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/InjectionTestCase.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -27,6 +27,7 @@
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.dependency.spi.ControllerState;
@@ -81,8 +82,8 @@
{
try
{
- unmarshalBean("InjectionBadNoBean.xml");
- fail("Should not be here");
+ AbstractDependencyValueMetaData dependency = getInjection("InjectionBadNoBean.xml");
+ assertNull(dependency.getValue());
}
catch (Exception expected)
{
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameLooseSimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameLooseSimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameLooseSimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+import org.jboss.beans.metadata.spi.annotations.InjectMode;
+import org.jboss.beans.metadata.spi.annotations.InjectType;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotatedNameLooseSimpleTestObject extends AnnotatedSimpleTestObject
+{
+
+ @Inject(mode = InjectMode.BY_NAME, type = InjectType.LOOSE)
+ public void setTesterInterface(TesterInterface testerInterface)
+ {
+ this.testerInterface = testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameStrictSimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameStrictSimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedNameStrictSimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+import org.jboss.beans.metadata.spi.annotations.InjectMode;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotatedNameStrictSimpleTestObject extends AnnotatedSimpleTestObject
+{
+
+ @Inject(mode = InjectMode.BY_NAME)
+ public void setTesterInterface(TesterInterface testerInterface)
+ {
+ this.testerInterface = testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedSimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedSimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedSimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+import org.jboss.beans.metadata.spi.annotations.InjectMode;
+import org.jboss.beans.metadata.spi.annotations.InjectType;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public abstract class AnnotatedSimpleTestObject implements TesterInterfaceGetter
+{
+
+ protected TesterInterface testerInterface;
+
+ public TesterInterface getTesterInterface()
+ {
+ return testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeLooseSimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeLooseSimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeLooseSimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+import org.jboss.beans.metadata.spi.annotations.InjectType;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotatedTypeLooseSimpleTestObject extends AnnotatedSimpleTestObject
+{
+
+ @Inject(type = InjectType.LOOSE)
+ public void setTesterInterface(TesterInterface testerInterface)
+ {
+ this.testerInterface = testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeStrictSimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeStrictSimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotatedTypeStrictSimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotatedTypeStrictSimpleTestObject extends AnnotatedSimpleTestObject
+{
+
+ @Inject
+ public void setTesterInterface(TesterInterface testerInterface)
+ {
+ this.testerInterface = testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/DuplicateTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/DuplicateTester.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/DuplicateTester.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class DuplicateTester implements TesterInterface
+{
+
+ public void someMethod()
+ {
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/ParameterTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/ParameterTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/ParameterTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,16 @@
+package org.jboss.test.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class ParameterTestObject
+{
+
+ private DuplicateTester duplicateTester;
+
+ public ParameterTestObject(DuplicateTester duplicateTester)
+ {
+ this.duplicateTester = duplicateTester;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SimpleTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SimpleTestObject.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SimpleTestObject.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+import org.jboss.beans.metadata.spi.annotations.Inject;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class SimpleTestObject implements TesterInterfaceGetter
+{
+
+ private TesterInterface testerInterface;
+
+ public TesterInterface getTesterInterface()
+ {
+ return testerInterface;
+ }
+
+ public void setTesterInterface(TesterInterface testerInterface)
+ {
+ this.testerInterface = testerInterface;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SingletonTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SingletonTester.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SingletonTester.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class SingletonTester implements TesterInterface
+{
+
+ public void someMethod()
+ {
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterface.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterface.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterface.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public interface TesterInterface
+{
+
+ void someMethod();
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterfaceGetter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterfaceGetter.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/TesterInterfaceGetter.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,30 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public interface TesterInterfaceGetter
+{
+ TesterInterface getTesterInterface();
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.kernel.inject.test;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.textui.TestRunner;
+
+/**
+ * Contextual injection Test Suite.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class ContextualInjectionTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(ContextualInjectionTestSuite.suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Contextal injection Tests");
+
+ suite.addTest(ParameterContextualInjectionTestCase.suite());
+// suite.addTest(PropertyContextualInjectionTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ParameterContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ParameterContextualInjectionTestCase.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ParameterContextualInjectionTestCase.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,36 @@
+package org.jboss.test.kernel.inject.test;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.test.kernel.inject.support.TesterInterfaceGetter;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class ParameterContextualInjectionTestCase extends MicrocontainerTest
+{
+ public ParameterContextualInjectionTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ParameterContextualInjectionTestCase.class);
+ }
+
+ public void testContextualInjection() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ParameterContextualInjection.xml");
+ try
+ {
+ validate();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java 2006-08-12 20:19:52 UTC (rev 55847)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java 2006-08-13 15:20:52 UTC (rev 55848)
@@ -0,0 +1,91 @@
+package org.jboss.test.kernel.inject.test;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.test.kernel.inject.support.TesterInterfaceGetter;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class PropertyContextualInjectionTestCase extends MicrocontainerTest
+{
+ private static final String[] PREFIX = new String[]{"", "Ann"};
+ private static final String[] NUMBER = new String[]{"Single", "Multiple", "Null"};
+ private static final String[] MODE = new String[]{"Type", "Name"};
+ private static final String[] TYPE = new String[]{"Loose", "Strict"};
+ private static final String TEST_CASE_SUFFIX = "TestCase.xml";
+
+ public PropertyContextualInjectionTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(PropertyContextualInjectionTestCase.class);
+ }
+
+ public void testContextualInjection() throws Throwable
+ {
+ for(int i = 0; i < PropertyContextualInjectionTestCase.PREFIX.length; i++)
+ {
+ for(int j = 0; j < PropertyContextualInjectionTestCase.NUMBER.length; j++)
+ {
+ for(int k = 0; k < PropertyContextualInjectionTestCase.MODE.length; k++)
+ {
+ for(int l = 0; l < PropertyContextualInjectionTestCase.TYPE.length; l++)
+ {
+ executeTestCase(PropertyContextualInjectionTestCase.PREFIX[i] + PropertyContextualInjectionTestCase.NUMBER[j] + PropertyContextualInjectionTestCase.MODE[k] + PropertyContextualInjectionTestCase.TYPE[l] + PropertyContextualInjectionTestCase.TEST_CASE_SUFFIX);
+ }
+ }
+ }
+ }
+ }
+
+ private void executeTestCase(String testCaseName) throws Throwable
+ {
+ getLog().info("Testing contextual injection: "+ testCaseName);
+ KernelDeployment deployment = null;
+ try
+ {
+ deployment = deploy(testCaseName);
+
+ validate();
+
+ TesterInterfaceGetter interfaceGetter = (TesterInterfaceGetter) getBean("testObject");
+ boolean isSingle = testCaseName.indexOf("Single") >= 0;
+ assertFalse(interfaceGetter == null && isStrict(testCaseName) && isSingle);
+ }
+ catch(Throwable t)
+ {
+ // check if we expect Throwable - e.g. NullTypeStrictTestCase, ...
+ if (isThrowableExpected(testCaseName) == false)
+ {
+ throw t;
+ }
+ // get some info about 'failure'
+ getLog().info(t);
+ }
+ finally {
+ if (deployment != null)
+ {
+ undeploy(deployment);
+ }
+ }
+ }
+
+ // MultipleNameStrictTC is excluded - unique name requirement
+ private boolean isThrowableExpected(String testCaseName)
+ {
+ boolean isMultiple = testCaseName.indexOf("Multiple") >= 0;
+ boolean isNull = testCaseName.indexOf("Null") >= 0;
+ return isMultiple || (isNull && isStrict(testCaseName));
+ }
+
+ private boolean isStrict(String testCaseName)
+ {
+ return testCaseName.indexOf("Strict") >= 0;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list