[jboss-cvs] JBossAS SVN: r95133 - in projects/kernel/trunk/weld-int: src/main/java/org/jboss/kernel/weld/plugins/weld and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 19 14:49:28 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-10-19 14:49:28 -0400 (Mon, 19 Oct 2009)
New Revision: 95133
Added:
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceFieldProducer.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceMethodProducer.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceProducer.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/SecurityActions.java
Modified:
projects/kernel/trunk/weld-int/pom.xml
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McBeanRegistryObserver.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java
Log:
[JBKERNEL-51] Enable the tests and implement producer methods and fields. A limitation is that the producer methods cannot take parameters
Modified: projects/kernel/trunk/weld-int/pom.xml
===================================================================
--- projects/kernel/trunk/weld-int/pom.xml 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/pom.xml 2009-10-19 18:49:28 UTC (rev 95133)
@@ -16,7 +16,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <!--skip>true</skip-->
<!--testFailureIgnore>true</testFailureIgnore-->
<excludes>
<exclude>org/jboss/test/kernel/weld/beanwrapper/test/BeanImplementationTestCase.java</exclude>
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceFieldProducer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceFieldProducer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceFieldProducer.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.kernel.weld.plugins.weld;
+
+import java.lang.reflect.Field;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.spi.Producer;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExisitingInstanceFieldProducer<T> extends ExistingInstanceProducer<T>
+{
+ private final Field field;
+
+ ExisitingInstanceFieldProducer(Field field, Producer<T> delegate, T instance)
+ {
+ super(delegate, instance);
+ this.field = field;
+ SecurityActions.setAccessible(field);
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ try
+ {
+ return (T)field.get(getInstance());
+ }
+ catch (Exception e)
+ {
+ throw new CreationException(e);
+ }
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceMethodProducer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceMethodProducer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExisitingInstanceMethodProducer.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.kernel.weld.plugins.weld;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.spi.Producer;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExisitingInstanceMethodProducer<T> extends ExistingInstanceProducer<T>
+{
+ private final Method method;
+
+ ExisitingInstanceMethodProducer(Method method, Producer<T> delegate, T instance)
+ {
+ super(delegate, instance);
+ this.method = method;
+ SecurityActions.setAccessible(method);
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ try
+ {
+ return (T)method.invoke(getInstance());
+ }
+ catch (Exception e)
+ {
+ throw new CreationException(e);
+ }
+ }
+}
Modified: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -34,10 +34,11 @@
*/
public class ExistingInstanceInjectionTarget<T> implements InjectionTarget<T>
{
- InjectionTarget<T> injectionTarget;
- T instance;
+ final InjectionTarget<T> injectionTarget;
- public ExistingInstanceInjectionTarget(InjectionTarget<T> injectionTarget, T instance)
+ final T instance;
+
+ ExistingInstanceInjectionTarget(InjectionTarget<T> injectionTarget, T instance)
{
this.injectionTarget = injectionTarget;
this.instance = instance;
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceProducer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceProducer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceProducer.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.kernel.weld.plugins.weld;
+
+import java.util.Set;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ExistingInstanceProducer<T> implements Producer<T>
+{
+ private final Producer<T> delegate;
+
+ private final T instance;
+
+ ExistingInstanceProducer(Producer<T> delegate, T instance)
+ {
+ this.delegate = delegate;
+ this.instance = instance;
+ }
+
+ public void dispose(T instance)
+ {
+ //Noop
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return delegate.getInjectionPoints();
+ }
+
+ protected final T getInstance()
+ {
+ return instance;
+ }
+}
Modified: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McBeanRegistryObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McBeanRegistryObserver.java 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McBeanRegistryObserver.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -21,12 +21,18 @@
*/
package org.jboss.kernel.weld.plugins.weld;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.enterprise.inject.spi.ProcessProducer;
+import javax.enterprise.inject.spi.Producer;
import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
@@ -46,7 +52,7 @@
}
}
- public void processInjectionTarget(@Observes @SuppressWarnings("unchecked") ProcessInjectionTarget event)
+ public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
AnnotatedType<?> type = event.getAnnotatedType();
WeldKernelControllerContext context = WeldFromMcRegistry.getContext(type);
@@ -58,4 +64,37 @@
event.setInjectionTarget(tgt);
}
}
+
+ public void processProducer(@Observes ProcessProducer<?, ?> event)
+ {
+ AnnotatedType<?> type = event.getAnnotatedMember().getDeclaringType();
+ WeldKernelControllerContext context = WeldFromMcRegistry.getContext(type);
+ if (context != null)
+ {
+ Producer<?> producer = event.getProducer();
+ if (producer.getInjectionPoints().size() > 0)
+ {
+ throw new IllegalStateException("Only producer fields or parameterless producer methods can be used");
+ }
+
+ Member member = event.getAnnotatedMember().getJavaMember();
+
+ if (member instanceof Field)
+ {
+ @SuppressWarnings("unchecked")
+ Producer wrapped = new ExisitingInstanceFieldProducer((Field)member, producer, context.getTarget());
+ event.setProducer(wrapped);
+ }
+ else if (member instanceof Method)
+ {
+ @SuppressWarnings("unchecked")
+ Producer wrapped = new ExisitingInstanceMethodProducer((Method)member, producer, context.getTarget());
+ event.setProducer(wrapped);
+ }
+ else
+ {
+ throw new IllegalStateException("Invalid member type " + member);
+ }
+ }
+ }
}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/SecurityActions.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/SecurityActions.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/SecurityActions.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.kernel.weld.plugins.weld;
+
+import java.lang.reflect.AccessibleObject;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SecurityActions
+{
+ public static void setAccessible(final AccessibleObject member)
+ {
+ if (System.getSecurityManager() == null)
+ member.setAccessible(true);
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+ public Object run()
+ {
+ member.setAccessible(true);
+ return null;
+ }});
+ }
+ }
+}
Modified: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -47,7 +47,7 @@
}
@Override
- public void processInjectionTarget(@Observes ProcessInjectionTarget event)
+ public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
super.processInjectionTarget(event);
}
Modified: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -24,6 +24,7 @@
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.enterprise.inject.spi.ProcessProducer;
import org.jboss.kernel.weld.plugins.weld.McBeanRegistryObserver;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -43,8 +44,14 @@
}
@Override
- public void processInjectionTarget(@Observes ProcessInjectionTarget event)
+ public void processInjectionTarget(@Observes @SuppressWarnings("unchecked") ProcessInjectionTarget event)
{
super.processInjectionTarget(event);
}
-}
+
+ @Override
+ public void processProducer(@Observes ProcessProducer<?, ?> event)
+ {
+ super.processProducer(event);
+ }
+}
\ No newline at end of file
Modified: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java 2009-10-19 18:48:08 UTC (rev 95132)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java 2009-10-19 18:49:28 UTC (rev 95133)
@@ -36,6 +36,7 @@
import org.jboss.kernel.weld.plugins.weld.WeldFromMcRegistry;
import org.jboss.test.kernel.weld.AbstractWeldMcTest;
import org.jboss.test.kernel.weld.mctowb.support.mc.ThingBean;
+import org.jboss.test.kernel.weld.mctowb.support.mc.ThingFieldProducer;
import org.jboss.test.kernel.weld.mctowb.support.mc.ThingMethodProducer;
import org.jboss.test.kernel.weld.mctowb.support.validateobserver.TestObserver;
import org.jboss.test.kernel.weld.mctowb.support.wb.TestMcAfterBeanDiscoveryObserver;
@@ -102,6 +103,7 @@
finally
{
undeployWeld();
+ undeploy(context);
}
}
@@ -148,41 +150,96 @@
}
}
-// public void testInjectMcMethodProducedBeanIntoField() throws Exception
-// {
-// WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingMethodProducer.class));
-// try
-// {
-// ThingMethodProducer thing = assertBean("thing", ThingMethodProducer.class);
-// deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingField.class);
-// Set<Bean<?>> beans = getCurrentManager().getBeans(ThingField.class);
-// assertEquals(1, beans.size());
-// Bean<ThingField> bean = (Bean<ThingField>)beans.iterator().next();
-// CreationalContext<ThingField> createCtx = getCurrentManager().createCreationalContext(null);
-//
-//
-// ThingField thingField = bean.create(createCtx);
-// assertEquals(thing.getThing(), thingField.thing);
-// }
-// finally
-// {
-// undeployWeld();
-// undeploy(context);
-// }
-// }
-//
-// public void testInjectMcMethodProducedBeanIntoConstructor() throws Exception
-// {
-// fail("NYI");
-// }
-//
-// public void testInjectMcFieldProducedBeanIntoField() throws Exception
-// {
-// fail("NYI");
-// }
-//
-// public void testInjectMcFieldProducedBeanIntoConstructor() throws Exception
-// {
-// fail("NYI");
-// }
+ public void testInjectMcMethodProducedBeanIntoField() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingMethodProducer.class));
+ try
+ {
+ ThingMethodProducer thing = assertBean("thing", ThingMethodProducer.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingField.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingField.class);
+ assertEquals(1, beans.size());
+ Bean<ThingField> bean = (Bean<ThingField>)beans.iterator().next();
+ CreationalContext<ThingField> createCtx = getCurrentManager().createCreationalContext(null);
+
+
+ ThingField thingField = bean.create(createCtx);
+ assertEquals(thing.getThing(), thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+ public void testInjectMcMethodProducedBeanIntoConstructor() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingMethodProducer.class));
+ try
+ {
+ ThingMethodProducer thing = assertBean("thing", ThingMethodProducer.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingConstructor.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingConstructor.class);
+ assertEquals(1, beans.size());
+ Bean<ThingConstructor> bean = (Bean<ThingConstructor>)beans.iterator().next();
+ CreationalContext<ThingConstructor> createCtx = getCurrentManager().createCreationalContext(null);
+
+
+ ThingConstructor thingField = bean.create(createCtx);
+ assertEquals(thing.getThing(), thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+ public void testInjectMcFieldProducedBeanIntoField() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingFieldProducer.class));
+ try
+ {
+ ThingFieldProducer thing = assertBean("thing", ThingFieldProducer.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingField.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingField.class);
+ assertEquals(1, beans.size());
+ Bean<ThingField> bean = (Bean<ThingField>)beans.iterator().next();
+ CreationalContext<ThingField> createCtx = getCurrentManager().createCreationalContext(null);
+
+
+ ThingField thingField = bean.create(createCtx);
+ assertEquals(thing.getThing(), thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+ public void testInjectMcFieldProducedBeanIntoConstructor() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingFieldProducer.class));
+ try
+ {
+ ThingFieldProducer thing = assertBean("thing", ThingFieldProducer.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingConstructor.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingConstructor.class);
+ assertEquals(1, beans.size());
+ Bean<ThingConstructor> bean = (Bean<ThingConstructor>)beans.iterator().next();
+ CreationalContext<ThingConstructor> createCtx = getCurrentManager().createCreationalContext(null);
+
+
+ ThingConstructor thingField = bean.create(createCtx);
+ assertEquals(thing.getThing(), thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list