[webbeans-commits] Webbeans SVN: r203 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: util and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-10-29 03:24:34 -0400 (Wed, 29 Oct 2008)
New Revision: 203
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ProxyData.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java
Log:
more client proxy theories
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 23:07:14 UTC (rev 202)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-29 07:24:34 UTC (rev 203)
@@ -42,7 +42,6 @@
{
private class ContextMap extends MapWrapper<Class<? extends Annotation>, List<Context>>
{
-
public ContextMap()
{
super(new HashMap<Class<? extends Annotation>, List<Context>>());
@@ -52,25 +51,21 @@
{
return (List<Context>) super.get(key);
}
-
}
- private class ProxyPool extends MapWrapper<Bean<?>, ClientProxy<?>>
+ private class ProxyPool extends MapWrapper<Bean<?>, Bean<?>>
{
-
public ProxyPool()
{
- super(new HashMap<Bean<?>, ClientProxy<?>>());
+ super(new HashMap<Bean<?>, Bean<?>>());
}
- public ClientProxy<?> get(Bean<?> key)
+ public Bean<?> get(Bean<?> key)
{
- return (ClientProxy<?>) super.get(key);
+ return (Bean<?>) super.get(key);
}
+ }
- }
-
-
private List<Class<? extends Annotation>> enabledDeploymentTypes;
private ModelManager modelManager;
private EjbManager ejbLookupManager;
@@ -111,14 +106,14 @@
}
}
}
-
- protected void initContexts(Context ... contexts)
+
+ protected void initContexts(Context... contexts)
{
this.contextMap = new ContextMap();
if (contexts == null)
{
-
- this.dependentContext = new DependentContext();
+
+ this.dependentContext = new DependentContext();
addContext(dependentContext);
addContext(new RequestContext());
addContext(new SessionContext());
@@ -236,20 +231,22 @@
public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
{
- // TODO Using the eventType TypeLiteral<T>, the Class<T> object must be retrieved
- this.eventBus.addObserver(observer, (Class<T>)Reflections.getActualTypeArguements(eventType.getClass())[0], bindings);
+ // TODO Using the eventType TypeLiteral<T>, the Class<T> object must be
+ // retrieved
+ this.eventBus.addObserver(observer, (Class<T>) Reflections.getActualTypeArguements(eventType.getClass())[0], bindings);
return this;
}
public void fireEvent(Object event, Annotation... bindings)
{
- // Check the event object for template parameters which are not allowed by the spec.
+ // Check the event object for template parameters which are not allowed by
+ // the spec.
if (Reflections.isParameterizedType(event.getClass()))
{
- throw new IllegalArgumentException("Event type " + event.getClass().getName() +
- " is not allowed because it is a generic");
+ throw new IllegalArgumentException("Event type " + event.getClass().getName() + " is not allowed because it is a generic");
}
- // Get the observers for this event. Although resolveObservers is parameterized, this
+ // Get the observers for this event. Although resolveObservers is
+ // parameterized, this
// method is not, so we have to use Observer<Object> for observers.
Set<Observer<Object>> observers = this.resolveObservers(event, bindings);
this.eventBus.notifyObservers(observers, event);
@@ -290,7 +287,7 @@
dependentContext.setActive(true);
if (getModelManager().getScopeModel(bean.getScopeType()).isNormal())
{
- return (T) getClientProxy(bean).getInstance();
+ return (T) getClientProxy(bean);
}
else
{
@@ -363,8 +360,9 @@
public <T> Manager removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
{
- // TODO The Class<T> for the event type must be retrieved from the TypeLiteral<T> instance
- this.eventBus.removeObserver(observer, (Class<T>)Reflections.getActualTypeArguements(eventType.getClass())[0], bindings);
+ // TODO The Class<T> for the event type must be retrieved from the
+ // TypeLiteral<T> instance
+ this.eventBus.removeObserver(observer, (Class<T>) Reflections.getActualTypeArguements(eventType.getClass())[0], bindings);
return this;
}
@@ -384,17 +382,21 @@
// TODO Auto-generated method stub
return null;
}
-
- private ClientProxy<?> getClientProxy(Bean<?> bean)
+
+ private Bean<?> getClientProxy(Bean<?> bean)
{
- ClientProxy<?> clientProxy = proxyPool.get(bean);
+ Bean<?> clientProxy = proxyPool.get(bean);
if (clientProxy == null)
{
- clientProxy = new ClientProxy(bean, this);
+ try
+ {
+ clientProxy = ClientProxyUtil.createProxy(new ProxyData(bean, this));
+ } catch (Exception e) {
+ throw new UnproxyableDependencyException("Could not create proxy", e);
+ }
proxyPool.put(bean, clientProxy);
}
return clientProxy;
}
-
}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ProxyData.java (from rev 201, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ClientProxy.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ProxyData.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ProxyData.java 2008-10-29 07:24:34 UTC (rev 203)
@@ -0,0 +1,27 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
+
+public class ProxyData
+{
+ private Bean<?> bean;
+ private Manager manager;
+
+ public ProxyData(Bean<?> bean, Manager manager)
+ {
+ this.bean = bean;
+ this.manager = manager;
+ }
+
+ public Bean<?> getBean()
+ {
+ return bean;
+ }
+
+ public Manager getManager()
+ {
+ return manager;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ProxyData.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java 2008-10-28 23:07:14 UTC (rev 202)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java 2008-10-29 07:24:34 UTC (rev 203)
@@ -1,6 +1,19 @@
package org.jboss.webbeans.util;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+import javax.webbeans.manager.Manager;
+
+import org.jboss.webbeans.ProxyData;
+
+
public class ClientProxyUtil
{
@@ -30,4 +43,27 @@
}
}
+ private static MethodHandler methodHandler = new MethodHandler()
+ {
+ public Object invoke(Object self, Method m, Method proceed, Object[] args) throws Throwable
+ {
+ ProxyData proxyData = (ProxyData)self;
+ Manager manager = proxyData.getManager();
+ Class<? extends Annotation> beanScope = proxyData.getBean().getScopeType();
+ Context context = manager.getContext(beanScope);
+ Object instance = context.get(proxyData.getBean(), true);
+ return proceed.invoke(instance, args);
+ }
+ };
+
+ public static Bean<?> createProxy(ProxyData clientProxy) throws InstantiationException, IllegalAccessException
+ {
+ ProxyFactory proxyFactory = new ProxyFactory();
+ proxyFactory.setSuperclass(clientProxy.getClass());
+ Class<?> proxyClass = proxyFactory.createClass();
+ Bean<?> proxy = (Bean<?>) proxyClass.newInstance();
+ ((ProxyObject)proxy).setHandler(methodHandler);
+ return proxy;
+ }
+
}
16 years
[webbeans-commits] Webbeans SVN: r202 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/util and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 19:07:14 -0400 (Tue, 28 Oct 2008)
New Revision: 202
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FarmOffice.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithFinalBoundField.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithStaticBoundField.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java
Log:
Remaining injection tests
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -105,6 +105,14 @@
injectableFields = new HashSet<InjectableField<?>>();
for (AnnotatedField<Object> annotatedField : annotatedItem.getMetaAnnotatedFields(BindingType.class))
{
+ if (Reflections.isStatic(annotatedField.getDelegate()))
+ {
+ throw new DefinitionException("Don't place binding annotations on static fields " + annotatedField);
+ }
+ if (Reflections.isFinal(annotatedField.getDelegate()))
+ {
+ throw new DefinitionException("Don't place binding annotations on final fields " + annotatedField);
+ }
InjectableField<?> injectableField = new InjectableField<Object>(annotatedField);
injectableFields.add(injectableField);
super.injectionPoints.add(injectableField);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -60,6 +60,11 @@
return Modifier.isFinal(method.getModifiers());
}
+ public static boolean isFinal(Field field)
+ {
+ return Modifier.isFinal(field.getModifiers());
+ }
+
public static boolean isTypeOrAnyMethodFinal(Class<?> type)
{
if (isFinal(type))
@@ -81,6 +86,16 @@
return type.isPrimitive();
}
+ public static boolean isStatic(Class<?> type)
+ {
+ return Modifier.isStatic(type.getModifiers());
+ }
+
+ public static boolean isStatic(Field field)
+ {
+ return Modifier.isStatic(field.getModifiers());
+ }
+
public static boolean isAbstract(Class<?> clazz)
{
return Modifier.isAbstract(clazz.getModifiers());
@@ -88,12 +103,12 @@
public static boolean isStaticInnerClass(Class<?> clazz)
{
- return clazz.isMemberClass() && Modifier.isStatic(clazz.getModifiers());
+ return clazz.isMemberClass() && isStatic(clazz);
}
public static boolean isNonStaticInnerClass(Class<?> clazz)
{
- return clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers());
+ return clazz.isMemberClass() && !isStatic(clazz);
}
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -39,7 +39,7 @@
order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
}
- @Test(groups="injection") @SpecAssertion(section="2.3.1")
+ @Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="2.3.1")
public void testDefaultBindingTypeAssumedAtInjectionPoint() throws Exception
{
assert false;
@@ -142,7 +142,7 @@
assert false;
}
- @Test(groups="injection")
+ @Test(groups={"injection", "producerMethod"})
public void testMethodWithBindingAnnotationsOnParametersAreInjected()
{
assert false;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -1,62 +1,82 @@
package org.jboss.webbeans.test;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
+
import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.DefinitionException;
import javax.webbeans.NonexistentFieldException;
import javax.webbeans.NullableDependencyException;
+import javax.webbeans.manager.Bean;
+import org.jboss.webbeans.SimpleBeanImpl;
+import org.jboss.webbeans.test.beans.Fox;
+import org.jboss.webbeans.test.beans.FoxRun;
+import org.jboss.webbeans.test.beans.Tuna;
+import org.jboss.webbeans.test.beans.broken.BeanWithFinalBoundField;
+import org.jboss.webbeans.test.beans.broken.BeanWithStaticBoundField;
import org.testng.annotations.Test;
@SpecVersion("PDR")
public class InjectionTests extends AbstractTest
{
- @Test(groups="injection") @SpecAssertion(section="4.2")
+ @Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testPrimitiveTypesEquivalentToBoxedTypes()
{
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="4.2")
+ @Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testInjectionPerformsBoxingIfNecessary()
{
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="4.2")
+ @Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="4.2")
public void testInjectionPerformsUnboxingIfNecessary()
{
assert false;
}
- @Test(groups="injection", expectedExceptions=NullableDependencyException.class) @SpecAssertion(section="4.2")
+ @Test(groups={"injection", "producerMethod"}, expectedExceptions=NullableDependencyException.class) @SpecAssertion(section="4.2")
public void testPrimitiveInjectionPointResolvesToNullableWebBean()
{
assert false;
}
- @Test(groups="injection", expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="4.3")
+ @Test(groups={"injection", "clientProxy"}, expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="4.3")
public void testInvokeNormalInjectedWebBeanWhenContextNotActive()
{
- assert false;
+
}
@Test(groups="injection") @SpecAssertion(section="4.3")
- public void testInovkeDependentScopeWhenContextNotActive()
+ public void testInvokeDependentScopeWhenContextNotActive()
{
- assert false;
+ Bean<FoxRun> foxRunBean = createSimpleWebBean(FoxRun.class, manager);
+ Bean<Fox> foxBean = createSimpleWebBean(Fox.class, manager);
+ manager.addBean(foxBean);
+ FoxRun foxRun = foxRunBean.create();
+ assert foxRun.fox.getName().equals("gavin");
}
- @Test(groups="injection") @SpecAssertion(section="3.6")
+ @Test(groups="injection", expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.6")
public void testInjectingStaticField()
{
- assert false;
+ SimpleBeanImpl<BeanWithStaticBoundField> bean = createSimpleWebBean(BeanWithStaticBoundField.class, manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ manager.addBean(tunaBean);
+ BeanWithStaticBoundField instance = bean.create();
}
- @Test(groups="injection") @SpecAssertion(section="3.6")
+ @Test(groups="injection",expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.6")
public void testInjectingFinalField()
{
- assert false;
+ SimpleBeanImpl<BeanWithFinalBoundField> bean = createSimpleWebBean(BeanWithFinalBoundField.class, manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ manager.addBean(tunaBean);
+ BeanWithFinalBoundField instance = bean.create();
}
@Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="3.6.2")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -12,7 +12,7 @@
public class ManagerTest extends AbstractTest
{
- @Test(groups={"manager", "injection"}) @SpecAssertion(section="4.8")
+ @Test(groups={"manager", "injection", "deployment"}) @SpecAssertion(section="4.8")
public void testInjectingManager()
{
assert false;
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FarmOffice.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FarmOffice.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FarmOffice.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+
+public class FarmOffice
+{
+
+ @Current
+ public int noOfStaff;
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FarmOffice.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java 2008-10-28 22:04:15 UTC (rev 201)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -6,4 +6,9 @@
public class Fox
{
+ public String getName()
+ {
+ return "gavin";
+ }
+
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithFinalBoundField.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithFinalBoundField.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithFinalBoundField.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.test.beans.broken;
+
+import javax.webbeans.Current;
+
+import org.jboss.webbeans.test.beans.Tuna;
+
+public class BeanWithFinalBoundField
+{
+
+ @Current
+ public final Tuna tuna = null;
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithFinalBoundField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithStaticBoundField.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithStaticBoundField.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithStaticBoundField.java 2008-10-28 23:07:14 UTC (rev 202)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.test.beans.broken;
+
+import javax.webbeans.Current;
+
+import org.jboss.webbeans.test.beans.Tuna;
+
+public class BeanWithStaticBoundField
+{
+
+ @Current
+ public static Tuna tuna;
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/BeanWithStaticBoundField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years
[webbeans-commits] Webbeans SVN: r201 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: util and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-10-28 18:04:15 -0400 (Tue, 28 Oct 2008)
New Revision: 201
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ClientProxy.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxy.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
Log:
Initial proxy support
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ClientProxy.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ClientProxy.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ClientProxy.java 2008-10-28 22:04:15 UTC (rev 201)
@@ -0,0 +1,26 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+import javax.webbeans.manager.Manager;
+
+public class ClientProxy<T>
+{
+ private Bean<T> bean;
+ private Manager manager;
+
+ public ClientProxy(Bean<T> bean, Manager manager)
+ {
+ this.bean = bean;
+ this.manager = manager;
+ }
+
+ public T getInstance()
+ {
+ Context context = manager.getContext(bean.getScopeType());
+ T instance = context.get(bean, true);
+ // wrap in proxy here
+ return instance;
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 20:27:32 UTC (rev 200)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 22:04:15 UTC (rev 201)
@@ -34,7 +34,7 @@
import org.jboss.webbeans.exceptions.TypesafeResolutionLocation;
import org.jboss.webbeans.injectable.Injectable;
import org.jboss.webbeans.injectable.ResolverInjectable;
-import org.jboss.webbeans.util.ClientProxy;
+import org.jboss.webbeans.util.ClientProxyUtil;
import org.jboss.webbeans.util.MapWrapper;
import org.jboss.webbeans.util.Reflections;
@@ -55,6 +55,22 @@
}
+ private class ProxyPool extends MapWrapper<Bean<?>, ClientProxy<?>>
+ {
+
+ public ProxyPool()
+ {
+ super(new HashMap<Bean<?>, ClientProxy<?>>());
+ }
+
+ public ClientProxy<?> get(Bean<?> key)
+ {
+ return (ClientProxy<?>) super.get(key);
+ }
+
+ }
+
+
private List<Class<? extends Annotation>> enabledDeploymentTypes;
private ModelManager modelManager;
private EjbManager ejbLookupManager;
@@ -62,6 +78,7 @@
private ResolutionManager resolutionManager;
private ContextMap contextMap;
private DependentContext dependentContext;
+ private ProxyPool proxyPool;
private Set<Bean<?>> beans;
@@ -74,6 +91,7 @@
this.beans = new HashSet<Bean<?>>();
this.eventBus = new EventBus();
this.resolutionManager = new ResolutionManager(this);
+ this.proxyPool = new ProxyPool();
}
protected void initEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
@@ -272,8 +290,7 @@
dependentContext.setActive(true);
if (getModelManager().getScopeModel(bean.getScopeType()).isNormal())
{
- // TODO return a client proxy
- return getContext(bean.getScopeType()).get(bean, true);
+ return (T) getClientProxy(bean).getInstance();
}
else
{
@@ -327,7 +344,7 @@
else
{
Bean<T> bean = beans.iterator().next();
- if (getModelManager().getScopeModel(bean.getScopeType()).isNormal() && !ClientProxy.isProxyable(injectable.getType()))
+ if (getModelManager().getScopeModel(bean.getScopeType()).isNormal() && !ClientProxyUtil.isProxyable(injectable.getType()))
{
throw new UnproxyableDependencyException(new TypesafeResolutionLocation(injectable) + "Unable to proxy");
}
@@ -367,5 +384,17 @@
// TODO Auto-generated method stub
return null;
}
+
+ private ClientProxy<?> getClientProxy(Bean<?> bean)
+ {
+ ClientProxy<?> clientProxy = proxyPool.get(bean);
+ if (clientProxy == null)
+ {
+ clientProxy = new ClientProxy(bean, this);
+ proxyPool.put(bean, clientProxy);
+ }
+ return clientProxy;
+ }
+
}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxy.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxy.java 2008-10-28 20:27:32 UTC (rev 200)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxy.java 2008-10-28 22:04:15 UTC (rev 201)
@@ -1,33 +0,0 @@
-package org.jboss.webbeans.util;
-
-
-public class ClientProxy
-{
-
- public static boolean isProxyable(Class<?> rawType)
- {
- // TODO Add logging
-
- if (Reflections.getConstructor(rawType) == null)
- {
- return false;
- }
- else if (Reflections.isTypeOrAnyMethodFinal(rawType))
- {
- return false;
- }
- else if (Reflections.isPrimitive(rawType))
- {
- return false;
- }
- else if (Reflections.isArrayType(rawType))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java (from rev 199, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxy.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java 2008-10-28 22:04:15 UTC (rev 201)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.util;
+
+
+public class ClientProxyUtil
+{
+
+ public static boolean isProxyable(Class<?> rawType)
+ {
+ // TODO Add logging
+
+ if (Reflections.getConstructor(rawType) == null)
+ {
+ return false;
+ }
+ else if (Reflections.isTypeOrAnyMethodFinal(rawType))
+ {
+ return false;
+ }
+ else if (Reflections.isPrimitive(rawType))
+ {
+ return false;
+ }
+ else if (Reflections.isArrayType(rawType))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ClientProxyUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
16 years
[webbeans-commits] Webbeans SVN: r200 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans and 8 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 16:27:32 -0400 (Tue, 28 Oct 2008)
New Revision: 200
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/SimpleBeanImpl.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FoxRun.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/TunaFarm.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injectable/InjectableField.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByNameTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByNameTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanLifecycleTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FishFarm.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Tuna.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/util/Util.java
ri/trunk/webbeans-ri/testng.xml
Log:
Start to fix injection tests
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanImpl.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BeanImpl.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -7,26 +7,33 @@
import org.jboss.webbeans.model.bean.BeanModel;
-public class BeanImpl<T> extends Bean<T>
+public abstract class BeanImpl<T> extends Bean<T>
{
public static final String LOGGER_NAME = "bean";
- private BeanModel<T, ?> beanModel;
-
- private ManagerImpl manager;
+ protected ManagerImpl manager;
- public BeanImpl(BeanModel<T, ?> model, ManagerImpl manager)
+ public BeanImpl(ManagerImpl manager)
{
super(manager);
- this.beanModel = model;
+ this.manager = manager;
}
-
- @Override
- public T create()
+
+ protected T getInstance()
{
- return beanModel.getConstructor().invoke(manager);
+ return getModel().getConstructor().invoke(manager);
}
+
+ protected void bindInterceptors()
+ {
+ // TODO
+ }
+
+ protected void bindDecorators()
+ {
+ // TODO
+ }
@Override
public void destroy(T instance)
@@ -38,37 +45,37 @@
@Override
public Set<Annotation> getBindingTypes()
{
- return beanModel.getBindingTypes();
+ return getModel().getBindingTypes();
}
@Override
public Class<? extends Annotation> getDeploymentType()
{
- return beanModel.getDeploymentType();
+ return getModel().getDeploymentType();
}
@Override
public String getName()
{
- return beanModel.getName();
+ return getModel().getName();
}
@Override
public Class<? extends Annotation> getScopeType()
{
- return beanModel.getScopeType();
+ return getModel().getScopeType();
}
@Override
public Set<Class<?>> getTypes()
{
- return beanModel.getApiTypes();
+ return getModel().getApiTypes();
}
@Override
public boolean isNullable()
{
- return !beanModel.isPrimitive();
+ return !getModel().isPrimitive();
}
@Override
@@ -81,12 +88,9 @@
@Override
public String toString()
{
- return beanModel.toString();
+ return getModel().toString();
}
- public BeanModel<T, ?> getModel()
- {
- return beanModel;
- }
+ public abstract BeanModel<T, ?> getModel();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -24,6 +24,10 @@
import javax.webbeans.manager.Interceptor;
import javax.webbeans.manager.Manager;
+import org.jboss.webbeans.contexts.ApplicationContext;
+import org.jboss.webbeans.contexts.DependentContext;
+import org.jboss.webbeans.contexts.RequestContext;
+import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.ejb.EjbManager;
import org.jboss.webbeans.event.EventBus;
import org.jboss.webbeans.exceptions.NameResolutionLocation;
@@ -57,14 +61,14 @@
private EventBus eventBus;
private ResolutionManager resolutionManager;
private ContextMap contextMap;
+ private DependentContext dependentContext;
private Set<Bean<?>> beans;
public ManagerImpl()
{
- contextMap = new ContextMap();
- // TODO Are there any contexts that should be initialized here?
initEnabledDeploymentTypes(null);
+ initContexts(null);
this.modelManager = new ModelManager();
this.ejbLookupManager = new EjbManager();
this.beans = new HashSet<Bean<?>>();
@@ -89,6 +93,27 @@
}
}
}
+
+ protected void initContexts(Context ... contexts)
+ {
+ this.contextMap = new ContextMap();
+ if (contexts == null)
+ {
+
+ this.dependentContext = new DependentContext();
+ addContext(dependentContext);
+ addContext(new RequestContext());
+ addContext(new SessionContext());
+ addContext(new ApplicationContext());
+ }
+ else
+ {
+ for (Context context : contexts)
+ {
+ addContext(context);
+ }
+ }
+ }
public Manager addBean(Bean<?> bean)
{
@@ -242,14 +267,22 @@
public <T> T getInstance(Bean<T> bean)
{
- if (getModelManager().getScopeModel(bean.getScopeType()).isNormal())
+ try
{
- // TODO return a client proxy
- return null;
+ dependentContext.setActive(true);
+ if (getModelManager().getScopeModel(bean.getScopeType()).isNormal())
+ {
+ // TODO return a client proxy
+ return getContext(bean.getScopeType()).get(bean, true);
+ }
+ else
+ {
+ return getContext(bean.getScopeType()).get(bean, true);
+ }
}
- else
+ finally
{
- return getContext(bean.getScopeType()).get(bean, true);
+ dependentContext.setActive(false);
}
}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/SimpleBeanImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/SimpleBeanImpl.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/SimpleBeanImpl.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -0,0 +1,47 @@
+package org.jboss.webbeans;
+
+import org.jboss.webbeans.injectable.InjectableField;
+import org.jboss.webbeans.model.bean.SimpleBeanModel;
+
+public class SimpleBeanImpl<T> extends BeanImpl<T>
+{
+
+ private SimpleBeanModel<T> model;
+
+ public SimpleBeanImpl(SimpleBeanModel<T> model, ManagerImpl manager)
+ {
+ super(manager);
+ this.model = model;
+ }
+
+ @Override
+ public T create()
+ {
+ T instance = getInstance();
+ bindDecorators();
+ bindInterceptors();
+ injectEjbAndCommonFields();
+ injectBoundFields(instance);
+ return instance;
+ }
+
+ protected void injectEjbAndCommonFields()
+ {
+ // TODO
+ }
+
+ protected void injectBoundFields(T instance)
+ {
+ for (InjectableField<?> injectableField : getModel().getInjectableFields())
+ {
+ injectableField.inject(instance, manager);
+ }
+ }
+
+ @Override
+ public SimpleBeanModel<T> getModel()
+ {
+ return model;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/SimpleBeanImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injectable/InjectableField.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injectable/InjectableField.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injectable/InjectableField.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -2,7 +2,10 @@
import java.lang.reflect.Field;
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.SimpleAnnotatedField;
+import org.jboss.webbeans.util.Reflections;
/**
* Abstraction of Java Reflection
@@ -17,5 +20,15 @@
{
super(new SimpleAnnotatedField<T>(field));
}
+
+ public InjectableField(AnnotatedField<T> annotatedField)
+ {
+ super(annotatedField);
+ }
+
+ public void inject(Object instance, ManagerImpl manager)
+ {
+ Reflections.setAndWrap(getAnnotatedItem().getDelegate(), instance, getValue(manager));
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -24,7 +24,7 @@
* Get all fields on the type
* @return
*/
- public Set<AnnotatedField<?>> getFields();
+ public Set<AnnotatedField<Object>> getFields();
/**
* Get all annotations which are annotated with the given annotation
@@ -33,7 +33,7 @@
* If no annotations are present which are annotated with the given
* annotation an empty set is returned
*/
- public Set<AnnotatedField<?>> getAnnotatedField(Class<? extends Annotation> annotationType);
+ public Set<AnnotatedField<Object>> getAnnotatedField(Class<? extends Annotation> annotationType);
/**
* Get all fields which are annotated with the given meta annotation
@@ -42,7 +42,7 @@
* If no annotations are present which are annotated with the given meta
* annotation an empty set is returned
*/
- public Set<AnnotatedField<?>> getMetaAnnotatedFields(
+ public Set<AnnotatedField<Object>> getMetaAnnotatedFields(
Class<? extends Annotation> metaAnnotationType);
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -21,9 +21,9 @@
private Class<T> clazz;
private Type[] actualTypeArguements;
- private Set<AnnotatedField<?>> fields;
- private Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> annotatedFields;
- private Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> metaAnnotatedFields;
+ private Set<AnnotatedField<Object>> fields;
+ private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> annotatedFields;
+ private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> metaAnnotatedFields;
public SimpleAnnotatedType(Class<T> annotatedClass, Map<Class<? extends Annotation>, Annotation> annotationMap)
{
@@ -55,7 +55,7 @@
return clazz;
}
- public Set<AnnotatedField<?>> getFields()
+ public Set<AnnotatedField<Object>> getFields()
{
if (fields == null)
{
@@ -66,19 +66,19 @@
private void initFields()
{
- this.fields = new HashSet<AnnotatedField<?>>();
+ this.fields = new HashSet<AnnotatedField<Object>>();
for(Field field : clazz.getFields())
{
fields.add(new SimpleAnnotatedField<Object>(field));
}
}
- public Set<AnnotatedField<?>> getMetaAnnotatedFields(
+ public Set<AnnotatedField<Object>> getMetaAnnotatedFields(
Class<? extends Annotation> metaAnnotationType)
{
if (metaAnnotatedFields == null)
{
- metaAnnotatedFields = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<?>>>();
+ metaAnnotatedFields = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>();
}
if (annotatedFields == null)
{
@@ -88,14 +88,14 @@
return metaAnnotatedFields.get(metaAnnotationType);
}
- protected static <T extends Annotation> Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> populateMetaAnnotatedFieldMap(
+ protected static <T extends Annotation> Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> populateMetaAnnotatedFieldMap(
Class<T> metaAnnotationType,
- Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> annotatedFields,
- Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> metaAnnotatedFields)
+ Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> annotatedFields,
+ Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> metaAnnotatedFields)
{
if (!metaAnnotatedFields.containsKey(metaAnnotationType))
{
- Set<AnnotatedField<?>> s = new HashSet<AnnotatedField<?>>();
+ Set<AnnotatedField<Object>> s = new HashSet<AnnotatedField<Object>>();
for (Class<? extends Annotation> annotationType: annotatedFields.keySet())
{
if (annotationType.isAnnotationPresent(metaAnnotationType))
@@ -108,7 +108,7 @@
return metaAnnotatedFields;
}
- public Set<AnnotatedField<?>> getAnnotatedField(
+ public Set<AnnotatedField<Object>> getAnnotatedField(
Class<? extends Annotation> annotationType)
{
if (annotatedFields == null)
@@ -124,14 +124,14 @@
{
initFields();
}
- annotatedFields = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<?>>>();
- for (AnnotatedField<?> field : fields)
+ annotatedFields = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>();
+ for (AnnotatedField<Object> field : fields)
{
for (Annotation annotation : field.getAnnotations())
{
if (!annotatedFields.containsKey(annotation))
{
- annotatedFields.put(annotation.annotationType(), new HashSet<AnnotatedField<?>>());
+ annotatedFields.put(annotation.annotationType(), new HashSet<AnnotatedField<Object>>());
}
annotatedFields.get(annotation.annotationType()).add(field);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,11 +1,15 @@
package org.jboss.webbeans.model.bean;
+import java.util.HashSet;
+import java.util.Set;
import java.util.logging.Logger;
import javax.webbeans.BindingType;
import javax.webbeans.DefinitionException;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.injectable.InjectableField;
+import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.LoggerUtil;
import org.jboss.webbeans.util.Reflections;
@@ -26,6 +30,7 @@
private AnnotatedType<T> annotatedItem;
private AnnotatedType<T> xmlAnnotatedItem;
+ private Set<InjectableField<?>> injectableFields;
/**
*
@@ -97,7 +102,13 @@
protected void initInjectionPoints()
{
super.initInjectionPoints();
- annotatedItem.getMetaAnnotatedFields(BindingType.class);
+ injectableFields = new HashSet<InjectableField<?>>();
+ for (AnnotatedField<Object> annotatedField : annotatedItem.getMetaAnnotatedFields(BindingType.class))
+ {
+ InjectableField<?> injectableField = new InjectableField<Object>(annotatedField);
+ injectableFields.add(injectableField);
+ super.injectionPoints.add(injectableField);
+ }
}
@Override
@@ -146,5 +157,10 @@
throw new DefinitionException("Web Bean implementation class " + type + " cannot be declared abstract");
}
}
+
+ public Set<InjectableField<?>> getInjectableFields()
+ {
+ return injectableFields;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -3,6 +3,7 @@
import java.beans.Introspector;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -244,16 +245,32 @@
}
catch (IllegalArgumentException e)
{
- throw new ExecutionException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e);
+ throw new ExecutionException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
}
catch (IllegalAccessException e)
{
- throw new ExecutionException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e);
+ throw new ExecutionException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
}
catch (InvocationTargetException e)
{
- throw new ExecutionException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e);
+ throw new ExecutionException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
}
}
+ public static void setAndWrap(Field field, Object target, Object value)
+ {
+ try
+ {
+ field.set(target, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ExecutionException("Error setting field " + field.getName() + " on " + field.getDeclaringClass(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ExecutionException("Error setting field " + field.getName() + " on " + field.getDeclaringClass(), e);
+ }
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -7,10 +7,6 @@
import javax.webbeans.Production;
import javax.webbeans.Standard;
-import org.jboss.webbeans.contexts.ApplicationContext;
-import org.jboss.webbeans.contexts.DependentContext;
-import org.jboss.webbeans.contexts.RequestContext;
-import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.model.StereotypeModel;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
@@ -39,7 +35,6 @@
protected void init()
{
addStereotypes();
- addBuiltInContexts();
addEnabledDeploymentTypes();
}
@@ -62,13 +57,5 @@
manager.getModelManager().addStereotype(new StereotypeModel<RiverFishStereotype>(RiverFishStereotype.class));
manager.getModelManager().addStereotype(new StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class));
}
-
- protected void addBuiltInContexts()
- {
- manager.addContext(new DependentContext());
- manager.addContext(new RequestContext());
- manager.addContext(new SessionContext());
- manager.addContext(new ApplicationContext());
- }
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/BindingTypeTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -11,7 +11,6 @@
import javax.webbeans.Current;
import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
-import org.jboss.webbeans.injectable.InjectableField;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
import org.jboss.webbeans.model.bean.BeanModel;
@@ -23,7 +22,6 @@
import org.jboss.webbeans.test.beans.Cod;
import org.jboss.webbeans.test.beans.Order;
import org.jboss.webbeans.test.beans.Tuna;
-import org.jboss.webbeans.test.beans.broken.PlaiceFarm;
import org.jboss.webbeans.test.bindings.AsynchronousAnnotationLiteral;
import org.jboss.webbeans.util.Reflections;
import org.testng.annotations.Test;
@@ -44,10 +42,7 @@
@Test(groups="injection") @SpecAssertion(section="2.3.1")
public void testDefaultBindingTypeAssumedAtInjectionPoint() throws Exception
{
- // This is like defining a field in XML
- InjectableField<Tuna> tunaField = new InjectableField<Tuna>(PlaiceFarm.class.getDeclaredField("tuna"));
- assert tunaField.getBindingTypes().size() == 1;
- assert tunaField.getBindingTypes().contains(new CurrentAnnotationLiteral());
+ assert false;
}
@Test(groups="annotationDefinition") @SpecAssertion(section="2.3.2")
@@ -127,37 +122,21 @@
assert model.getBindingTypes().contains(new CurrentAnnotationLiteral());
}
- @Test(groups="injection")
- public void testFieldsWithBindingAnnotationsAreInjected()
- {
- assert false;
- }
+
- @Test(groups="injection") @SpecAssertion(section="2.3.5")
- public void testAllBindTypesMustMatch()
- {
- assert false;
- }
-
- @Test(groups="injection")
- public void testFieldMissingBindingAnnotationsAreNotInjected()
- {
- assert false;
- }
-
- @Test(groups="injection") @SpecAssertion(section="2.3.5")
+ @Test(groups={"injection", "producerMethod"}) @SpecAssertion(section="2.3.5")
public void testFieldInjectedFromProducerMethod()
{
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="2.3.5")
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="2.3.5")
public void testFieldWithBindingTypeInXml()
{
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="2.3.5")
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="2.3.5")
public void testFieldWithBindingTypeInXmlIgnoresAnnotations()
{
assert false;
@@ -169,13 +148,13 @@
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="2.3.6")
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="2.3.6")
public void testMethodWithBindingAnnotationsOnParametersDeclaredInXml()
{
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="2.3.6")
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="2.3.6")
public void testMethodWithBindingAnnotationsOnParametersDeclaredInXmlIgnoresAnnotations()
{
assert false;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -8,7 +8,6 @@
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
-import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.contexts.AbstractContext;
import org.jboss.webbeans.contexts.RequestContext;
import org.jboss.webbeans.introspector.SimpleAnnotatedMethod;
@@ -73,8 +72,8 @@
manager.getModelManager().addBeanModel(producer);
Method nullProducer = SpiderProducer.class.getMethod("produceShelob");
ProducerMethodBeanModel<Tarantula> producerModel = new ProducerMethodBeanModel<Tarantula>(new SimpleAnnotatedMethod<Tarantula>(nullProducer), manager);
- Bean<Tarantula> shelobBean = new BeanImpl<Tarantula>(producerModel, manager);
- assert context.get(shelobBean, true) == null;
+ //Bean<Tarantula> shelobBean = new ProducerBeanImpl<Tarantula>(producerModel, manager);
+ //assert context.get(shelobBean, true) == null;
}
@Test(groups="contexts")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -8,6 +8,7 @@
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.test.beans.Fox;
+import org.jboss.webbeans.test.beans.FoxRun;
import org.testng.annotations.Test;
@SpecVersion("PDR")
@@ -17,7 +18,11 @@
@Test(groups={"contexts", "injection"}) @SpecAssertion(section="8.3")
public void testInstanceNotSharedBetweenInjectionPoints()
{
- assert false;
+ Bean<FoxRun> foxRunBean = createSimpleWebBean(FoxRun.class, manager);
+ Bean<Fox> foxBean = createSimpleWebBean(Fox.class, manager);
+ manager.addBean(foxBean);
+ FoxRun foxRun = foxRunBean.create();
+ assert !foxRun.fox.equals(foxRun.anotherFox);
}
@Test(groups={"contexts", "el"}) @SpecAssertion(section="8.3")
@@ -99,7 +104,11 @@
@Test(groups={"contexts", "injection"}) @SpecAssertion(section="8.3")
public void testContextIsActiveDuringInjection()
{
- assert false;
+ Bean<FoxRun> foxRunBean = createSimpleWebBean(FoxRun.class, manager);
+ Bean<Fox> foxBean = createSimpleWebBean(Fox.class, manager);
+ manager.addBean(foxBean);
+ FoxRun foxRun = foxRunBean.create();
+ assert foxRun.fox != null;
}
@Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.3")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,5 +1,6 @@
package org.jboss.webbeans.test;
+
import javax.webbeans.ContextNotActiveException;
import javax.webbeans.NonexistentFieldException;
import javax.webbeans.NullableDependencyException;
@@ -46,12 +47,6 @@
assert false;
}
- @Test(groups="injection") @SpecAssertion(section="3.6.1")
- public void testInjectFields()
- {
- assert false;
- }
-
@Test(groups="injection") @SpecAssertion(section="3.6")
public void testInjectingStaticField()
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByNameTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByNameTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByNameTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,15 +1,12 @@
package org.jboss.webbeans.test;
-import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
import javax.webbeans.AmbiguousDependencyException;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.ResolutionManager;
import org.jboss.webbeans.injectable.InjectableField;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.beans.Cod;
import org.jboss.webbeans.test.beans.FishFarm;
import org.jboss.webbeans.test.beans.Haddock;
@@ -28,8 +25,8 @@
public void testNoWebBeansFound() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
manager.addBean(codBean);
manager.addBean(salmonBean);
@@ -43,10 +40,10 @@
public void testAmbiguousDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> plaiceBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- manager.addBean(plaiceBean);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ manager.addBean(codBean);
manager.addBean(salmonBean);
manager.addBean(soleBean);
@@ -59,13 +56,13 @@
@Test(groups={"resolution", "beanLifecycle"}) @SpecAssertion(section="4.10.1")
public void testGetInstanceByName()
{
- Bean<Tuna> tunaBean = new BeanImpl<Tuna>(new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), getEmptyAnnotatedType(Tuna.class), super.manager), manager);
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- Bean<SeaBass> seaBassBean = new BeanImpl<SeaBass>(new SimpleBeanModel<SeaBass>(new SimpleAnnotatedType<SeaBass>(SeaBass.class), getEmptyAnnotatedType(SeaBass.class), super.manager), manager);
- Bean<Haddock> haddockBean = new BeanImpl<Haddock>(new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), super.manager), manager);
- Bean<Plaice> plaiceBean = new BeanImpl<Plaice>(new SimpleBeanModel<Plaice>(new SimpleAnnotatedType<Plaice>(Plaice.class), getEmptyAnnotatedType(Plaice.class), super.manager), manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ Bean<SeaBass> seaBassBean = createSimpleWebBean(SeaBass.class, manager);
+ Bean<Haddock> haddockBean = createSimpleWebBean(Haddock.class, manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
manager.addBean(tunaBean);
manager.addBean(codBean);
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,6 +1,6 @@
package org.jboss.webbeans.test;
-import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
import javax.webbeans.AmbiguousDependencyException;
import javax.webbeans.AnnotationLiteral;
@@ -9,12 +9,9 @@
import javax.webbeans.UnsatisfiedDependencyException;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.ResolutionManager;
import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
import org.jboss.webbeans.injectable.InjectableField;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.annotations.Whitefish;
import org.jboss.webbeans.test.beans.Cod;
import org.jboss.webbeans.test.beans.FishFarm;
@@ -53,10 +50,10 @@
public void testAmbiguousDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> plaiceBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- manager.addBean(plaiceBean);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ manager.addBean(codBean);
manager.addBean(salmonBean);
manager.addBean(soleBean);
@@ -71,10 +68,10 @@
public void testUnsatisfiedDependencies() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> plaiceBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- manager.addBean(plaiceBean);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ manager.addBean(codBean);
manager.addBean(salmonBean);
manager.addBean(soleBean);
@@ -89,7 +86,7 @@
public void testUnproxyableDependencies() throws Exception
{
InjectableField<Plaice> plaiceField = new InjectableField<Plaice>(PlaiceFarm.class.getDeclaredField("plaice"));
- Bean<Plaice> plaiceBean = new BeanImpl<Plaice>(new SimpleBeanModel<Plaice>(new SimpleAnnotatedType<Plaice>(Plaice.class), getEmptyAnnotatedType(Plaice.class), super.manager), manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
manager.addBean(plaiceBean);
ResolutionManager resolutionManager = manager.getResolutionManager();
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -12,12 +12,6 @@
public class ManagerTest extends AbstractTest
{
- @Override
- protected void addBuiltInContexts()
- {
- // No -op, done manually here
- }
-
@Test(groups={"manager", "injection"}) @SpecAssertion(section="4.8")
public void testInjectingManager()
{
@@ -29,7 +23,7 @@
{
Context requestContext = new RequestContext();
((NormalContext)requestContext).setActive(false);
- manager.addContext(requestContext);
+ manager.setContexts(requestContext);
manager.getContext(RequestScoped.class);
}
@@ -38,8 +32,7 @@
{
Context firstContext = new RequestContext();
Context secondContext = new RequestContext();
- manager.addContext(firstContext);
- manager.addContext(secondContext);
+ manager.setContexts(firstContext, secondContext);
manager.getContext(RequestScoped.class);
assert true;
}
@@ -47,6 +40,7 @@
@Test(expectedExceptions={ContextNotActiveException.class}, groups={"manager"}) @SpecAssertion(section="8.6")
public void testGetContextWithNoRegisteredContextsFails()
{
+ manager.setContexts();
manager.getContext(RequestScoped.class);
assert false;
}
@@ -55,7 +49,7 @@
public void testGetContextReturnsActiveContext()
{
Context requestContext = new RequestContext();
- manager.addContext(requestContext);
+ manager.setContexts(requestContext);
Context testContext = manager.getContext(RequestScoped.class);
assert testContext == requestContext;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByNameTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByNameTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByNameTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,20 +1,13 @@
package org.jboss.webbeans.test;
-import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.BeanImpl;
-import org.jboss.webbeans.ResolutionManager;
-import org.jboss.webbeans.injectable.InjectableField;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.beans.Cod;
-import org.jboss.webbeans.test.beans.FishFarm;
import org.jboss.webbeans.test.beans.Haddock;
import org.jboss.webbeans.test.beans.Plaice;
import org.jboss.webbeans.test.beans.Salmon;
-import org.jboss.webbeans.test.beans.ScottishFish;
import org.jboss.webbeans.test.beans.SeaBass;
import org.jboss.webbeans.test.beans.Sole;
import org.jboss.webbeans.test.beans.Tuna;
@@ -45,14 +38,15 @@
@Test @SpecAssertion(section="4.10.1")
public void testNamedBasedResolution()
{
- Bean<Tuna> tunaBean = new BeanImpl<Tuna>(new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), getEmptyAnnotatedType(Tuna.class), super.manager), manager);
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- Bean<SeaBass> seaBassBean = new BeanImpl<SeaBass>(new SimpleBeanModel<SeaBass>(new SimpleAnnotatedType<SeaBass>(SeaBass.class), getEmptyAnnotatedType(SeaBass.class), super.manager), manager);
- Bean<Haddock> haddockBean = new BeanImpl<Haddock>(new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), super.manager), manager);
- Bean<Plaice> plaiceBean = new BeanImpl<Plaice>(new SimpleBeanModel<Plaice>(new SimpleAnnotatedType<Plaice>(Plaice.class), getEmptyAnnotatedType(Plaice.class), super.manager), manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ Bean<SeaBass> seaBassBean = createSimpleWebBean(SeaBass.class, manager);
+ Bean<Haddock> haddockBean = createSimpleWebBean(Haddock.class, manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
+
manager.addBean(tunaBean);
manager.addBean(codBean);
manager.addBean(salmonBean);
@@ -76,15 +70,12 @@
@Test(groups="resolution") @SpecAssertion(section="4.10.1")
public void testNoWebBeansFound() throws Exception
{
- InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+
manager.addBean(codBean);
manager.addBean(salmonBean);
- ResolutionManager resolutionManager = manager.getResolutionManager();
- resolutionManager.addInjectionPoint(whiteScottishFishField);
-
assert manager.resolveByName("foo").size() == 0;
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,7 +1,6 @@
package org.jboss.webbeans.test;
import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
-import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
import java.util.HashSet;
import java.util.Set;
@@ -12,12 +11,9 @@
import javax.webbeans.TypeLiteral;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.ResolutionManager;
import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
import org.jboss.webbeans.injectable.InjectableField;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.annotations.Expensive;
import org.jboss.webbeans.test.annotations.Whitefish;
import org.jboss.webbeans.test.beans.Animal;
@@ -60,7 +56,7 @@
public void testSingleApiTypeWithCurrent() throws Exception
{
InjectableField<Tuna> tunaField = new InjectableField<Tuna>(FishFarm.class.getDeclaredField("tuna"));
- Bean<Tuna> tunaBean = new BeanImpl<Tuna>(new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), getEmptyAnnotatedType(Tuna.class), super.manager), manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
Set<Bean<?>> beans = new HashSet<Bean<?>>();
beans.add(tunaBean);
Set<Bean<?>> possibleTargets = tunaField.getMatchingBeans(beans, manager.getModelManager());
@@ -84,9 +80,10 @@
public void testOneBindingType() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+
Set<Bean<?>> beans = new HashSet<Bean<?>>();
beans.add(codBean);
beans.add(salmonBean);
@@ -101,9 +98,11 @@
public void testABindingType() throws Exception
{
InjectableField<Animal> whiteChunkyFishField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("realChunkyWhiteFish"));
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
+
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+
Set<Bean<?>> beans = new HashSet<Bean<?>>();
beans.add(codBean);
beans.add(salmonBean);
@@ -117,8 +116,8 @@
public void testMultipleApiTypeWithCurrent() throws Exception
{
InjectableField<Animal> animalField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("animal"));
- Bean<SeaBass> seaBassBean = new BeanImpl<SeaBass>(new SimpleBeanModel<SeaBass>(new SimpleAnnotatedType<SeaBass>(SeaBass.class), getEmptyAnnotatedType(SeaBass.class), super.manager), manager);
- Bean<Haddock> haddockBean = new BeanImpl<Haddock>(new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), super.manager), manager);
+ Bean<SeaBass> seaBassBean = createSimpleWebBean(SeaBass.class, manager);
+ Bean<Haddock> haddockBean = createSimpleWebBean(Haddock.class, manager);
Set<Bean<?>> beans = new HashSet<Bean<?>>();
beans.add(seaBassBean);
beans.add(haddockBean);
@@ -131,17 +130,13 @@
@Test(groups="resolution") @SpecAssertion(section={"4.9.2", "4.9.4"})
public void testResolveByType() throws Exception
{
- Bean<Tuna> tunaBean = new BeanImpl<Tuna>(new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), getEmptyAnnotatedType(Tuna.class), super.manager), manager);
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- Bean<SeaBass> seaBassBean = new BeanImpl<SeaBass>(new SimpleBeanModel<SeaBass>(new SimpleAnnotatedType<SeaBass>(SeaBass.class), getEmptyAnnotatedType(SeaBass.class), super.manager), manager);
- Bean<Haddock> haddockBean = new BeanImpl<Haddock>(new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), super.manager), manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<SeaBass> seaBassBean = createSimpleWebBean(SeaBass.class, manager);
+ Bean<Haddock> haddockBean = createSimpleWebBean(Haddock.class, manager);
manager.addBean(tunaBean);
- manager.addBean(codBean);
manager.addBean(salmonBean);
- manager.addBean(soleBean);
manager.addBean(haddockBean);
manager.addBean(seaBassBean);
@@ -155,7 +150,19 @@
assert manager.resolveByType(Animal.class, new CurrentAnnotationLiteral()).contains(salmonBean);
assert manager.resolveByType(Animal.class, new CurrentAnnotationLiteral()).contains(seaBassBean);
assert manager.resolveByType(Animal.class, new CurrentAnnotationLiteral()).contains(haddockBean);
+ }
+
+ @Test(groups="injection") @SpecAssertion(section="2.3.5")
+ public void testAllBindingTypesSpecifiedForResolutionMustAppearOnWebBean()
+ {
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ manager.addBean(codBean);
+ manager.addBean(salmonBean);
+ manager.addBean(soleBean);
+
assert manager.resolveByType(Animal.class, new ChunkyAnnotationLiteral() {
public boolean realChunky()
@@ -176,7 +183,6 @@
assert manager.resolveByType(ScottishFish.class, new AnnotationLiteral<Whitefish>() {}).size() == 2;
assert manager.resolveByType(ScottishFish.class, new AnnotationLiteral<Whitefish>() {}).contains(codBean);
assert manager.resolveByType(ScottishFish.class, new AnnotationLiteral<Whitefish>() {}).contains(soleBean);
-
}
@Test(groups="resolution") @SpecAssertion(section="4.9.2")
@@ -184,8 +190,8 @@
{
InjectableField<Farmer<ScottishFish>> scottishFishFarmerField = new InjectableField<Farmer<ScottishFish>>(FishFarm.class.getDeclaredField("scottishFishFarmer"));
- Bean<ScottishFishFarmer> scottishFishFarmerBean = new BeanImpl<ScottishFishFarmer>(new SimpleBeanModel<ScottishFishFarmer>(new SimpleAnnotatedType<ScottishFishFarmer>(ScottishFishFarmer.class), getEmptyAnnotatedType(ScottishFishFarmer.class), super.manager), manager);
- Bean<AnimalFarmer> farmerBean = new BeanImpl<AnimalFarmer>(new SimpleBeanModel<AnimalFarmer>(new SimpleAnnotatedType<AnimalFarmer>(AnimalFarmer.class), getEmptyAnnotatedType(AnimalFarmer.class), super.manager), manager);
+ Bean<ScottishFishFarmer> scottishFishFarmerBean = createSimpleWebBean(ScottishFishFarmer.class, manager);
+ Bean<AnimalFarmer> farmerBean = createSimpleWebBean(AnimalFarmer.class, manager);
manager.addBean(scottishFishFarmerBean);
manager.addBean(farmerBean);
@@ -208,12 +214,11 @@
public void testOnlyHighestEnabledPreecedenceWebBeansResolved() throws Exception
{
InjectableField<Animal> whiteFishField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("whiteFish"));
+ Bean<Cod> codBean = createSimpleWebBean(Cod.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
- Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
- Bean<Plaice> plaiceBean = new BeanImpl<Plaice>(new SimpleBeanModel<Plaice>(new SimpleAnnotatedType<Plaice>(Plaice.class), getEmptyAnnotatedType(Plaice.class), super.manager), manager);
-
manager.addBean(plaiceBean);
manager.addBean(codBean);
manager.addBean(soleBean);
@@ -233,7 +238,7 @@
InjectableField<Animal> veryExpensiveWhitefishField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("veryExpensiveWhitefish"));
Bean<Halibut> halibutBean = createSimpleWebBean(Halibut.class, manager);
Bean<RoundWhitefish> roundWhiteFishBean = createSimpleWebBean(RoundWhitefish.class, manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
manager.addBean(halibutBean);
manager.addBean(roundWhiteFishBean);
manager.addBean(soleBean);
@@ -265,9 +270,9 @@
public void testNoWebBeansFound() throws Exception
{
InjectableField<ScottishFish> whiteScottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- Bean<Cod> plaiceBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
manager.addBean(plaiceBean);
manager.addBean(salmonBean);
manager.addBean(soleBean);
@@ -282,9 +287,9 @@
@Test(groups="resolution") @SpecAssertion(section="4.9.2")
public void testResolveObject() throws Exception
{
- Bean<Cod> plaiceBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
- Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
- Bean<Sole> soleBean = new BeanImpl<Sole>(new SimpleBeanModel<Sole>(new SimpleAnnotatedType<Sole>(Sole.class), getEmptyAnnotatedType(Sole.class), super.manager), manager);
+ Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
+ Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
+ Bean<Plaice> plaiceBean = createSimpleWebBean(Plaice.class, manager);
manager.addBean(plaiceBean);
manager.addBean(salmonBean);
manager.addBean(soleBean);
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanLifecycleTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanLifecycleTest.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanLifecycleTest.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,8 +1,17 @@
package org.jboss.webbeans.test;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
+
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.SimpleBeanImpl;
+import org.jboss.webbeans.test.beans.RedSnapper;
+import org.jboss.webbeans.test.beans.Tuna;
+import org.jboss.webbeans.test.beans.TunaFarm;
import org.testng.annotations.Test;
-public class SimpleBeanLifecycleTest
+@SpecVersion("PDR")
+public class SimpleBeanLifecycleTest extends AbstractTest
{
@Test(groups="beanLifecycle") @SpecAssertion(section="3.1.3")
@@ -19,4 +28,61 @@
assert false;
}
+ @Test(groups="beanLifecycle") @SpecAssertion(section="5.3")
+ public void testCreateReturnsInstanceOfBean()
+ {
+ Bean<RedSnapper> bean = createSimpleWebBean(RedSnapper.class, manager);
+ assert bean.create() instanceof RedSnapper;
+ }
+
+ @Test(groups={"beanLifecycle", "interceptors"}) @SpecAssertion(section="5.3")
+ public void testCreateBindsInterceptorStack()
+ {
+ assert false;
+ }
+
+ @Test(groups={"beanLifecycle", "decorators"}) @SpecAssertion(section="5.3")
+ public void testCreateBindsDecoratorStack()
+ {
+ assert false;
+ }
+
+ @Test(groups={"beanLifecycle", "ejb3"}) @SpecAssertion(section="5.3")
+ public void testCreateInjectsEjb()
+ {
+ assert false;
+ }
+
+ @Test(groups={"beanLifecycle", "ejb3"}) @SpecAssertion(section="5.3")
+ public void testCreateInjectsPersistenceContext()
+ {
+ assert false;
+ }
+
+ @Test(groups={"beanLifecycle", "commonAnnotations"}) @SpecAssertion(section="5.3")
+ public void testCreateInjectsResource()
+ {
+ assert false;
+ }
+
+ @Test(groups="injection") @SpecAssertion(section="5.3")
+ public void testCreateInjectsFieldsDeclaredInJava()
+ {
+ SimpleBeanImpl<TunaFarm> tunaFarmBean = createSimpleWebBean(TunaFarm.class, manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ manager.addBean(tunaBean);
+ TunaFarm tunaFarm = tunaFarmBean.create();
+ assert tunaFarm.tuna != null;
+ }
+
+ @Test(groups="injection")
+ public void testFieldMissingBindingAnnotationsAreNotInjected()
+ {
+ SimpleBeanImpl<TunaFarm> tunaFarmBean = createSimpleWebBean(TunaFarm.class, manager);
+ Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
+ manager.addBean(tunaBean);
+ TunaFarm tunaFarm = tunaFarmBean.create();
+ assert tunaFarm.notInjectedTuna != manager.getInstance(tunaBean);
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FishFarm.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FishFarm.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FishFarm.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -13,29 +13,29 @@
@SuppressWarnings("unused")
@Current
- private Tuna tuna;
+ public Tuna tuna;
@SuppressWarnings("unused")
@Current
- private Animal animal;
+ public Animal animal;
@SuppressWarnings("unused")
@Whitefish
- private ScottishFish whiteScottishFish;
+ public ScottishFish whiteScottishFish;
@SuppressWarnings("unused")
@Whitefish
- private Animal whiteFish;
+ public Animal whiteFish;
@SuppressWarnings("unused")
@Whitefish @Chunky(realChunky=true)
- private Animal realChunkyWhiteFish;
+ public Animal realChunkyWhiteFish;
@SuppressWarnings("unused")
@Current
- private Farmer<ScottishFish> scottishFishFarmer;
+ public Farmer<ScottishFish> scottishFishFarmer;
@Expensive(cost=60, veryExpensive=true) @Whitefish
- private Animal veryExpensiveWhitefish;
+ public Animal veryExpensiveWhitefish;
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FoxRun.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FoxRun.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FoxRun.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+
+public class FoxRun
+{
+
+ @Current
+ public Fox fox;
+
+ @Current
+ public Fox anotherFox;
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FoxRun.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Tuna.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Tuna.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Tuna.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -1,8 +1,11 @@
package org.jboss.webbeans.test.beans;
+import javax.webbeans.RequestScoped;
+
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
@AnotherDeploymentType
+@RequestScoped
public class Tuna
{
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/TunaFarm.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/TunaFarm.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/TunaFarm.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.Production;
+
+@Production
+public class TunaFarm
+{
+
+ @SuppressWarnings("unused")
+ @Current
+ public Tuna tuna;
+
+ public Tuna notInjectedTuna = new Tuna();
+
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/TunaFarm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -8,6 +8,7 @@
import javax.webbeans.Observer;
import javax.webbeans.TypeLiteral;
+import javax.webbeans.manager.Context;
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
@@ -97,5 +98,10 @@
{
initEnabledDeploymentTypes(enabledDeploymentTypes);
}
+
+ public void setContexts(Context ... contexts)
+ {
+ initContexts(contexts);
+ }
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/util/Util.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/util/Util.java 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/util/Util.java 2008-10-28 20:27:32 UTC (rev 200)
@@ -3,8 +3,8 @@
import java.lang.annotation.Annotation;
import java.util.HashMap;
-import org.jboss.webbeans.BeanImpl;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.SimpleBeanImpl;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
import org.jboss.webbeans.model.bean.SimpleBeanModel;
@@ -12,9 +12,9 @@
public class Util
{
- public static <T> BeanImpl<T> createSimpleWebBean(Class<T> clazz, ManagerImpl manager)
+ public static <T> SimpleBeanImpl<T> createSimpleWebBean(Class<T> clazz, ManagerImpl manager)
{
- return new BeanImpl<T>(createSimpleModel(clazz, manager), manager);
+ return new SimpleBeanImpl<T>(createSimpleModel(clazz, manager), manager);
}
public static <T> SimpleBeanModel<T> createSimpleModel(Class<T> clazz, ManagerImpl manager)
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-28 17:25:28 UTC (rev 199)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-28 20:27:32 UTC (rev 200)
@@ -12,7 +12,6 @@
<exclude name="producerMethod" />
<exclude name="observerMethod" />
<exclude name="deferredEvent" />
- <exclude name="injection" />
<exclude name="ejb3" />
<exclude name="webservice" />
<exclude name="annotationDefinition" />
@@ -20,6 +19,7 @@
<exclude name="el" />
<exclude name="jms" />
<exclude name="interceptors" />
+ <exclude name="decorators" />
<exclude name="innerClass" />
<exclude name="servlet" />
<exclude name="clientProxy" />
16 years
[webbeans-commits] Webbeans SVN: r199 - in ri/trunk/webbeans-ri/src: test/java/org/jboss/webbeans/test and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 13:25:28 -0400 (Tue, 28 Oct 2008)
New Revision: 199
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ResolutionManager.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
Log:
Actually allow dyanmic lookups :-)
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ResolutionManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ResolutionManager.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ResolutionManager.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -48,6 +48,7 @@
public ResolutionManager(ManagerImpl manager)
{
this.injectionPoints = new HashSet<Injectable<?,?>>();
+ this.resolvedInjectionPoints = new InjectableMap();
this.manager = manager;
}
@@ -63,19 +64,15 @@
public void clear()
{
- resolvedInjectionPoints = null;
+ resolvedInjectionPoints = new InjectableMap();
resolvedNames = new HashMap<String, Set<Bean<?>>>();
}
- public void resolveBeans()
+ public void resolveInjectionPoints()
{
- if (resolvedInjectionPoints == null)
+ for (Injectable<?, ?> injectable : injectionPoints)
{
- resolvedInjectionPoints = new InjectableMap();
- for (Injectable<?, ?> injectable : injectionPoints)
- {
- registerInjectionPoint(injectable);
- }
+ registerInjectionPoint(injectable);
}
}
@@ -83,13 +80,14 @@
{
if (key.getType().equals(Object.class))
{
+ // TODO Fix this cast
return (Set<Bean<T>>) (Set) manager.getBeans();
}
- else
+ if (!resolvedInjectionPoints.containsKey(key))
{
- resolveBeans();
- return resolvedInjectionPoints.get(key);
+ registerInjectionPoint(key);
}
+ return resolvedInjectionPoints.get(key);
}
public Set<Bean<?>> get(String name)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -2,6 +2,7 @@
import org.testng.annotations.Test;
+@SpecVersion("PDR")
public class ApplicationContextTest extends AbstractTest
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -28,7 +28,7 @@
}
@Test(groups="clientProxy", expectedExceptions=UnproxyableDependencyException.class) @SpecAssertion(section="4.4.1")
- public void testInjectionPointWithUnproxyableTypeResolvesToNormalScopedWebBean()
+ public void testInjectionPointWithUnproxyableTypeWhichResolvesToNormalScopedWebBean()
{
assert false;
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionTests.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -1,6 +1,7 @@
package org.jboss.webbeans.test;
import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.NonexistentFieldException;
import javax.webbeans.NullableDependencyException;
import org.testng.annotations.Test;
@@ -45,6 +46,54 @@
assert false;
}
+ @Test(groups="injection") @SpecAssertion(section="3.6.1")
+ public void testInjectFields()
+ {
+ assert false;
+ }
+
+ @Test(groups="injection") @SpecAssertion(section="3.6")
+ public void testInjectingStaticField()
+ {
+ assert false;
+ }
+
+ @Test(groups="injection") @SpecAssertion(section="3.6")
+ public void testInjectingFinalField()
+ {
+ assert false;
+ }
+
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="3.6.2")
+ public void testInjectFieldsDeclaredInXml()
+ {
+ assert false;
+ }
+
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="3.6.2")
+ public void testInjectedFieldDeclaredInXmlIgnoresJavaAnnotations()
+ {
+ assert false;
+ }
+
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="3.6.2")
+ public void testInjectedFieldDeclaredInXmlAssumesCurrent()
+ {
+ assert false;
+ }
+
+ @Test(groups={"injection", "webbeansxml"}, expectedExceptions=NonexistentFieldException.class) @SpecAssertion(section="3.6.2")
+ public void testNonexistentFieldDefinedInXml()
+ {
+ assert false;
+ }
+
+ @Test(groups={"injection", "webbeansxml"}) @SpecAssertion(section="3.6.2")
+ public void testInjectFieldsDeclaredInXmlAndJava()
+ {
+ assert false;
+ }
+
/*
@Test(groups="injection") @SpecAssertion(section="4.2")
@@ -53,5 +102,6 @@
assert false;
}
- */
+ */
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InstantiationByTypeTest.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -62,6 +62,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(whiteScottishFishField);
+ resolutionManager.resolveInjectionPoints();
manager.getInstanceByType(ScottishFish.class, new AnnotationLiteral<Whitefish>(){});
}
@@ -79,6 +80,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(whiteScottishFishField);
+ resolutionManager.resolveInjectionPoints();
manager.getInstanceByType(Tuna.class, new CurrentAnnotationLiteral());
}
@@ -92,6 +94,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(plaiceField);
+ resolutionManager.resolveInjectionPoints();
manager.getInstanceByType(Plaice.class, new AnnotationLiteral<Whitefish>(){});
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -2,6 +2,7 @@
import org.testng.annotations.Test;
+@SpecVersion("PDR")
public class RequestContextTest extends AbstractTest
{
@@ -24,7 +25,7 @@
}
@Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
- public void testScopeActiveDuringEjbTimeoust()
+ public void testScopeActiveDuringEjbTimeoutsInEE6()
{
assert false;
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-10-28 15:39:14 UTC (rev 198)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-10-28 17:25:28 UTC (rev 199)
@@ -131,11 +131,6 @@
@Test(groups="resolution") @SpecAssertion(section={"4.9.2", "4.9.4"})
public void testResolveByType() throws Exception
{
- InjectableField<Animal> realChunkyWhiteFishField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("realChunkyWhiteFish"));
- InjectableField<Animal> animalField = new InjectableField<Animal>(FishFarm.class.getDeclaredField("animal"));
- InjectableField<ScottishFish> scottishFishField = new InjectableField<ScottishFish>(FishFarm.class.getDeclaredField("whiteScottishFish"));
- InjectableField<Tuna> tunaField = new InjectableField<Tuna>(FishFarm.class.getDeclaredField("tuna"));
-
Bean<Tuna> tunaBean = new BeanImpl<Tuna>(new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), getEmptyAnnotatedType(Tuna.class), super.manager), manager);
Bean<Cod> codBean = new BeanImpl<Cod>(new SimpleBeanModel<Cod>(new SimpleAnnotatedType<Cod>(Cod.class), getEmptyAnnotatedType(Cod.class), super.manager), manager);
Bean<Salmon> salmonBean = new BeanImpl<Salmon>(new SimpleBeanModel<Salmon>(new SimpleAnnotatedType<Salmon>(Salmon.class), getEmptyAnnotatedType(Salmon.class), super.manager), manager);
@@ -150,12 +145,6 @@
manager.addBean(haddockBean);
manager.addBean(seaBassBean);
- ResolutionManager resolutionManager = manager.getResolutionManager();
- resolutionManager.addInjectionPoint(realChunkyWhiteFishField);
- resolutionManager.addInjectionPoint(animalField);
- resolutionManager.addInjectionPoint(scottishFishField);
- resolutionManager.addInjectionPoint(tunaField);
-
assert manager.resolveByType(Tuna.class, new CurrentAnnotationLiteral()).size() == 1;
assert manager.resolveByType(Tuna.class, new CurrentAnnotationLiteral()).contains(tunaBean);
@@ -203,6 +192,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(scottishFishFarmerField);
+ resolutionManager.resolveInjectionPoints();
assert manager.resolveByType(new TypeLiteral<Farmer<ScottishFish>>(){}).size() == 1;
assert manager.resolveByType(new TypeLiteral<Farmer<ScottishFish>>(){}).contains(scottishFishFarmerBean);
@@ -230,6 +220,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(whiteFishField);
+ resolutionManager.resolveInjectionPoints();
assert manager.resolveByType(Animal.class, new AnnotationLiteral<Whitefish>() {}).size() == 1;
assert manager.resolveByType(Animal.class, new AnnotationLiteral<Whitefish>() {}).contains(plaiceBean);
@@ -249,6 +240,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(veryExpensiveWhitefishField);
+ resolutionManager.resolveInjectionPoints();
Set<Bean<Animal>> beans = manager.resolveByType(Animal.class, new ExpensiveAnnotationLiteral()
{
@@ -282,6 +274,7 @@
ResolutionManager resolutionManager = manager.getResolutionManager();
resolutionManager.addInjectionPoint(whiteScottishFishField);
+ resolutionManager.resolveInjectionPoints();
assert manager.resolveByType(Tuna.class, new CurrentAnnotationLiteral()).size() == 0;
}
16 years
[webbeans-commits] Webbeans SVN: r198 - ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 11:39:14 -0400 (Tue, 28 Oct 2008)
New Revision: 198
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java
Log:
Stubs for request context tests
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java 2008-10-28 15:39:14 UTC (rev 198)
@@ -0,0 +1,78 @@
+package org.jboss.webbeans.test;
+
+import org.testng.annotations.Test;
+
+public class RequestContextTest extends AbstractTest
+{
+
+ @Test(groups={"servlet", "contexts"}) @SpecAssertion(section="8.5.1")
+ public void testScopeActiveDuringServiceMethod()
+ {
+ assert false;
+ }
+
+ @Test(groups={"webservice", "contexts"}) @SpecAssertion(section="8.5.1")
+ public void testScopeActiveDuringWebServiceInvocation()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeActiveDuringRemoteInvocationOfEjbs()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeActiveDuringEjbTimeoust()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeActiveDuringMessageDelivery()
+ {
+ assert false;
+ }
+
+ @Test(groups={"servlet", "contexts"}) @SpecAssertion(section="8.5.1")
+ public void testScopeNotSharedAcrossRequests()
+ {
+ assert false;
+ }
+
+ @Test(groups={"webservice", "contexts"}) @SpecAssertion(section="8.5.1")
+ public void testScopeNotSharedAcrossWebServiceInvocations()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeNotSharedAcrossRemoteInvocationsOfEjbs()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeNotSharedAcrossEjbTimeouts()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.1")
+ public void testScopeNotSharedAcrossMessageDelivery()
+ {
+ assert false;
+ }
+
+ /*
+
+ @Test @SpecAssertion(section="8.5.3")
+ public void test
+ {
+ assert false;
+ }
+
+ */
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/RequestContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years
[webbeans-commits] Webbeans SVN: r197 - in ri/trunk/webbeans-ri: src/test/java/org/jboss/webbeans/test and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 11:35:59 -0400 (Tue, 28 Oct 2008)
New Revision: 197
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
ri/trunk/webbeans-ri/testng.xml
Log:
Stubs for application context tests
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java 2008-10-28 15:35:59 UTC (rev 197)
@@ -0,0 +1,78 @@
+package org.jboss.webbeans.test;
+
+import org.testng.annotations.Test;
+
+public class ApplicationContextTest extends AbstractTest
+{
+
+ @Test(groups={"servlet", "contexts"}) @SpecAssertion(section="8.5.3")
+ public void testScopeActiveDuringServiceMethod()
+ {
+ assert false;
+ }
+
+ @Test(groups={"webservice", "contexts"}) @SpecAssertion(section="8.5.3")
+ public void testScopeActiveDuringWebServiceInvocation()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeActiveDuringRemoteInvocationOfEjbs()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeActiveDuringEjbTimeoust()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeActiveDuringMessageDelivery()
+ {
+ assert false;
+ }
+
+ @Test(groups={"servlet", "contexts"}) @SpecAssertion(section="8.5.3")
+ public void testScopeSharedAcrossRequests()
+ {
+ assert false;
+ }
+
+ @Test(groups={"webservice", "contexts"}) @SpecAssertion(section="8.5.3")
+ public void testScopeSharedAcrossWebServiceInvocations()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeSharedAcrossRemoteInvocationsOfEjbs()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeSharedAcrossEjbTimeouts()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.5.3")
+ public void testScopeSharedAcrossMessageDelivery()
+ {
+ assert false;
+ }
+
+ /*
+
+ @Test @SpecAssertion(section="8.5.3")
+ public void test
+ {
+ assert false;
+ }
+
+ */
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApplicationContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-28 12:54:18 UTC (rev 196)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-28 15:35:59 UTC (rev 197)
@@ -5,7 +5,6 @@
import java.lang.reflect.Method;
import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
@@ -16,7 +15,6 @@
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
import org.jboss.webbeans.model.bean.ProducerMethodBeanModel;
import org.jboss.webbeans.model.bean.SimpleBeanModel;
-import org.jboss.webbeans.test.beans.BlackWidow;
import org.jboss.webbeans.test.beans.SpiderProducer;
import org.jboss.webbeans.test.beans.Tarantula;
import org.jboss.webbeans.test.beans.Tuna;
@@ -32,7 +30,7 @@
* This class tests a basic context against section 8 of the specification
*
*/
-@SpecVersion("20081020")
+@SpecVersion("PDR")
public class CommonContextTest extends AbstractTest
{
Context context;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 12:54:18 UTC (rev 196)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 15:35:59 UTC (rev 197)
@@ -10,6 +10,7 @@
import org.jboss.webbeans.test.beans.Fox;
import org.testng.annotations.Test;
+@SpecVersion("PDR")
public class DependentContextTest extends AbstractTest
{
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-28 12:54:18 UTC (rev 196)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-28 15:35:59 UTC (rev 197)
@@ -14,6 +14,7 @@
<exclude name="deferredEvent" />
<exclude name="injection" />
<exclude name="ejb3" />
+ <exclude name="webservice" />
<exclude name="annotationDefinition" />
<exclude name="webbeansxml" />
<exclude name="el" />
16 years
[webbeans-commits] Webbeans SVN: r196 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 08:54:18 -0400 (Tue, 28 Oct 2008)
New Revision: 196
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeferredEventNotificationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
ri/trunk/webbeans-ri/testng.xml
Log:
Tests for dependent context
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -60,11 +60,11 @@
private Set<Bean<?>> beans;
- public ManagerImpl(List<Class<? extends Annotation>> enabledDeploymentTypes)
+ public ManagerImpl()
{
contextMap = new ContextMap();
// TODO Are there any contexts that should be initialized here?
- initEnabledDeploymentTypes(enabledDeploymentTypes);
+ initEnabledDeploymentTypes(null);
this.modelManager = new ModelManager();
this.ejbLookupManager = new EjbManager();
this.beans = new HashSet<Bean<?>>();
@@ -72,7 +72,7 @@
this.resolutionManager = new ResolutionManager(this);
}
- private void initEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
+ protected void initEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
{
this.enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
if (enabledDeploymentTypes == null)
@@ -170,7 +170,6 @@
contextMap.put(context.getScopeType(), sameScopeTypeContexts);
}
sameScopeTypeContexts.add(context);
- // TODO: why manager? fluent interfaces?
return this;
}
@@ -218,7 +217,7 @@
List<Context> contexts = contextMap.get(scopeType);
if (contexts == null)
{
- throw new ContextNotActiveException("No contexts for " + scopeType.getName());
+ throw new ContextNotActiveException("No active contexts for " + scopeType.getName());
}
// TODO performance? Just flag found=true and continue loop, failing when
// found=already true etc?
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -62,7 +62,7 @@
{
destroy(manager, bean);
}
- beans = null;
+ beans = new BeanMap();
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -7,7 +7,10 @@
import javax.webbeans.Production;
import javax.webbeans.Standard;
-import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.contexts.ApplicationContext;
+import org.jboss.webbeans.contexts.DependentContext;
+import org.jboss.webbeans.contexts.RequestContext;
+import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.model.StereotypeModel;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
@@ -23,31 +26,49 @@
public class AbstractTest
{
- protected ManagerImpl manager;
+ protected MockManagerImpl manager;
@BeforeMethod
- public void before()
+ public final void before()
{
-
+ manager = new MockManagerImpl();
+ init();
+ }
+
+ protected void init()
+ {
+ addStereotypes();
+ addBuiltInContexts();
+ addEnabledDeploymentTypes();
+ }
+
+ protected void addEnabledDeploymentTypes()
+ {
List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(Production.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
enabledDeploymentTypes.add(HornedAnimalDeploymentType.class);
- manager = new MockManagerImpl(enabledDeploymentTypes);
-
- initStereotypes(manager);
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
- private void initStereotypes(ManagerImpl container)
+ protected void addStereotypes()
{
- container.getModelManager().addStereotype(new StereotypeModel<AnimalStereotype>(AnimalStereotype.class));
- container.getModelManager().addStereotype(new StereotypeModel<HornedMammalStereotype>(HornedMammalStereotype.class));
- container.getModelManager().addStereotype(new StereotypeModel<MammalStereotype>(MammalStereotype.class));
- container.getModelManager().addStereotype(new StereotypeModel<FishStereotype>(FishStereotype.class));
- container.getModelManager().addStereotype(new StereotypeModel<RiverFishStereotype>(RiverFishStereotype.class));
- container.getModelManager().addStereotype(new StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<AnimalStereotype>(AnimalStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<HornedMammalStereotype>(HornedMammalStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<MammalStereotype>(MammalStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<FishStereotype>(FishStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<RiverFishStereotype>(RiverFishStereotype.class));
+ manager.getModelManager().addStereotype(new StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class));
}
+
+ protected void addBuiltInContexts()
+ {
+ manager.addContext(new DependentContext());
+ manager.addContext(new RequestContext());
+ manager.addContext(new SessionContext());
+ manager.addContext(new ApplicationContext());
+ }
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeferredEventNotificationTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeferredEventNotificationTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeferredEventNotificationTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -10,7 +10,6 @@
import javax.webbeans.Observes;
import javax.webbeans.Standard;
-import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.event.DeferredEventNotification;
import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -20,7 +19,6 @@
import org.jboss.webbeans.test.annotations.Asynchronous;
import org.jboss.webbeans.test.beans.Tuna;
import org.jboss.webbeans.test.bindings.AsynchronousAnnotationLiteral;
-import org.jboss.webbeans.test.mock.MockManagerImpl;
import org.jboss.webbeans.test.mock.MockObserverImpl;
import org.testng.annotations.Test;
@@ -38,6 +36,15 @@
{
// Simple class used for testing
}
+
+ @Override
+ protected void addEnabledDeploymentTypes()
+ {
+ List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
+ enabledDeploymentTypes.add(Standard.class);
+ enabledDeploymentTypes.add(AnotherDeploymentType.class);
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
+ }
public class AnObserver
{
@@ -61,13 +68,9 @@
// When the transaction is committed, the beforeCompletion() method is
// invoked which in turn invokes the observer. Here the mock observer
// is used to keep track of the event being fired.
- ManagerImpl manager;
SimpleBeanModel<Tuna> tuna;
InjectableMethod<Object> om;
- List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
- enabledDeploymentTypes.add(Standard.class);
- enabledDeploymentTypes.add(AnotherDeploymentType.class);
- manager = new MockManagerImpl(enabledDeploymentTypes);
+
// Create an observer with known binding types
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -1,11 +1,19 @@
package org.jboss.webbeans.test;
+import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.Dependent;
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.contexts.DependentContext;
+import org.jboss.webbeans.test.beans.Fox;
import org.testng.annotations.Test;
public class DependentContextTest extends AbstractTest
{
- @Test(groups="contexts") @SpecAssertion(section="8.3")
+ @Test(groups={"contexts", "injection"}) @SpecAssertion(section="8.3")
public void testInstanceNotSharedBetweenInjectionPoints()
{
assert false;
@@ -32,19 +40,28 @@
@Test(groups="contexts") @SpecAssertion(section="8.3")
public void testContextGetWithCreateTrueReturnsNewInstance()
{
- assert false;
+ Bean<Fox> foxBean = createSimpleWebBean(Fox.class, manager);
+ manager.addBean(foxBean);
+ DependentContext context = new DependentContext();
+ context.setActive(true);
+ assert context.get(foxBean, true) != null;
+ assert context.get(foxBean, true) instanceof Fox;
}
@Test(groups="contexts") @SpecAssertion(section="8.3")
public void testContextGetWithCreateFalseReturnsNull()
{
- assert false;
+ Bean<Fox> foxBean = createSimpleWebBean(Fox.class, manager);
+ manager.addBean(foxBean);
+ DependentContext context = new DependentContext();
+ context.setActive(true);
+ assert context.get(foxBean, false) == null;
}
- @Test(groups="contexts") @SpecAssertion(section="8.3")
+ @Test(groups="contexts", expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="8.3")
public void testContextIsInactive()
{
- assert false;
+ manager.getContext(Dependent.class).isActive();
}
@Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
@@ -108,7 +125,7 @@
assert false;
}
- @Test(groups={"contexts"}) @SpecAssertion(section="8.3")
+ @Test(groups={"contexts", "beanLifecycle"}) @SpecAssertion(section="8.3")
public void testDestroyingParentDestroysDependents()
{
assert false;
@@ -126,7 +143,7 @@
assert false;
}
- @Test(groups={"contexts"}) @SpecAssertion(section="8.3")
+ @Test(groups={"contexts", "el"}) @SpecAssertion(section="8.3")
public void testDependentsDestroyedWhenElEvaluationCompletes()
{
assert false;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -16,7 +16,6 @@
import javax.webbeans.Standard;
import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
import org.jboss.webbeans.model.bean.SimpleBeanModel;
@@ -32,7 +31,6 @@
import org.jboss.webbeans.test.beans.broken.Gazelle;
import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeAnnotationLiteral;
import org.jboss.webbeans.test.bindings.FishStereotypeAnnotationLiteral;
-import org.jboss.webbeans.test.mock.MockManagerImpl;
import org.testng.annotations.Test;
@SpecVersion("PDR")
@@ -124,10 +122,10 @@
@Test @SpecAssertion(section={"2.5.6", "2.5.7"})
public void testDefaultEnabledDeploymentTypes()
{
- ManagerImpl container = new MockManagerImpl(null);
- assert container.getEnabledDeploymentTypes().size() == 2;
- assert container.getEnabledDeploymentTypes().get(0).equals(Standard.class);
- assert container.getEnabledDeploymentTypes().get(1).equals(Production.class);
+ manager.setEnabledDeploymentTypes(null);
+ assert manager.getEnabledDeploymentTypes().size() == 2;
+ assert manager.getEnabledDeploymentTypes().get(0).equals(Standard.class);
+ assert manager.getEnabledDeploymentTypes().get(1).equals(Production.class);
}
@Test @SpecAssertion(section={"2.5.6", "2.5.7"})
@@ -137,11 +135,11 @@
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
enabledDeploymentTypes.add(HornedAnimalDeploymentType.class);
- ManagerImpl container = new MockManagerImpl(enabledDeploymentTypes);
- assert container.getEnabledDeploymentTypes().size() == 3;
- assert container.getEnabledDeploymentTypes().get(0).equals(Standard.class);
- assert container.getEnabledDeploymentTypes().get(1).equals(AnotherDeploymentType.class);
- assert container.getEnabledDeploymentTypes().get(2).equals(HornedAnimalDeploymentType.class);
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
+ assert manager.getEnabledDeploymentTypes().size() == 3;
+ assert manager.getEnabledDeploymentTypes().get(0).equals(Standard.class);
+ assert manager.getEnabledDeploymentTypes().get(1).equals(AnotherDeploymentType.class);
+ assert manager.getEnabledDeploymentTypes().get(2).equals(HornedAnimalDeploymentType.class);
}
@Test(expectedExceptions=DeploymentException.class) @SpecAssertion(section="2.5.6")
@@ -150,7 +148,7 @@
List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
enabledDeploymentTypes.add(AnotherDeploymentType.class);
enabledDeploymentTypes.add(HornedAnimalDeploymentType.class);
- new MockManagerImpl(enabledDeploymentTypes);
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
@Test(groups="webbeansxml", expectedExceptions=DeploymentException.class) @SpecAssertion(section="2.5.6")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBeanModelTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBeanModelTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -39,7 +39,8 @@
List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
- manager = new MockManagerImpl(enabledDeploymentTypes);
+ manager = new MockManagerImpl();
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
Field eventModelField = this.getClass().getDeclaredField("eventModelField");
eventBeanModel = new EventBeanModel<EventImpl<DangerCall>>(
new SimpleAnnotatedField<EventImpl<DangerCall>>(eventModelField),
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -54,7 +54,8 @@
List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
- manager = new MockManagerImpl(enabledDeploymentTypes);
+ manager = new MockManagerImpl();
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
/**
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -12,6 +12,12 @@
public class ManagerTest extends AbstractTest
{
+ @Override
+ protected void addBuiltInContexts()
+ {
+ // No -op, done manually here
+ }
+
@Test(groups={"manager", "injection"}) @SpecAssertion(section="4.8")
public void testInjectingManager()
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -10,7 +10,6 @@
import javax.webbeans.Observes;
import javax.webbeans.Standard;
-import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
@@ -33,7 +32,7 @@
@SpecVersion("20081024-PDR")
public class ObserverTest
{
- private ManagerImpl manager;
+ private MockManagerImpl manager;
private SimpleBeanModel<Tuna> tuna;
private InjectableMethod<?> om;
@@ -59,7 +58,8 @@
List<Class<? extends Annotation>> enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
- manager = new MockManagerImpl(enabledDeploymentTypes);
+ manager = new MockManagerImpl();
+ manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
// Create an observer with known binding types
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Dependent;
+
+@Dependent
+public class Fox
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Fox.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-10-28 12:54:18 UTC (rev 196)
@@ -19,11 +19,6 @@
private Annotation[] eventBindings = null;
private Observer<?> observer = null;
- public MockManagerImpl(List<Class<? extends Annotation>> enabledDeploymentTypes)
- {
- super(enabledDeploymentTypes);
- }
-
/* (non-Javadoc)
* @see org.jboss.webbeans.ManagerImpl#fireEvent(java.lang.Object, java.lang.annotation.Annotation[])
*/
@@ -97,5 +92,10 @@
{
return observer;
}
+
+ public void setEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
+ {
+ initEnabledDeploymentTypes(enabledDeploymentTypes);
+ }
}
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-28 12:25:44 UTC (rev 195)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-28 12:54:18 UTC (rev 196)
@@ -22,7 +22,6 @@
<exclude name="innerClass" />
<exclude name="servlet" />
<exclude name="clientProxy" />
- <exclude name="contexts" />
</run>
</groups>
<packages>
16 years
[webbeans-commits] Webbeans SVN: r195 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-28 08:25:44 -0400 (Tue, 28 Oct 2008)
New Revision: 195
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
Log:
move map into NormalContext
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-10-28 11:59:58 UTC (rev 194)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-10-28 12:25:44 UTC (rev 195)
@@ -36,14 +36,13 @@
}
- protected BeanMap beans;
private Class<? extends Annotation> scopeType;
protected boolean active;
public AbstractContext(Class<? extends Annotation> scopeType)
{
this.scopeType = scopeType;
- beans = new BeanMap();
+
}
public abstract <T> T get(Bean<T> bean, boolean create);
@@ -53,20 +52,8 @@
return scopeType;
}
- private <T> void destroy(Manager manager, Bean<T> bean)
- {
- bean.destroy(beans.get(bean));
- }
+ public abstract void destroy(Manager manager);
- public void destroy(Manager manager)
- {
- for (Bean<? extends Object> bean : beans.keySet())
- {
- destroy(manager, bean);
- }
- beans = null;
- }
-
public boolean isActive()
{
return active;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-28 11:59:58 UTC (rev 194)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-28 12:25:44 UTC (rev 195)
@@ -1,15 +1,14 @@
package org.jboss.webbeans.contexts;
-import java.lang.annotation.Annotation;
-
import javax.webbeans.ContextNotActiveException;
import javax.webbeans.Dependent;
import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
public class DependentContext extends AbstractContext
{
- public DependentContext(Class<? extends Annotation> scopeType)
+ public DependentContext()
{
super(Dependent.class);
active = false;
@@ -31,4 +30,11 @@
{
return "Dependent context";
}
+
+ @Override
+ public void destroy(Manager manager)
+ {
+
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-28 11:59:58 UTC (rev 194)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-28 12:25:44 UTC (rev 195)
@@ -4,13 +4,17 @@
import javax.webbeans.ContextNotActiveException;
import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Manager;
public abstract class NormalContext extends AbstractContext
{
+ private BeanMap beans;
+
public NormalContext(Class<? extends Annotation> scopeType)
{
super(scopeType);
+ beans = new BeanMap();
active = true;
}
@@ -45,6 +49,20 @@
beans.put(bean, instance);
return instance;
- }
+ }
+
+ private <T> void destroy(Manager manager, Bean<T> bean)
+ {
+ bean.destroy(beans.get(bean));
+ }
+ public void destroy(Manager manager)
+ {
+ for (Bean<? extends Object> bean : beans.keySet())
+ {
+ destroy(manager, bean);
+ }
+ beans = null;
+ }
+
}
16 years
[webbeans-commits] Webbeans SVN: r194 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-10-28 07:59:58 -0400 (Tue, 28 Oct 2008)
New Revision: 194
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/PseudoContext.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
Log:
Removed the PseudoContext
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-28 11:02:00 UTC (rev 193)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-28 11:59:58 UTC (rev 194)
@@ -6,7 +6,7 @@
import javax.webbeans.Dependent;
import javax.webbeans.manager.Bean;
-public class DependentContext extends PseudoContext
+public class DependentContext extends AbstractContext
{
public DependentContext(Class<? extends Annotation> scopeType)
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/PseudoContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/PseudoContext.java 2008-10-28 11:02:00 UTC (rev 193)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/PseudoContext.java 2008-10-28 11:59:58 UTC (rev 194)
@@ -1,13 +0,0 @@
-package org.jboss.webbeans.contexts;
-
-import java.lang.annotation.Annotation;
-
-public abstract class PseudoContext extends AbstractContext
-{
-
- public PseudoContext(Class<? extends Annotation> scopeType)
- {
- super(scopeType);
- }
-
-}
16 years