[webbeans-commits] Webbeans SVN: r173 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: contexts and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-10-27 06:00:39 -0400 (Mon, 27 Oct 2008)
New Revision: 173
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.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
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
Log:
Context hierarchy to new package
Stub for EL resolver
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java 2008-10-27 09:59:35 UTC (rev 172)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-
-import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Context;
-import javax.webbeans.manager.Manager;
-
-import org.jboss.webbeans.util.MapWrapper;
-
-/**
- * Basic implementation of javax.webbeans.Context, backed by a HashMap
- *
- * @author Shane Bryzak
- * @author Nicklas Karlsson (nickarls(a)gmail.com)
- * @author Pete Muir
- *
- */
-public abstract class AbstractContext implements Context
-{
-
- private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
- {
-
- public BeanMap()
- {
- super(new HashMap<Bean<? extends Object>, Object>());
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Object> T get(Bean<? extends T> key)
- {
- return (T) super.get(key);
- }
-
- }
-
- private BeanMap beans;
- private Class<? extends Annotation> scopeType;
- private boolean active;
-
- public AbstractContext(Class<? extends Annotation> scopeType)
- {
- this.scopeType = scopeType;
- beans = new BeanMap();
- active = true;
- }
-
- public <T> T get(Bean<T> bean, boolean create)
- {
- if (!active)
- {
- throw new ContextNotActiveException();
- }
-
- if (beans == null)
- {
- // Context has been destroyed
- return null;
- }
-
- T instance = beans.get(bean);
-
- if (instance != null)
- {
- return instance;
- }
-
- if (!create)
- {
- return null;
- }
-
- // TODO should bean creation be synchronized?
-
- instance = bean.create();
-
- beans.put(bean, instance);
- return instance;
- }
-
- public Class<? extends Annotation> getScopeType()
- {
- return scopeType;
- }
-
- 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;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive(boolean active)
- {
- this.active = active;
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java (from rev 171, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+import javax.webbeans.manager.Manager;
+
+import org.jboss.webbeans.util.MapWrapper;
+
+/**
+ * Basic implementation of javax.webbeans.Context, backed by a HashMap
+ *
+ * @author Shane Bryzak
+ * @author Nicklas Karlsson (nickarls(a)gmail.com)
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractContext implements Context
+{
+
+ private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
+ {
+
+ public BeanMap()
+ {
+ super(new HashMap<Bean<? extends Object>, Object>());
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Object> T get(Bean<? extends T> key)
+ {
+ return (T) super.get(key);
+ }
+
+ }
+
+ private BeanMap beans;
+ private Class<? extends Annotation> scopeType;
+ private boolean active;
+
+ public AbstractContext(Class<? extends Annotation> scopeType)
+ {
+ this.scopeType = scopeType;
+ beans = new BeanMap();
+ active = true;
+ }
+
+ public <T> T get(Bean<T> bean, boolean create)
+ {
+ if (!active)
+ {
+ throw new ContextNotActiveException();
+ }
+
+ if (beans == null)
+ {
+ // Context has been destroyed
+ return null;
+ }
+
+ T instance = beans.get(bean);
+
+ if (instance != null)
+ {
+ return instance;
+ }
+
+ if (!create)
+ {
+ return null;
+ }
+
+ // TODO should bean creation be synchronized?
+
+ instance = bean.create();
+
+ beans.put(bean, instance);
+ return instance;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return scopeType;
+ }
+
+ 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;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.ApplicationScoped;
+
+public class ApplicationContext extends NormalContext {
+
+ public ApplicationContext()
+ {
+ super(ApplicationScoped.class);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ConversationContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.ConversationScoped;
+
+
+public class ConversationContext extends NormalContext {
+
+ public ConversationContext()
+ {
+ super(ConversationScoped.class);
+ }
+
+}
Added: 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 (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+
+public class DependentContext extends AbstractContext
+{
+
+ public DependentContext(Class<? extends Annotation> scopeType)
+ {
+ super(scopeType);
+ }
+
+}
Added: 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 (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/NormalContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+
+public class NormalContext extends AbstractContext
+{
+
+ public NormalContext(Class<? extends Annotation> scopeType)
+ {
+ super(scopeType);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/RequestContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.RequestScoped;
+
+public class RequestContext extends NormalContext {
+
+ public RequestContext()
+ {
+ super(RequestScoped.class);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.contexts;
+
+import javax.webbeans.SessionScoped;
+
+public class SessionContext extends NormalContext {
+
+ public SessionContext()
+ {
+ super(SessionScoped.class);
+ }
+
+}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -0,0 +1,53 @@
+package org.jboss.webbeans.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+public class WebBeansELResolver extends ELResolver
+{
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ // TODO Auto-generated method stub
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-27 09:59:35 UTC (rev 172)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-27 10:00:39 UTC (rev 173)
@@ -8,11 +8,12 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Manager;
-import org.jboss.webbeans.AbstractContext;
+import org.jboss.webbeans.contexts.AbstractContext;
+import org.jboss.webbeans.contexts.RequestContext;
+
/**
*
* @author Shane Bryzak
@@ -30,7 +31,7 @@
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
- AbstractContext requestContext = new AbstractContext(RequestScoped.class) {};
+ AbstractContext requestContext = new RequestContext();
try
{
16 years, 1 month
[webbeans-commits] Webbeans SVN: r172 - in ri/trunk/webbeans-ri/src: test/java/org/jboss/webbeans/test and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2008-10-27 05:59:35 -0400 (Mon, 27 Oct 2008)
New Revision: 172
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/annotations/Role.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/bindings/RoleBinding.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventBus.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.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/ObserverTest.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/mock/MockObserverImpl.java
Log:
Added new data structures for observers and observer resolution.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventBus.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventBus.java 2008-10-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventBus.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -1,8 +1,7 @@
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -20,106 +19,114 @@
* The event bus is where observers are registered and events are fired.
*
* @author David Allen
- *
+ *
*/
public class EventBus
{
- private final Map<Integer, Set<Observer<?>>> registeredObservers;
- private final TransactionManager tm;
- private String tmName = "java:/TransactionManager";
-
+ private final Map<Class<?>, ArrayList<EventObserver<?>>> registeredObservers;
+ private final TransactionManager tm;
+ private String tmName = "java:/TransactionManager";
+
/**
- * Initializes a new instance of the EventBus. This includes looking up the
+ * Initializes a new instance of the EventBus. This includes looking up the
* transaction manager which is needed to defer events till the end of a
- * transaction.
- * TODO Should be able to configure JNDI name of transaction manager
+ * transaction. TODO Should be able to configure JNDI name of transaction
+ * manager
*
*/
public EventBus()
{
- registeredObservers = new HashMap<Integer, Set<Observer<?>>>();
+ registeredObservers = new HashMap<Class<?>, ArrayList<EventObserver<?>>>();
tm = JNDI.lookup(tmName, TransactionManager.class);
}
/**
- * Adds an observer to the event bus so that it receives event notifications. The
- * event information is already encapsulated as part of the observer.
- * @param o The observer that should receive events
+ * Adds an observer to the event bus so that it receives event notifications.
+ * The event information is already encapsulated as part of the observer.
+ *
+ * @param o
+ * The observer that should receive events
*/
- public void addObserver(Observer<?> o)
+ public <T> void addObserver(Observer<T> o, Class<T> eventType,
+ Annotation... bindings)
{
- int key = 1 /*TODO generateKey(o.getEventType(), o.get)*/;
- Set<Observer<?>> l = registeredObservers.get(key);
+ ArrayList<EventObserver<?>> l = registeredObservers.get(eventType);
if (l == null)
- l = new HashSet<Observer<?>>();
- l.add(o);
- registeredObservers.put(key, l);
+ {
+ l = new ArrayList<EventObserver<?>>();
+ registeredObservers.put(eventType, l);
+ }
+ EventObserver<T> eventObserver = new EventObserver<T>(o, eventType, bindings);
+ if (!l.contains(eventObserver))
+ l.add(eventObserver);
}
/**
- * Defers delivery of an event till the end of the currently active transaction.
+ * Defers delivery of an event till the end of the currently active
+ * transaction.
*
- * @param container The WebBeans container
- * @param event The event object to deliver
- * @param o The observer to receive the event
+ * @param container
+ * The WebBeans container
+ * @param event
+ * The event object to deliver
+ * @param o
+ * The observer to receive the event
* @throws SystemException
* @throws IllegalStateException
* @throws RollbackException
*/
- public void deferEvent(Object event, Observer<Object> o) throws SystemException, IllegalStateException, RollbackException
+ public void deferEvent(Object event, Observer<Object> o)
+ throws SystemException, IllegalStateException, RollbackException
{
- if (tm != null) {
+ if (tm != null)
+ {
// Get the current transaction associated with the thread
Transaction t = tm.getTransaction();
if (t != null)
- t.registerSynchronization(new DeferredEventNotification<Object>(event, o));
+ t.registerSynchronization(new DeferredEventNotification<Object>(
+ event, o));
}
}
/**
* Resolves the list of observers to be notified for a given event and
* optional event bindings.
- * @param event The event object
- * @param bindings Optional event bindings
+ *
+ * @param event
+ * The event object
+ * @param bindings
+ * Optional event bindings
* @return A set of Observers
*/
+ @SuppressWarnings("unchecked")
public <T> Set<Observer<T>> getObservers(T event, Annotation... bindings)
{
Set<Observer<T>> results = new HashSet<Observer<T>>();
- for (Observer<?> observer : registeredObservers.get(generateKey(event.getClass(), Arrays.asList(bindings))))
+ for (EventObserver<?> observer : registeredObservers.get(event.getClass()))
{
- results.add((Observer<T>) observer);
+ // TODO Verify bindings match before adding
+ results.add((Observer<T>) observer.getObserver());
}
return results;
}
/**
* Removes an observer from the event bus.
- * @param o The observer to remove
+ *
+ * @param observer
+ * The observer to remove
*/
- public void removeObserver(Observer<?> o)
+ public <T> void removeObserver(Observer<T> observer, Class<T> eventType)
{
- // TODO fix
- // Set<Observer<?>> l = registeredObservers.get(generateKey(o.getEventType(), o.getEventBindingTypes()));
- //if (l != null) {
- // l.remove(o);
- //}
+ ArrayList<EventObserver<?>> observers = registeredObservers.get(eventType);
+ for (int i = 0; i < observers.size(); i++)
+ {
+ EventObserver<?> eventObserver = observers.get(i);
+ if (eventObserver.getObserver().equals(observer))
+ {
+ observers.remove(i);
+ break;
+ }
+ }
}
-
- /**
- * Creates a key that can be used in a map for an observer that is notified of
- * events of a specific type with optional event bindings.
- * @param eventType The class of the event being observed
- * @param eventBindings An optional set of event bindings
- * @return
- */
- public int generateKey(Class<?> eventType, Collection<Annotation> eventBindings)
- {
- // Produce the sum of the hash codes for the event type and the set of
- // event bindings.
- int key = eventType.hashCode();
- if (eventBindings != null)
- key += eventBindings.hashCode();
- return key;
- }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-10-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -1,6 +1,9 @@
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -11,6 +14,7 @@
import javax.webbeans.DuplicateBindingTypeException;
import javax.webbeans.Event;
import javax.webbeans.Observer;
+import javax.webbeans.TypeLiteral;
import javax.webbeans.manager.Manager;
/**
@@ -24,21 +28,26 @@
public class EventImpl<T> implements Event<T>
{
private Collection<? extends Annotation> eventBindings;
+ private Class<T> eventType;
// The current WB manager
@Current
protected Manager webBeansManager;
/**
- * Used to set the event bindings for this type of event after it is constructed
- * with the default constructor.
- * @param eventBindings Annotations that are bindings for the event
+ * Used to set the event bindings for this type of event after it is
+ * constructed with the default constructor.
+ *
+ * @param eventBindings
+ * Annotations that are bindings for the event
*/
public void setEventBindings(Annotation... eventBindings)
{
- this.eventBindings = Arrays.asList(eventBindings);
+ Set<Annotation> newEventBindings = new HashSet<Annotation>();
+ addAnnotationBindings(newEventBindings, eventBindings);
+ this.eventBindings = newEventBindings;
}
-
+
/*
* (non-Javadoc)
*
@@ -60,10 +69,31 @@
.fireEvent(event, eventBindings.toArray(new Annotation[0]));
}
- public void observe(Observer<T> observe, Annotation... bindings)
+ public void observe(Observer<T> observer, Annotation... bindings)
{
- // TODO Auto-generated method stub
-
+ // Register the observer with the web beans manager
+ Class<T> eventArgumentClazz = null;
+ try
+ {
+ // TODO Fix me: Reflection can only get type variables, not the arguments used elsewhere
+ Field eventTypeField = this.getClass().getDeclaredField("eventType");
+ ParameterizedType genericType = (ParameterizedType) eventTypeField.getGenericType();
+ Type[] eventTypeArguments = genericType.getActualTypeArguments();
+ eventArgumentClazz = (Class<T>) eventTypeArguments[0];
+ } catch (SecurityException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchFieldException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Set<Annotation> eventBindings = new HashSet<Annotation>();
+ eventBindings.addAll(this.getBindingTypes());
+ addAnnotationBindings(eventBindings, bindings);
+ webBeansManager.addObserver(observer, eventArgumentClazz, bindings);
}
/**
@@ -72,9 +102,13 @@
* thrown.
*
* @param bindingsSet
+ * The set of annotation binding objects
* @param bindings
+ * An array of annotation bindings to add to the set
* @throws DuplicateBindingTypeException
* if any of bindings are duplicates
+ * @throws IllegalArgumentException
+ * if any annotation is not a binding type
*/
private void addAnnotationBindings(Set<Annotation> bindingsSet,
Annotation[] bindings)
@@ -82,6 +116,15 @@
if (bindings != null)
{
Set<Class<? extends Annotation>> bindingTypes = new HashSet<Class<? extends Annotation>>();
+ // Add the bindings types that are already in the set being added to. This will
+ // provide detection of duplicates across construction and later invocations.
+ for (Annotation annotation : bindingsSet)
+ {
+ bindingTypes.add(annotation.annotationType());
+ }
+
+ // Now go through the new annotations being added to make sure these are binding
+ // types and are not duplicates
for (Annotation annotation : bindings)
{
// Check that the binding type is indeed a binding type
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -0,0 +1,134 @@
+package org.jboss.webbeans.event;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.webbeans.Observer;
+
+/**
+ * <p>
+ * EventObserver wraps various {@link Observer} objects created by application
+ * code or by the Web Beans Manager for annotated observer methods. In all
+ * cases, this wrapper provides consistent object identification and hashing
+ * based on the type of event being observed and any event binding types
+ * specified.
+ *
+ * @author David Allen
+ *
+ */
+public class EventObserver<T>
+{
+ private final Class<T> eventType;
+ private final Annotation[] eventBindings;
+ private final Observer<T> observer;
+
+ /**
+ * Constructs a new wrapper for an observer.
+ *
+ * @param observer
+ * The observer
+ * @param eventType
+ * The class of event being observed
+ * @param eventBindings
+ * The array of annotation event bindings, if any
+ */
+ public EventObserver(final Observer<T> observer, final Class<T> eventType,
+ final Annotation... eventBindings)
+ {
+ this.observer = observer;
+ this.eventType = eventType;
+ this.eventBindings = eventBindings;
+ }
+
+ /**
+ * @return the eventType
+ */
+ public final Class<T> getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @return the eventBindings
+ */
+ public final Annotation[] getEventBindings()
+ {
+ return eventBindings;
+ }
+
+ /**
+ * @return the observer
+ */
+ public final Observer<T> getObserver()
+ {
+ return observer;
+ }
+
+ /**
+ * Query method to determine if this observer should be notified of an event
+ * based on the event bindings and any member values thereof.
+ *
+ * @param bindings The event bindings
+ * @return true only if all required bindings match
+ */
+ public boolean isObserverInterested(Annotation... bindings)
+ {
+ boolean result = true;
+ // Check each binding specified by this observer against those provided
+ if (this.eventBindings != null)
+ {
+ if ((bindings != null) && (bindings.length > 0))
+ {
+ List<Annotation> bindingsArray = Arrays.asList(bindings);
+ for (Annotation annotation : this.eventBindings)
+ {
+ int eventBindingIndex = bindingsArray.indexOf(annotation);
+ if (eventBindingIndex >= 0)
+ {
+ result = annotationsMatch(annotation, bindingsArray.get(eventBindingIndex));
+ } else
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Compares two annotation bindings for equivalence. This means that all member values, if any,
+ * must match.
+ * @param annotation The first annotation to compare
+ * @param annotation2 The second annotation to compare
+ * @return
+ */
+ private boolean annotationsMatch(Annotation annotation,
+ Annotation annotation2)
+ {
+ boolean result = true;
+ if (annotation.getClass().getDeclaredMethods().length > 0)
+ {
+ for (Method annotationValue : annotation.getClass().getDeclaredMethods())
+ {
+ try
+ {
+ if (!annotationValue.invoke(annotation).equals(annotationValue.invoke(annotation2)))
+ {
+ result = false;
+ break;
+ }
+ } catch (Exception e)
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-10-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -2,9 +2,8 @@
import java.lang.annotation.Annotation;
+import javax.webbeans.Current;
import javax.webbeans.Observer;
-import javax.webbeans.manager.Manager;
-
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.injectable.InjectableParameter;
@@ -14,17 +13,11 @@
/**
* <p>
* Reference implementation for the Observer interface, which represents an
- * observer method. Each observer method has an event type, the class of the
- * event object being observed, and event binding types, annotations applied to
+ * observer method. Each observer method has an event type which is the class of the
+ * event object being observed, and event binding types that are annotations applied to
* the event parameter to narrow the event notifications delivered.
* </p>
*
- * <p>
- * The hash code for each observer method includes all the information
- * contained. The data structure used to lookup observers must account for an
- * arbitrary number of observers of the same event.
- * </p>
- *
* @author David Allen
*
*/
@@ -36,14 +29,30 @@
private final Class<T> eventType;
/**
- * Creates an Observer which describes and encapsulates an observer method (7.3).
+ * Injected before notify is called. This can only work with the RI since
+ * InjectableMethod requires this specific implementation.
+ * TODO Determine if the impl can be injected here.
+ */
+ @Current
+ protected ManagerImpl manager;
+
+ /**
+ * Creates an Observer which describes and encapsulates an observer method
+ * (7.5).
*
+ * @param componentModel
+ * The model for the component which defines the observer method
+ * @param observer
+ * The observer method to notify
+ * @param eventType
+ * The type of event being observed
* @param beanModel The model for the bean which defines the
* observer method
* @param observer The observer method to notify
* @param eventType The type of event being observed
*/
- public ObserverImpl(BeanModel<?, ?> beanModel, InjectableMethod<?> observer, Class<T> eventType)
+ public ObserverImpl(final BeanModel<?, ?> beanModel,
+ final InjectableMethod<?> observer, final Class<T> eventType)
{
this.beanModel = beanModel;
this.observerMethod = observer;
@@ -68,18 +77,20 @@
*/
public void notify(final T event)
{
- // Get the most specialized instance of the bean
- Object instance = null /*getInstance(manager)*/;
+ // Get the most specialized instance of the component
+ Object instance = getInstance();
if (instance != null)
{
// Let the super class get the parameter values, but substitute the event
// object so that we know for certain it is the correct one.
for (int i = 0; i < observerMethod.getParameters().size(); i++)
{
- InjectableParameter<? extends Object> parameter = observerMethod.getParameters().get(i);
+ InjectableParameter<? extends Object> parameter = observerMethod
+ .getParameters().get(i);
if (parameter.getType().isAssignableFrom(event.getClass()))
{
- InjectableParameter<?> newParameter = new InjectableParameterWrapper<Object>(parameter)
+ InjectableParameter<?> newParameter = new InjectableParameterWrapper<Object>(
+ parameter)
{
@Override
public Object getValue(ManagerImpl manager)
@@ -90,21 +101,21 @@
observerMethod.getParameters().set(i, newParameter);
}
}
- // this.observerMethod.invoke(manager, instance);
+ this.observerMethod.invoke(manager, instance);
}
-
+
}
/**
* Uses the container to retrieve the most specialized instance of this
* observer.
*
- * @param container The WebBeans manager
* @return the most specialized instance
*/
- protected Object getInstance(Manager manager)
+ protected Object getInstance()
{
- // Return the most specialized instance of the bean
- return manager.getInstanceByType(beanModel.getType(), beanModel.getBindingTypes().toArray(new Annotation[0]));
+ // Return the most specialized instance of the component
+ return manager.getInstanceByType(beanModel.getType(), beanModel
+ .getBindingTypes().toArray(new Annotation[0]));
}
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test;
+
+/**
+ * Tests for the EventBus implementation used by the Web Beans RI.
+ *
+ * @author David Allen
+ *
+ */
+public class EventBusTest extends AbstractTest
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -0,0 +1,52 @@
+package org.jboss.webbeans.test;
+
+import javax.webbeans.Observer;
+
+import org.jboss.webbeans.event.EventObserver;
+import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
+import org.jboss.webbeans.test.bindings.RoleBinding;
+import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
+import org.jboss.webbeans.test.beans.DangerCall;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for the wrapper class {@link EventObserverTest} which implements some of
+ * the observer resolution behavior specified in 7.7.1 and 7.7.2 of the Web Beans
+ * Specification.
+ *
+ * @author David Allen
+ *
+ */
+@SpecVersion("20081024-PDR")
+public class EventObserverTest
+{
+ public class AnObserver<T> implements Observer<T>
+ {
+ public void notify(T event)
+ {
+ }
+ }
+
+
+ /**
+ * Tests different annotation literals as event bindings to make sure the wrapper
+ * properly detects when an observer matches the given event bindings.
+ */
+ @Test(groups = "eventbus")
+ @SpecAssertion(section = "7.7.1")
+ public void testIsObserverInterested()
+ {
+ Observer<DangerCall> observer = new AnObserver<DangerCall>();
+ EventObserver<DangerCall> wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new TameAnnotationLiteral());
+ assert wrappedObserver.getEventBindings().length == 1;
+ assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral());
+ assert !wrappedObserver.isObserverInterested(new AnimalStereotypeAnnotationLiteral());
+ assert wrappedObserver.isObserverInterested(new TameAnnotationLiteral(), new RoleBinding("Admin"));
+
+ // Perform some tests with binding values (7.7.1)
+ wrappedObserver = new EventObserver<DangerCall>(observer, DangerCall.class, new RoleBinding("Admin"));
+ assert wrappedObserver.getEventBindings().length == 1;
+ assert wrappedObserver.isObserverInterested(new RoleBinding("Admin"));
+ assert !wrappedObserver.isObserverInterested(new RoleBinding("User"));
+ }
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventObserverTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -6,34 +6,48 @@
import javax.webbeans.DuplicateBindingTypeException;
import javax.webbeans.Event;
+import javax.webbeans.Observer;
import javax.webbeans.Standard;
import org.jboss.webbeans.event.EventImpl;
-import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
import org.jboss.webbeans.test.annotations.Synchronous;
import org.jboss.webbeans.test.annotations.Tame;
-import org.jboss.webbeans.test.beans.DangerCall;
-import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
import org.jboss.webbeans.test.bindings.FishStereotypeAnnotationLiteral;
+import org.jboss.webbeans.test.bindings.RiverFishStereotypeAnnotationLiteral;
import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
import org.jboss.webbeans.test.bindings.TameAnnotationLiteral;
+import org.jboss.webbeans.test.beans.DangerCall;
import org.jboss.webbeans.test.mock.MockManagerImpl;
import org.jboss.webbeans.util.Reflections;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
- * Tests for the implementation of an Event bean
+ * Tests for the implementation of an Event component.
*
* @author David Allen
*
*/
-@SpecVersion("20081012")
+@SpecVersion("20081024-PDR")
public class EventTest
{
private MockManagerImpl manager = null;
+ /**
+ * Test class used as an observer.
+ *
+ */
+ public class AnObserver<T> implements Observer<T>
+ {
+ protected boolean notified = false;
+
+ public void notify(T event)
+ {
+ this.notified = true;
+ }
+ }
+
@BeforeMethod
public void before() throws Exception
{
@@ -48,45 +62,87 @@
* instantiated implementation.
*/
@SuppressWarnings("unchecked")
- @Test(groups = "eventbus") @SpecAssertion(section="7.4")
+ @Test(groups = "eventbus")
+ @SpecAssertion(section = "7.6")
public void testFireEvent()
{
DangerCall anEvent = new DangerCall();
// Create a test annotation for the event and use it to construct the
// event object
- Annotation[] annotations = new Annotation[] { new AnimalStereotypeAnnotationLiteral() };
- EventImpl<DangerCall> eventBean = new EventImpl<DangerCall>();
- eventBean.setEventBindings(annotations);
- eventBean.setManager(manager);
- eventBean.fire(anEvent, new TameAnnotationLiteral(),
- new SynchronousAnnotationLiteral());
+ Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
+ EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>();
+ eventComponent.setEventBindings(annotations);
+ eventComponent.setManager(manager);
+ eventComponent.fire(anEvent, new SynchronousAnnotationLiteral());
assert anEvent.equals(manager.getEvent());
assert Reflections.annotationSetMatches(manager.getEventBindings(),
- AnimalStereotype.class, Tame.class,
- Synchronous.class);
+ Tame.class, Synchronous.class);
// Test duplicate annotations on the fire method call
boolean duplicateDetected = false;
try
{
- eventBean.fire(anEvent, new TameAnnotationLiteral(),
+ eventComponent.fire(anEvent, new TameAnnotationLiteral(),
new TameAnnotationLiteral());
} catch (DuplicateBindingTypeException e)
{
duplicateDetected = true;
}
assert duplicateDetected;
-
+
// Test annotations that are not binding types
boolean nonBindingTypeDetected = false;
try
{
- eventBean.fire(anEvent, new FishStereotypeAnnotationLiteral());
+ eventComponent.fire(anEvent, new FishStereotypeAnnotationLiteral());
+ } catch (IllegalArgumentException e)
+ {
+ nonBindingTypeDetected = true;
}
- catch (IllegalArgumentException e)
+ assert nonBindingTypeDetected;
+ }
+
+ /**
+ * Tests the {@link Event#observe(javax.webbeans.Observer, Annotation...)}
+ * method with a locally instantiated implementation.
+ */
+ @Test(groups = "eventbus")
+ @SpecAssertion(section = "7.6")
+ public void testObserve()
+ {
+ // Create a test annotation for the event and use it to construct the
+ // event object
+ Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
+ EventImpl<DangerCall> eventComponent = new EventImpl<DangerCall>();
+ eventComponent.setEventBindings(annotations);
+ eventComponent.setManager(manager);
+ Observer<DangerCall> observer = new AnObserver<DangerCall>();
+ eventComponent.observe(observer, new SynchronousAnnotationLiteral());
+ assert manager.getEventType().equals(DangerCall.class);
+
+ // Try duplicate annotation bindings
+ boolean duplicateDetected = false;
+ try
{
+ eventComponent.observe(observer,
+ new TameAnnotationLiteral());
+ } catch (DuplicateBindingTypeException e)
+ {
+ duplicateDetected = true;
+ }
+ assert duplicateDetected;
+
+ // Try an invalid binding type
+ boolean nonBindingTypeDetected = false;
+ try
+ {
+ eventComponent.observe(observer,
+ new RiverFishStereotypeAnnotationLiteral());
+ } catch (IllegalArgumentException e)
+ {
nonBindingTypeDetected = true;
}
assert nonBindingTypeDetected;
}
+
}
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-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ObserverTest.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -11,7 +11,6 @@
import javax.webbeans.Standard;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
@@ -31,14 +30,14 @@
* @author David Allen
*
*/
-@SpecVersion("20081012")
+@SpecVersion("20081024-PDR")
public class ObserverTest
{
private ManagerImpl manager;
private SimpleBeanModel<Tuna> tuna;
private InjectableMethod<?> om;
- public class Event
+ public class SampleEvent
{
// Simple class used for testing
}
@@ -47,7 +46,7 @@
{
protected boolean notified = false;
- public void observe(@Observes @Asynchronous Event e)
+ public void observe(@Observes @Asynchronous SampleEvent e)
{
// An observer method
this.notified = true;
@@ -67,49 +66,21 @@
annotations.put(Asynchronous.class, new AsynchronousAnnotationLiteral());
AnnotatedType<Tuna> annotatedItem = new SimpleAnnotatedType<Tuna>(Tuna.class, annotations);
tuna = new SimpleBeanModel<Tuna>(new SimpleAnnotatedType<Tuna>(Tuna.class), annotatedItem, manager);
- om = new InjectableMethod<Object>(AnObserver.class.getMethod("observe", new Class[] { Event.class }));
+ om = new InjectableMethod<Object>(AnObserver.class.getMethod("observe", new Class[] { SampleEvent.class }));
}
/**
* Test method for
- * {@link org.jboss.webbeans.event.ObserverImpl#getEventBindingTypes()}.
- */
- @SuppressWarnings("unchecked")
- @Test(groups = "eventbus") @SpecAssertion(section="7.3")
- public final void testGetEventBindingTypes() throws Exception
- {
- Observer<Event> o = new ObserverImpl<Event>(tuna, om, Event.class);
- //assert o.getEventBindingTypes().size() == 1;
- //assert Reflections.annotationSetMatches(o.getEventBindingTypes(), Asynchronous.class);
- //assert o.getEventType().equals(Event.class);
- }
-
- /**
- * Test method for
- * {@link org.jboss.webbeans.event.ObserverImpl#getEventType()}.
- *
- * @throws
- * @throws Exception
- */
- @Test(groups = "eventbus") @SpecAssertion(section="7.3")
- public final void testGetEventType() throws Exception
- {
- Observer<Event> o = new ObserverImpl<Event>(tuna, om, Event.class);
- //assert o.getEventType().equals(Event.class);
- }
-
- /**
- * Test method for
* {@link org.jboss.webbeans.event.ObserverImpl#notify(javax.webbeans.Container, java.lang.Object)}
* .
*/
- @Test(groups = "eventbus") @SpecAssertion(section={"7.2","7.3"})
+ @Test(groups = "eventbus") @SpecAssertion(section={"7.5.7"})
public final void testNotify() throws Exception
{
AnObserver observerInstance = new AnObserver();
- Observer<Event> observer = new MockObserverImpl<Event>(tuna, om, Event.class);
- ((MockObserverImpl<Event>) observer).setInstance(observerInstance);
- Event event = new Event();
+ Observer<SampleEvent> observer = new MockObserverImpl<SampleEvent>(tuna, om, SampleEvent.class);
+ ((MockObserverImpl<SampleEvent>) observer).setInstance(observerInstance);
+ SampleEvent event = new SampleEvent();
observer.notify(event);
assert observerInstance.notified;
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/annotations/Role.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/annotations/Role.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/annotations/Role.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.annotations;
+
+public @interface Role
+{
+ String value();
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/annotations/Role.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/bindings/RoleBinding.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/bindings/RoleBinding.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/bindings/RoleBinding.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.AnnotationLiteral;
+
+import org.jboss.webbeans.test.annotations.Role;
+
+public class RoleBinding extends AnnotationLiteral<Role> implements Role
+{
+ private String value = null;
+
+ public RoleBinding(String value)
+ {
+ this.value = value;
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/bindings/RoleBinding.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-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockManagerImpl.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -6,12 +6,18 @@
import java.util.List;
import java.util.Set;
+import javax.webbeans.Observer;
+import javax.webbeans.TypeLiteral;
+import javax.webbeans.manager.Manager;
+
import org.jboss.webbeans.ManagerImpl;
public class MockManagerImpl extends ManagerImpl
{
private Object event = null;
+ private Class<? extends Object> eventType = null;
private Annotation[] eventBindings = null;
+ private Observer<?> observer = null;
public MockManagerImpl(List<Class<? extends Annotation>> enabledDeploymentTypes)
{
@@ -29,6 +35,33 @@
this.eventBindings = bindings;
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.ManagerImpl#addObserver(javax.webbeans.Observer, java.lang.Class, java.lang.annotation.Annotation[])
+ */
+ @Override
+ public <T> Manager addObserver(Observer<T> observer, Class<T> eventType,
+ Annotation... bindings)
+ {
+ this.observer = observer;
+ this.eventType = eventType;
+ this.eventBindings = bindings;
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.ManagerImpl#addObserver(javax.webbeans.Observer, javax.webbeans.TypeLiteral, java.lang.annotation.Annotation[])
+ */
+ @Override
+ public <T> Manager addObserver(Observer<T> observer,
+ TypeLiteral<T> eventType, Annotation... bindings)
+ {
+ this.observer = observer;
+ // TODO Fix the event type based on the type literal being passed. Not clear how to get the actual T.
+ this.eventType = null;
+ this.eventBindings = bindings;
+ return this;
+ }
+
/**
* Retrieves the event which was last fired with this manager.
* @return the event
@@ -49,4 +82,20 @@
return null;
}
+ /**
+ * @return the eventType
+ */
+ public final Class<?> getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @return the observer
+ */
+ public final Observer<?> getObserver()
+ {
+ return observer;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java 2008-10-26 20:39:54 UTC (rev 171)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockObserverImpl.java 2008-10-27 09:59:35 UTC (rev 172)
@@ -1,7 +1,5 @@
package org.jboss.webbeans.test.mock;
-import javax.webbeans.manager.Manager;
-
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.model.bean.BeanModel;
@@ -24,7 +22,7 @@
}
@Override
- protected final Object getInstance(Manager manager) {
+ protected final Object getInstance() {
return specializedInstance;
}
16 years, 1 month
[webbeans-commits] Webbeans SVN: r171 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-26 16:39:54 -0400 (Sun, 26 Oct 2008)
New Revision: 171
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.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
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
ri/trunk/webbeans-ri/testng.xml
Log:
Stub tests for 8.3, make basic context abstract
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java (from rev 170, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/AbstractContext.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+import javax.webbeans.manager.Manager;
+
+import org.jboss.webbeans.util.MapWrapper;
+
+/**
+ * Basic implementation of javax.webbeans.Context, backed by a HashMap
+ *
+ * @author Shane Bryzak
+ * @author Nicklas Karlsson (nickarls(a)gmail.com)
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractContext implements Context
+{
+
+ private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
+ {
+
+ public BeanMap()
+ {
+ super(new HashMap<Bean<? extends Object>, Object>());
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Object> T get(Bean<? extends T> key)
+ {
+ return (T) super.get(key);
+ }
+
+ }
+
+ private BeanMap beans;
+ private Class<? extends Annotation> scopeType;
+ private boolean active;
+
+ public AbstractContext(Class<? extends Annotation> scopeType)
+ {
+ this.scopeType = scopeType;
+ beans = new BeanMap();
+ active = true;
+ }
+
+ public <T> T get(Bean<T> bean, boolean create)
+ {
+ if (!active)
+ {
+ throw new ContextNotActiveException();
+ }
+
+ if (beans == null)
+ {
+ // Context has been destroyed
+ return null;
+ }
+
+ T instance = beans.get(bean);
+
+ if (instance != null)
+ {
+ return instance;
+ }
+
+ if (!create)
+ {
+ return null;
+ }
+
+ // TODO should bean creation be synchronized?
+
+ instance = bean.create();
+
+ beans.put(bean, instance);
+ return instance;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return scopeType;
+ }
+
+ 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;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java 2008-10-26 19:14:11 UTC (rev 170)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-
-import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Context;
-import javax.webbeans.manager.Manager;
-
-import org.jboss.webbeans.util.MapWrapper;
-
-/**
- * Basic implementation of javax.webbeans.Context, backed by a HashMap
- *
- * @author Shane Bryzak
- * @author Nicklas Karlsson (nickarls(a)gmail.com)
- * @author Pete Muir
- *
- */
-public class BasicContext implements Context
-{
-
- private class BeanMap extends MapWrapper<Bean<? extends Object>, Object>
- {
-
- public BeanMap()
- {
- super(new HashMap<Bean<? extends Object>, Object>());
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Object> T get(Bean<? extends T> key)
- {
- return (T) super.get(key);
- }
-
- }
-
- private BeanMap beans;
- private Class<? extends Annotation> scopeType;
- private boolean active;
-
- public BasicContext(Class<? extends Annotation> scopeType)
- {
- this.scopeType = scopeType;
- beans = new BeanMap();
- active = true;
- }
-
- public <T> T get(Bean<T> bean, boolean create)
- {
- if (!active)
- {
- throw new ContextNotActiveException();
- }
-
- if (beans == null)
- {
- // Context has been destroyed
- return null;
- }
-
- T instance = beans.get(bean);
-
- if (instance != null)
- {
- return instance;
- }
-
- if (!create)
- {
- return null;
- }
-
- // TODO should bean creation be synchronized?
-
- instance = bean.create();
-
- beans.put(bean, instance);
- return instance;
- }
-
- public Class<? extends Annotation> getScopeType()
- {
- return scopeType;
- }
-
- 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;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive(boolean active)
- {
- this.active = active;
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-26 19:14:11 UTC (rev 170)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -11,7 +11,7 @@
import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Manager;
-import org.jboss.webbeans.BasicContext;
+import org.jboss.webbeans.AbstractContext;
/**
*
@@ -30,7 +30,7 @@
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
- BasicContext requestContext = new BasicContext(RequestScoped.class);
+ AbstractContext requestContext = new AbstractContext(RequestScoped.class) {};
try
{
Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java (from rev 170, ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/CommonContextTest.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -0,0 +1,72 @@
+package org.jboss.webbeans.test;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.RequestScoped;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+
+import org.jboss.webbeans.AbstractContext;
+import org.jboss.webbeans.test.beans.Tuna;
+import org.jboss.webbeans.test.util.Util;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Nicklas Karlsson (nickarls(a)gmail.com)
+ * @author Pete Muir
+ *
+ * This class tests a basic context against section 8 of the specification
+ *
+ */
+@SpecVersion("20081020")
+public class CommonContextTest extends AbstractTest
+{
+ Context context;
+
+ @BeforeMethod
+ public void initContext() {
+ context = new AbstractContext(RequestScoped.class) {};
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.1")
+ public void testGetWithCreateFalseReturnsNull() {
+ Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
+ assert context.get(tunaBean, false) == null;
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.1")
+ public void testGetWithCreateTrueReturnsBean() {
+ Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
+ assert context.get(tunaBean, true) != null;
+ }
+
+ @Test(groups="contexts", expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="8.1")
+ public void testInactiveContextThrowsContextNotActiveException() {
+ ((AbstractContext)context).setActive(false);
+ context.get(null, false);
+ assert true;
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.1")
+ public void testReturnsCorrectExistingBean() {
+ Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
+ Tuna firstTuna = context.get(tunaBean, true);
+ Tuna secondTuna = context.get(tunaBean, false);
+ assert firstTuna == secondTuna;
+ }
+
+ @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.1")
+ public void testProducerMethodReturningNullOK() {
+ // TODO
+ assert false;
+ }
+
+ @Test(groups="contexts")
+ public void testDestroy() {
+ Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
+ assert context.get(tunaBean, true) instanceof Tuna;
+ ((AbstractContext)context).destroy(manager);
+ assert context.get(tunaBean, false) == null;
+ }
+}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 19:14:11 UTC (rev 170)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -1,72 +0,0 @@
-package org.jboss.webbeans.test;
-
-import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.RequestScoped;
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Context;
-
-import org.jboss.webbeans.BasicContext;
-import org.jboss.webbeans.test.beans.Tuna;
-import org.jboss.webbeans.test.util.Util;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Nicklas Karlsson (nickarls(a)gmail.com)
- * @author Pete Muir
- *
- * This class tests a basic context against section 8 of the specification
- *
- */
-@SpecVersion("20081020")
-public class ContextTest extends AbstractTest
-{
- Context context;
-
- @BeforeMethod
- public void initContext() {
- context = new BasicContext(RequestScoped.class);
- }
-
- @Test(groups="contexts") @SpecAssertion(section="8.1")
- public void testGetWithCreateFalseReturnsNull() {
- Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
- assert context.get(tunaBean, false) == null;
- }
-
- @Test(groups="contexts") @SpecAssertion(section="8.1")
- public void testGetWithCreateTrueReturnsBean() {
- Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
- assert context.get(tunaBean, true) != null;
- }
-
- @Test(groups="contexts", expectedExceptions=ContextNotActiveException.class) @SpecAssertion(section="8.1")
- public void testInactiveContextThrowsContextNotActiveException() {
- ((BasicContext)context).setActive(false);
- context.get(null, false);
- assert true;
- }
-
- @Test(groups="contexts") @SpecAssertion(section="8.1")
- public void testReturnsCorrectExistingBean() {
- Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
- Tuna firstTuna = context.get(tunaBean, true);
- Tuna secondTuna = context.get(tunaBean, false);
- assert firstTuna == secondTuna;
- }
-
- @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.1")
- public void testProducerMethodReturningNullOK() {
- // TODO
- assert false;
- }
-
- @Test(groups="contexts")
- public void testDestroy() {
- Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
- assert context.get(tunaBean, true) instanceof Tuna;
- ((BasicContext)context).destroy(manager);
- assert context.get(tunaBean, false) == null;
- }
-}
Added: 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 (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java 2008-10-26 20:39:54 UTC (rev 171)
@@ -0,0 +1,147 @@
+package org.jboss.webbeans.test;
+
+import org.testng.annotations.Test;
+
+public class DependentContextTest extends AbstractTest
+{
+
+ @Test(groups="contexts") @SpecAssertion(section="8.3")
+ public void testInstanceNotSharedBetweenInjectionPoints()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "el"}) @SpecAssertion(section="8.3")
+ public void testInstanceUsedForElEvalutionNotShared()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
+ public void testInstanceUsedForProducerMethodNotShared()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "eventbus"}) @SpecAssertion(section="8.3")
+ public void testInstanceUsedForObserverMethodNotShared()
+ {
+ assert false;
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.3")
+ public void testContextGetWithCreateTrueReturnsNewInstance()
+ {
+ assert false;
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.3")
+ public void testContextGetWithCreateFalseReturnsNull()
+ {
+ assert false;
+ }
+
+ @Test(groups="contexts") @SpecAssertion(section="8.3")
+ public void testContextIsInactive()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveWhenInvokingProducerMethod()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "eventbus"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveWhenInvokingObserverMethod()
+ {
+ assert false;
+ }
+
+
+ @Test(groups={"contexts", "el"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveWhenEvaluatingElExpression()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "beanLifecycle"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveDuringBeanCreation()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "beanLifecycle"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveDuringBeanDestruction()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "injection"}) @SpecAssertion(section="8.3")
+ public void testContextIsActiveDuringInjection()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.3")
+ public void testEjbBeanMayMayCreateInstanceFromInitializer()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.3")
+ public void testEjbBeanMayMayCreateInstanceFromPostConstruct()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.3")
+ public void testEjbBeanMayMayCreateInstanceFromPreDestroy()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "servlet"}) @SpecAssertion(section="8.3")
+ public void testServletBeanMayMayCreateInstanceFromInitializer()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts"}) @SpecAssertion(section="8.3")
+ public void testDestroyingParentDestroysDependents()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "ejb3"}) @SpecAssertion(section="8.3")
+ public void testDestroyingEjbDestroysDependents()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "servlet"}) @SpecAssertion(section="8.3")
+ public void testDestroyingServletDestroysDependents()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts"}) @SpecAssertion(section="8.3")
+ public void testDependentsDestroyedWhenElEvaluationCompletes()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.3")
+ public void testDependentsDestroyedWhenProducerMethodEvaluationCompletes()
+ {
+ assert false;
+ }
+
+ @Test(groups={"contexts", "eventbus"}) @SpecAssertion(section="8.3")
+ public void testDependentsDestroyedWhenObserverMethodEvaluationCompletes()
+ {
+ assert false;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DependentContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-26 19:14:11 UTC (rev 170)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-26 20:39:54 UTC (rev 171)
@@ -19,6 +19,7 @@
<exclude name="jms" />
<exclude name="interceptors" />
<exclude name="innerClass" />
+ <exclude name="servlet" />
</run>
</groups>
<packages>
16 years, 1 month
[webbeans-commits] Webbeans SVN: r170 - 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-26 15:14:11 -0400 (Sun, 26 Oct 2008)
New Revision: 170
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
Log:
Remove remove method
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java 2008-10-26 18:53:43 UTC (rev 169)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/BasicContext.java 2008-10-26 19:14:11 UTC (rev 170)
@@ -15,8 +15,8 @@
*
* @author Shane Bryzak
* @author Nicklas Karlsson (nickarls(a)gmail.com)
- * @author Pete\ Muir
- * @
+ * @author Pete Muir
+ *
*/
public class BasicContext implements Context
{
@@ -54,7 +54,15 @@
{
throw new ContextNotActiveException();
}
+
+ if (beans == null)
+ {
+ // Context has been destroyed
+ return null;
+ }
+
T instance = beans.get(bean);
+
if (instance != null)
{
return instance;
@@ -78,28 +86,18 @@
return scopeType;
}
- public <T> void remove(Manager manager, Bean<T> bean)
+ private <T> void destroy(Manager manager, Bean<T> bean)
{
- T instance = beans.get(bean);
-
- if (instance != null)
- {
- beans.remove(bean);
- bean.destroy(instance);
- }
- else
- {
- // TODO is this the correct exception to throw? See section 9.1 of spec
- throw new RuntimeException("Bean " + bean.getName() + " cannot be removed as it " + "does not exist in [" + scopeType + "] context.");
- }
+ bean.destroy(beans.get(bean));
}
public void destroy(Manager manager)
{
for (Bean<? extends Object> bean : beans.keySet())
{
- remove(manager, bean);
+ destroy(manager, bean);
}
+ beans = null;
}
public boolean isActive()
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 18:53:43 UTC (rev 169)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 19:14:11 UTC (rev 170)
@@ -63,10 +63,10 @@
}
@Test(groups="contexts")
- public void testRemoveBean() {
+ public void testDestroy() {
Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
- Tuna firstTuna = context.get(tunaBean, true);
- ((BasicContext)context).remove(manager, tunaBean);
+ assert context.get(tunaBean, true) instanceof Tuna;
+ ((BasicContext)context).destroy(manager);
assert context.get(tunaBean, false) == null;
}
}
16 years, 1 month
[webbeans-commits] Webbeans SVN: r169 - ri/trunk/webbeans-api/src/main/java/javax/webbeans.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-10-26 14:53:43 -0400 (Sun, 26 Oct 2008)
New Revision: 169
Added:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java
Log:
Conversation interface
Added: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java (rev 0)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java 2008-10-26 18:53:43 UTC (rev 169)
@@ -0,0 +1,11 @@
+package javax.webbeans;
+
+public interface Conversation {
+ public void begin();
+ public void begin(String id);
+ public void end();
+ public boolean isLongRunning();
+ public String getId();
+ public long getTimeout();
+ public void setTimeout(long milliseconds);
+}
\ No newline at end of file
16 years, 1 month
[webbeans-commits] Webbeans SVN: r168 - 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-26 12:24:01 -0400 (Sun, 26 Oct 2008)
New Revision: 168
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
ri/trunk/webbeans-ri/testng.xml
Log:
Enable simple context tests
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 14:43:18 UTC (rev 167)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ContextTest.java 2008-10-26 16:24:01 UTC (rev 168)
@@ -6,9 +6,6 @@
import javax.webbeans.manager.Context;
import org.jboss.webbeans.BasicContext;
-import org.jboss.webbeans.BeanImpl;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.beans.Tuna;
import org.jboss.webbeans.test.util.Util;
import org.testng.annotations.BeforeMethod;
@@ -17,6 +14,7 @@
/**
*
* @author Nicklas Karlsson (nickarls(a)gmail.com)
+ * @author Pete Muir
*
* This class tests a basic context against section 8 of the specification
*
@@ -58,7 +56,7 @@
assert firstTuna == secondTuna;
}
- @Test(groups="contexts") @SpecAssertion(section="8.1")
+ @Test(groups={"contexts", "producerMethod"}) @SpecAssertion(section="8.1")
public void testProducerMethodReturningNullOK() {
// TODO
assert false;
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-26 14:43:18 UTC (rev 167)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-26 16:24:01 UTC (rev 168)
@@ -12,7 +12,6 @@
<exclude name="producerMethod" />
<exclude name="eventbus" />
<exclude name="injection" />
- <exclude name="contexts" />
<exclude name="ejb3" />
<exclude name="annotationDefinition" />
<exclude name="webbeansxml" />
16 years, 1 month
[webbeans-commits] Webbeans SVN: r167 - 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-26 10:43:18 -0400 (Sun, 26 Oct 2008)
New Revision: 167
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
Log:
Leave xml constructors to later
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 14:25:13 UTC (rev 166)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 14:43:18 UTC (rev 167)
@@ -56,6 +56,7 @@
new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
}
+ @SuppressWarnings("unchecked")
@Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
public void testParameterizedClassDeclaredInJavaIsNotAllowed()
{
@@ -123,7 +124,7 @@
new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
}
- @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
+ @Test(expectedExceptions=DefinitionException.class, groups="webbeansxml") @SpecAssertion(section="3.2.4")
public void testParameterizedClassDeclaredInXmlIsNotAllowed()
{
assert false;
@@ -204,7 +205,7 @@
new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
}
- @Test @SpecAssertion(section="3.2.5.2")
+ @Test(groups="webbeansxml") @SpecAssertion(section="3.2.5.2")
public void testImplicitConstructorDeclaredInXmlUsed()
{
SimpleConstructor<Order> constructor = new SimpleBeanModel<Order>(new SimpleAnnotatedType<Order>(Order.class), getEmptyAnnotatedType(Order.class), manager).getConstructor();
@@ -214,7 +215,7 @@
assert false;
}
- @Test @SpecAssertion(section="3.2.5.2")
+ @Test(groups="webbeansxml") @SpecAssertion(section="3.2.5.2")
public void testEmptyConstructorDeclaredInXmlUsed()
{
SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor(); assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
@@ -223,13 +224,13 @@
assert false;
}
- @Test(expectedExceptions=NonexistentConstructorException.class) @SpecAssertion(section="3.2.5.2")
+ @Test(expectedExceptions=NonexistentConstructorException.class, groups="webbeansxml") @SpecAssertion(section="3.2.5.2")
public void testConstructorDeclaredInXmlDoesNotExist()
{
assert false;
}
- @Test @SpecAssertion(section="3.2.5.2")
+ @Test(groups="webbeansxml") @SpecAssertion(section="3.2.5.2")
public void testConstructorDeclaredInXmlIgnoresBindingTypesDeclaredInJava()
{
assert false;
16 years, 1 month
[webbeans-commits] Webbeans SVN: r166 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans/model/bean and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-26 10:25:13 -0400 (Sun, 26 Oct 2008)
New Revision: 166
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/AnimalFarmer.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/ParameterizedBean.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractBeanModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.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/DeferredEventNotificationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeSafeResolutionTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/OuterBean.java
ri/trunk/webbeans-ri/testng.xml
Log:
Fix remaining tests for 3.2 except xml declared constructors
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractBeanModel.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractBeanModel.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -37,7 +37,7 @@
protected Class<? extends Annotation> scopeType;
private MergedStereotypesModel<T, E> mergedStereotypes;
protected Class<? extends Annotation> deploymentType;
- protected Class<? extends T> type;
+ protected Class<T> type;
protected InjectableMethod<?> removeMethod;
private Set<Class<?>> apiTypes;
protected Set<Injectable<?, ?>> injectionPoints;
@@ -293,7 +293,7 @@
return scopeType;
}
- public Class<? extends T> getType()
+ public Class<T> getType()
{
return type;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/ProducerMethodBeanModel.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -155,7 +155,7 @@
{
try
{
- this.type = annotatedMethod.getType();
+ // TODO Fix this this.type = annotatedMethod.getType();
}
catch (ClassCastException e)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -4,7 +4,6 @@
import java.util.List;
import java.util.logging.Logger;
-import javax.webbeans.BindingType;
import javax.webbeans.DefinitionException;
import javax.webbeans.Initializer;
@@ -58,69 +57,45 @@
public static void checkType(Class<?> type)
{
- if (type.isMemberClass())
+ if (Reflections.isStaticInnerClass(type))
{
- throw new DefinitionException("Simple Web Bean " + type + " cannot be an inner class");
+ throw new DefinitionException("Simple Web Bean " + type + " cannot be a static inner class");
}
+ if (Reflections.isParameterizedType(type))
+ {
+ throw new DefinitionException("Simple Web Bean " + type + " cannot be a parameterized type");
+ }
}
protected void initConstructor()
{
- if (getType().getConstructors().length == 1)
- {
- Constructor<T> constructor = (Constructor<T>) getType().getConstructors()[0];
- log.finest("Exactly one constructor (" + constructor +") defined, using it as the bean constructor for " + getType());
- this.constructor = new SimpleConstructor<T>(constructor);
- return;
- }
- if (getType().getConstructors().length > 1)
+ List<Constructor<T>> initializerAnnotatedConstructors = Reflections.getAnnotatedConstructors(getType(), Initializer.class);
+ log.finest("Found " + initializerAnnotatedConstructors + " constructors annotated with @Initializer for " + getType());
+ if (initializerAnnotatedConstructors.size() > 1)
{
- List<Constructor<T>> initializerAnnotatedConstructors = Reflections.getConstructors(getType(), Initializer.class);
- List<Constructor<T>> bindingTypeAnnotatedConstructors = Reflections.getConstructorsForMetaAnnotatedParameter(getType(), BindingType.class);
- log.finest("Found " + initializerAnnotatedConstructors + " constructors annotated with @Initializer for " + getType());
- log.finest("Found " + bindingTypeAnnotatedConstructors + " with parameters annotated with binding types for " + getType());
- if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
+ if (initializerAnnotatedConstructors.size() > 1)
{
- if (initializerAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + getType());
- }
-
- else if (bindingTypeAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + getType());
- }
- else
- {
- throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + getType());
- }
+ throw new DefinitionException("Cannot have more than one constructor annotated with @Initializer for " + getType());
}
- else if (initializerAnnotatedConstructors.size() == 1)
- {
- Constructor<T> constructor = initializerAnnotatedConstructors.get(0);
- log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the bean constructor for " + getType());
- this.constructor = new SimpleConstructor<T>(constructor);
- return;
- }
- else if (bindingTypeAnnotatedConstructors.size() == 1)
- {
- Constructor<T> constructor = bindingTypeAnnotatedConstructors.get(0);
- log.finest("Exactly one constructor (" + constructor +") with parameters annotated with binding types defined, using it as the bean constructor for " + getType());
- this.constructor = new SimpleConstructor<T>(constructor);
- return;
- }
}
-
- if (getType().getConstructors().length == 0)
- {
- Constructor<T> constructor = (Constructor<T>) Reflections.getConstructor(getType());
- log.finest("No constructor defined, using implicit no arguement constructor for " + getType());
+ else if (initializerAnnotatedConstructors.size() == 1)
+ {
+ Constructor<T> constructor = initializerAnnotatedConstructors.get(0);
+ log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the bean constructor for " + getType());
this.constructor = new SimpleConstructor<T>(constructor);
return;
}
+
+ Constructor<T> emptyConstructor = Reflections.getConstructor(getType());
+ if (emptyConstructor != null)
+ {
+ log.finest("Exactly one constructor (" + constructor +") defined, using it as the bean constructor for " + getType());
+ this.constructor = new SimpleConstructor<T>(emptyConstructor);
+ return;
+ }
- throw new RuntimeException("Cannot determine constructor to use for " + getType());
+ throw new DefinitionException("Cannot determine constructor to use for " + getType());
}
public SimpleConstructor<T> getConstructor()
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-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -82,6 +82,16 @@
return Modifier.isAbstract(clazz.getModifiers());
}
+ public static boolean isStaticInnerClass(Class<?> clazz)
+ {
+ return clazz.isMemberClass() && Modifier.isStatic(clazz.getModifiers());
+ }
+
+ public static boolean isNonStaticInnerClass(Class<?> clazz)
+ {
+ return clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers());
+ }
+
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
{
try
@@ -112,7 +122,7 @@
}
@SuppressWarnings("unchecked")
- public static <T> List<Constructor<T>> getConstructors(Class<? extends T> clazz, Class<? extends Annotation> annotationType)
+ public static <T> List<Constructor<T>> getAnnotatedConstructors(Class<? extends T> clazz, Class<? extends Annotation> annotationType)
{
List<Constructor<T>> constructors = new ArrayList<Constructor<T>>();
for (Constructor<?> constructor : clazz.getConstructors())
@@ -217,4 +227,9 @@
{
return rawType.isArray();
}
+
+ public static boolean isParameterizedType(Class<?> type)
+ {
+ return type.getTypeParameters().length > 0;
+ }
}
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-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeferredEventNotificationTest.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -55,7 +55,7 @@
* {@link org.jboss.webbeans.event.DeferredEventNotification#beforeCompletion()}
* .
*/
- @Test
+ @Test(groups="eventbus")
public final void testBeforeCompletion() throws Exception
{
// When the transaction is committed, the beforeCompletion() method is
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseBeanModelTest.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseBeanModelTest.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -30,12 +30,6 @@
public class EnterpriseBeanModelTest extends AbstractTest
{
- @Test @SpecAssertion(section="2.7.2")
- public void testSingleStereotype()
- {
- assert false;
- }
-
@SuppressWarnings("unchecked")
@Test
public void testStateless()
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerMethodBeanModelTest.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -30,7 +30,7 @@
public class ProducerMethodBeanModelTest extends AbstractTest
{
- @Test @SpecAssertion(section="2.5.3")
+ @Test(groups="producerMethod") @SpecAssertion(section="2.5.3")
public void testProducerMethodInheritsDeploymentTypeOfDeclaringWebBean() throws Exception
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -40,7 +40,7 @@
tarantulaModel.getDeploymentType().equals(AnotherDeploymentType.class);
}
- @Test @SpecAssertion(section="3.3")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3")
public void testStaticMethod() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<BeanWithStaticProducerMethod> model = new SimpleBeanModel<BeanWithStaticProducerMethod>(new SimpleAnnotatedType<BeanWithStaticProducerMethod>(BeanWithStaticProducerMethod.class), getEmptyAnnotatedType(BeanWithStaticProducerMethod.class), manager);
@@ -58,7 +58,7 @@
assert exception;
}
- @Test @SpecAssertion(section="3.3")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3")
public void testApiTypes() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -73,7 +73,7 @@
assert !tarantulaModel.getApiTypes().contains(Object.class);
}
- @Test @SpecAssertion(section="3.3.1")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3.1")
public void testDefaultBindingType() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -84,7 +84,7 @@
assert tarantulaModel.getBindingTypes().iterator().next().annotationType().equals(Current.class);
}
- @Test
+ @Test(groups="producerMethod")
public void testBindingType() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -95,7 +95,7 @@
assert tarantulaModel.getBindingTypes().iterator().next().annotationType().equals(Tame.class);
}
- @Test @SpecAssertion(section="3.3")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3")
public void testFinalMethod() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<BeanWithFinalProducerMethod> model = new SimpleBeanModel<BeanWithFinalProducerMethod>(new SimpleAnnotatedType<BeanWithFinalProducerMethod>(BeanWithFinalProducerMethod.class), getEmptyAnnotatedType(BeanWithFinalProducerMethod.class), manager);
@@ -113,7 +113,7 @@
assert exception;
}
- @Test @SpecAssertion(section="3.3")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3")
public void testFinalMethodWithDependentScope() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -123,7 +123,7 @@
assert trapdoorSpiderModel.getScopeType().equals(Dependent.class);
}
- @Test @SpecAssertion(section="3.3.6")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3.6")
public void testNamedMethod() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -133,7 +133,7 @@
assert blackWidowSpiderModel.getName().equals("blackWidow");
}
- @Test @SpecAssertion(section="3.3.6")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3.6")
public void testDefaultNamedMethod() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -143,7 +143,7 @@
assert daddyLongLegsSpiderModel.getName().equals("produceDaddyLongLegs");
}
- @Test @SpecAssertion(section="3.3.6")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.3.6")
public void testDefaultNamedJavaBeanMethod() throws SecurityException, NoSuchMethodException
{
SimpleBeanModel<SpiderProducer> model = new SimpleBeanModel<SpiderProducer>(new SimpleAnnotatedType<SpiderProducer>(SpiderProducer.class), getEmptyAnnotatedType(SpiderProducer.class), manager);
@@ -213,13 +213,13 @@
assert false;
}
- @Test @SpecAssertion(section="2.7.2")
+ @Test(groups="producerMethod") @SpecAssertion(section="2.7.2")
public void testSingleStereotype()
{
assert false;
}
- @Test @SpecAssertion(section="2.7.2")
+ @Test(groups="producerMethod") @SpecAssertion(section="2.7.2")
public void testStereotypeOnNonProducerMethod()
{
assert false;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -26,7 +26,9 @@
import org.jboss.webbeans.test.beans.Spider;
import org.jboss.webbeans.test.beans.Tarantula;
import org.jboss.webbeans.test.beans.Turkey;
+import org.jboss.webbeans.test.beans.broken.ParameterizedBean;
import org.jboss.webbeans.test.beans.broken.OuterBean.InnerBean;
+import org.jboss.webbeans.test.beans.broken.OuterBean.StaticInnerBean;
import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
import org.testng.annotations.Test;
@@ -42,22 +44,22 @@
new SimpleBeanModel<Cow>(new SimpleAnnotatedType<Cow>(Cow.class), getEmptyAnnotatedType(Cow.class), manager);
}
- @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
- public void testNonStaticInnerClassDeclaredInJavaIsNotAllowed()
+ @Test(expectedExceptions=DefinitionException.class, groups="innerClass") @SpecAssertion(section="3.2")
+ public void testStaticInnerClassDeclaredInJavaIsNotAllowed()
{
- new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
+ new SimpleBeanModel<StaticInnerBean>(new SimpleAnnotatedType<StaticInnerBean>(StaticInnerBean.class), getEmptyAnnotatedType(StaticInnerBean.class), manager);
}
- @Test @SpecAssertion(section="3.2")
- public void testStaticInnerClassDeclaredInJavaAllowed()
+ @Test(groups="innerClass") @SpecAssertion(section="3.2")
+ public void testNonStaticInnerClassDeclaredInJavaAllowed()
{
- assert false;
+ new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
}
@Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
public void testParameterizedClassDeclaredInJavaIsNotAllowed()
{
-
+ new SimpleBeanModel<ParameterizedBean>(new SimpleAnnotatedType<ParameterizedBean>(ParameterizedBean.class), getEmptyAnnotatedType(ParameterizedBean.class), manager);
}
@Test(expectedExceptions=DefinitionException.class, groups={"interceptors", "decorators"}) @SpecAssertion(section="3.2")
@@ -106,19 +108,19 @@
@Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
public void testAbstractClassDeclaredInXmlIsNotAllowed()
{
- assert false;
+ new SimpleBeanModel<Cow>(new SimpleAnnotatedType<Cow>(Cow.class), getEmptyAnnotatedType(Cow.class), manager);
}
- @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
- public void testNonStaticInnerClassDeclaredInXmlIsNotAllowed()
+ @Test(expectedExceptions=DefinitionException.class, groups="innerClass") @SpecAssertion(section="3.2.4")
+ public void testStaticInnerClassDeclaredInXmlIsNotAllowed()
{
- assert false;
+ new SimpleBeanModel<StaticInnerBean>(new SimpleAnnotatedType<StaticInnerBean>(StaticInnerBean.class), getEmptyAnnotatedType(StaticInnerBean.class), manager);
}
- @Test @SpecAssertion(section="3.2.4")
- public void testStaticInnerClassDeclaredInXmlAllowed()
+ @Test(groups="innerClass") @SpecAssertion(section="3.2.4")
+ public void testNonStaticInnerClassDeclaredInXmlAllowed()
{
- assert false;
+ new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
}
@Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
@@ -168,7 +170,8 @@
@Test @SpecAssertion(section="3.2.5.1")
public void testEmptyConstructorUsed()
{
- SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor(); assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
+ SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor();
+ assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Donkey.class);
assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
assert constructor.getParameters().size() == 0;
}
@@ -195,7 +198,7 @@
new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
}
- @Test(expectedExceptions=DefinitionException.class, groups="eventBus") @SpecAssertion(section="3.2.5.1")
+ @Test(expectedExceptions=DefinitionException.class, groups="eventbus") @SpecAssertion(section="3.2.5.1")
public void testConstructorHasObservesParameter()
{
new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
@@ -223,13 +226,13 @@
@Test(expectedExceptions=NonexistentConstructorException.class) @SpecAssertion(section="3.2.5.2")
public void testConstructorDeclaredInXmlDoesNotExist()
{
-
+ assert false;
}
@Test @SpecAssertion(section="3.2.5.2")
public void testConstructorDeclaredInXmlIgnoresBindingTypesDeclaredInJava()
{
-
+ assert false;
}
@Test @SpecAssertion(section="3.2.5.3")
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeSafeResolutionTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeSafeResolutionTest.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeSafeResolutionTest.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -18,6 +18,7 @@
import org.jboss.webbeans.model.bean.SimpleBeanModel;
import org.jboss.webbeans.test.annotations.Whitefish;
import org.jboss.webbeans.test.beans.Animal;
+import org.jboss.webbeans.test.beans.AnimalFarmer;
import org.jboss.webbeans.test.beans.Cod;
import org.jboss.webbeans.test.beans.Farmer;
import org.jboss.webbeans.test.beans.FishFarm;
@@ -175,7 +176,7 @@
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<Farmer> farmerBean = new BeanImpl<Farmer>(new SimpleBeanModel<Farmer>(new SimpleAnnotatedType<Farmer>(Farmer.class), getEmptyAnnotatedType(Farmer.class), super.manager), manager);
+ Bean<AnimalFarmer> farmerBean = new BeanImpl<AnimalFarmer>(new SimpleBeanModel<AnimalFarmer>(new SimpleAnnotatedType<AnimalFarmer>(AnimalFarmer.class), getEmptyAnnotatedType(AnimalFarmer.class), super.manager), manager);
manager.addBean(scottishFishFarmerBean);
manager.addBean(farmerBean);
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/AnimalFarmer.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/AnimalFarmer.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/AnimalFarmer.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.beans;
+
+public class AnimalFarmer extends Farmer<Animal>
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/AnimalFarmer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/OuterBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/OuterBean.java 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/OuterBean.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -9,6 +9,16 @@
public class InnerBean
{
+ public InnerBean()
+ {
+
+ }
+
}
+
+ public static class StaticInnerBean
+ {
+
+ }
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/ParameterizedBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/ParameterizedBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/ParameterizedBean.java 2008-10-26 14:25:13 UTC (rev 166)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.beans.broken;
+
+public class ParameterizedBean<T>
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/broken/ParameterizedBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-26 13:34:47 UTC (rev 165)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-26 14:25:13 UTC (rev 166)
@@ -19,6 +19,7 @@
<exclude name="el" />
<exclude name="jms" />
<exclude name="interceptors" />
+ <exclude name="innerClass" />
</run>
</groups>
<packages>
16 years, 1 month
[webbeans-commits] Webbeans SVN: r165 - 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-26 09:34:47 -0400 (Sun, 26 Oct 2008)
New Revision: 165
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeTest.java
Removed:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/APITypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApiTypeTest.java
Log:
Stupid case names
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/APITypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/APITypeTest.java 2008-10-26 13:33:12 UTC (rev 164)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/APITypeTest.java 2008-10-26 13:34:47 UTC (rev 165)
@@ -1,20 +0,0 @@
-package org.jboss.webbeans.test;
-
-import static org.jboss.webbeans.test.util.Util.createSimpleModel;
-
-import org.jboss.webbeans.model.bean.BeanModel;
-import org.jboss.webbeans.test.beans.Bear;
-import org.testng.annotations.Test;
-
-@SpecVersion("PDR")
-public class ApiTypeTest extends AbstractTest
-{
-
- @Test @SpecAssertion(section="2.2")
- public void testApiTypeContainsObject()
- {
- BeanModel<?, ?> model = createSimpleModel(Bear.class, manager);
- assert model.getApiTypes().contains(Object.class);
- }
-
-}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApiTypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApiTypeTest.java 2008-10-26 13:33:12 UTC (rev 164)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ApiTypeTest.java 2008-10-26 13:34:47 UTC (rev 165)
@@ -1,20 +0,0 @@
-package org.jboss.webbeans.test;
-
-import static org.jboss.webbeans.test.util.Util.createSimpleModel;
-
-import org.jboss.webbeans.model.bean.BeanModel;
-import org.jboss.webbeans.test.beans.Bear;
-import org.testng.annotations.Test;
-
-@SpecVersion("PDR")
-public class ApiTypeTest extends AbstractTest
-{
-
- @Test @SpecAssertion(section="2.2")
- public void testApiTypeContainsObject()
- {
- BeanModel<?, ?> model = createSimpleModel(Bear.class, manager);
- assert model.getApiTypes().contains(Object.class);
- }
-
-}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeTest.java 2008-10-26 13:34:47 UTC (rev 165)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test;
+
+import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+
+import org.jboss.webbeans.introspector.SimpleAnnotatedType;
+import org.jboss.webbeans.model.bean.SimpleBeanModel;
+import org.jboss.webbeans.test.beans.Haddock;
+import org.testng.annotations.Test;
+
+public class TypeTest extends AbstractTest
+{
+
+ @Test @SpecAssertion(section="2.6.3")
+ public void testDefaultNamed()
+ {
+ SimpleBeanModel<Haddock> haddock = new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), manager);
+ assert haddock.getName() != null;
+ assert haddock.getName().equals("haddock");
+ }
+
+}
+
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/TypeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 1 month
[webbeans-commits] Webbeans SVN: r164 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans/model/bean and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-10-26 09:33:12 -0400 (Sun, 26 Oct 2008)
New Revision: 164
Removed:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goat.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goose.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/model/bean/SimpleBeanModel.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanLifecycleTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Donkey.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Duck.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Sheep.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Turkey.java
ri/trunk/webbeans-ri/testng.xml
Log:
Update tests for section 3.2 to PDR
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-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -143,7 +143,7 @@
{
if (Reflections.isAbstract(getType()))
{
- throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
+ throw new DefinitionException("Web Bean implementation class " + type + " cannot be declared abstract");
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/SimpleBeanModel.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -5,6 +5,7 @@
import java.util.logging.Logger;
import javax.webbeans.BindingType;
+import javax.webbeans.DefinitionException;
import javax.webbeans.Initializer;
import org.jboss.webbeans.ManagerImpl;
@@ -59,7 +60,7 @@
{
if (type.isMemberClass())
{
- throw new RuntimeException("Simple Web Bean " + type + " cannot be an inner class");
+ throw new DefinitionException("Simple Web Bean " + type + " cannot be an inner class");
}
}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorModelTest.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorModelTest.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,155 +0,0 @@
-package org.jboss.webbeans.test;
-
-import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
-
-import javax.webbeans.Current;
-
-import org.jboss.webbeans.injectable.SimpleConstructor;
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.bean.SimpleBeanModel;
-import org.jboss.webbeans.test.annotations.Synchronous;
-import org.jboss.webbeans.test.beans.Chicken;
-import org.jboss.webbeans.test.beans.Donkey;
-import org.jboss.webbeans.test.beans.Duck;
-import org.jboss.webbeans.test.beans.Goat;
-import org.jboss.webbeans.test.beans.Goose;
-import org.jboss.webbeans.test.beans.Order;
-import org.jboss.webbeans.test.beans.Sheep;
-import org.jboss.webbeans.test.beans.Turkey;
-import org.jboss.webbeans.util.Reflections;
-import org.testng.annotations.Test;
-
-@SpecVersion("20080925")
-public class ConstructorModelTest extends AbstractTest
-{
-
- @Test
- public void testImplicitConstructor()
- {
- SimpleConstructor<Order> constructor = new SimpleBeanModel<Order>(new SimpleAnnotatedType<Order>(Order.class), getEmptyAnnotatedType(Order.class), manager).getConstructor();
- assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
- assert constructor.getParameters().size() == 0;
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testSingleConstructor()
- {
- SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor();
- assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Donkey.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 1;
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[0].equals(String.class);
- assert constructor.getParameters().size() == 1;
- assert constructor.getParameters().get(0).getType().equals(String.class);
- assert constructor.getParameters().get(0).getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(constructor.getParameters().get(0).getBindingTypes(), Current.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testInitializerAnnotatedConstructor()
- {
- SimpleConstructor<Sheep> constructor = new SimpleBeanModel<Sheep>(new SimpleAnnotatedType<Sheep>(Sheep.class), getEmptyAnnotatedType(Sheep.class), manager).getConstructor();
- assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Sheep.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 2;
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[0].equals(String.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[1].equals(Double.class);
- assert constructor.getParameters().size() == 2;
- assert constructor.getParameters().get(0).getType().equals(String.class);
- assert constructor.getParameters().get(1).getType().equals(Double.class);
- assert constructor.getParameters().get(0).getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(constructor.getParameters().get(0).getBindingTypes(), Current.class);
- assert constructor.getParameters().get(1).getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(constructor.getParameters().get(1).getBindingTypes(), Current.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testBindingTypeAnnotatedConstructor()
- {
- SimpleConstructor<Duck> constructor = new SimpleBeanModel<Duck>(new SimpleAnnotatedType<Duck>(Duck.class), getEmptyAnnotatedType(Duck.class), manager).getConstructor();
- assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Duck.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 2;
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[0].equals(String.class);
- assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[1].equals(Integer.class);
- assert constructor.getParameters().size() == 2;
- assert constructor.getParameters().get(0).getType().equals(String.class);
- assert constructor.getParameters().get(1).getType().equals(Integer.class);
- assert constructor.getParameters().get(0).getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(constructor.getParameters().get(0).getBindingTypes(), Current.class);
- assert constructor.getParameters().get(1).getBindingTypes().size() == 1;
- assert Reflections.annotationSetMatches(constructor.getParameters().get(1).getBindingTypes(), Synchronous.class);
- }
-
- @Test
- public void testTooManyInitializerAnnotatedConstructor()
- {
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- @Test
- public void testTooManyConstructors()
- {
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Turkey>(new SimpleAnnotatedType<Turkey>(Turkey.class), getEmptyAnnotatedType(Turkey.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- @Test
- public void testTooManyBindingTypeAnnotatedConstructor()
- {
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Goat>(new SimpleAnnotatedType<Goat>(Goat.class), getEmptyAnnotatedType(Goat.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- @Test
- public void testBindingTypeAndInitializerAnnotatedConstructor()
- {
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Goose>(new SimpleAnnotatedType<Goose>(Goose.class), getEmptyAnnotatedType(Goose.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- @Test @SpecAssertion(section="2.7.2")
- public void testStereotypeOnConstructor()
- {
- assert false;
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -87,7 +87,7 @@
assert cod.getName().equals("whitefish");
}
- @Test @SpecAssertion(section="2.6.3")
+ @Test @SpecAssertion(section={"2.6.3", "3.2.7"})
public void testDefaultNamed()
{
SimpleBeanModel<Haddock> haddock = new SimpleBeanModel<Haddock>(new SimpleAnnotatedType<Haddock>(Haddock.class), getEmptyAnnotatedType(Haddock.class), manager);
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanLifecycleTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanLifecycleTest.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanLifecycleTest.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -5,21 +5,21 @@
public class ProducerExpressionBeanLifecycleTest
{
- @Test(groups={"beanLifecycle", "producerExpression"}) @SpecAssertion(section="3.4")
+ @Test(groups={"beanLifecycle", "producerMethod"}) @SpecAssertion(section="3.4")
public void testNonDependentProducerExpressionThatReturnsNull()
{
// TODO Placeholder
assert false;
}
- @Test(groups={"beanLifecycle", "producerExpression"}) @SpecAssertion(section="3.4")
+ @Test(groups={"beanLifecycle", "producerMethod"}) @SpecAssertion(section="3.4")
public void testDependentProducerExpressionThatReturnsNull()
{
// TODO Placeholder
assert false;
}
- @Test(groups={"beanLifecycle", "producerExpression"}) @SpecAssertion(section="3.4")
+ @Test(groups={"beanLifecycle", "producerMethod"}) @SpecAssertion(section="3.4")
public void testProducerExpressionHasValidRuntimeApiType()
{
// TODO Placeholder
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanModelTest.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ProducerExpressionBeanModelTest.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -5,25 +5,25 @@
public class ProducerExpressionBeanModelTest extends AbstractTest
{
- @Test(groups="producerExpression") @SpecAssertion(section="3.4")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.4")
public void testApiTypes()
{
assert false;
}
- @Test(groups="producerExpression") @SpecAssertion(section="3.4")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.4")
public void testFinalProducerExpression()
{
assert false;
}
- @Test(groups="producerExpression") @SpecAssertion(section="3.4")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.4")
public void testFinalDependentProducerExpression()
{
assert false;
}
- @Test(groups="producerExpression") @SpecAssertion(section="3.4.2")
+ @Test(groups="producerMethod") @SpecAssertion(section="3.4.2")
public void testProducerExpressionCannotHaveDefaultName()
{
assert false;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,116 +1,295 @@
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.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Iterator;
-import javax.webbeans.Dependent;
+import javax.webbeans.DefinitionException;
+import javax.webbeans.NonexistentConstructorException;
+import javax.webbeans.manager.Bean;
-import org.jboss.webbeans.bindings.DependentAnnotationLiteral;
-import org.jboss.webbeans.introspector.AnnotatedType;
+import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
+import org.jboss.webbeans.injectable.InjectableParameter;
+import org.jboss.webbeans.injectable.SimpleConstructor;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
import org.jboss.webbeans.model.bean.SimpleBeanModel;
+import org.jboss.webbeans.test.beans.Animal;
+import org.jboss.webbeans.test.beans.Chicken;
import org.jboss.webbeans.test.beans.Cow;
-import org.jboss.webbeans.test.beans.Horse;
-import org.jboss.webbeans.test.beans.broken.Pig;
+import org.jboss.webbeans.test.beans.DeadlyAnimal;
+import org.jboss.webbeans.test.beans.DeadlySpider;
+import org.jboss.webbeans.test.beans.Donkey;
+import org.jboss.webbeans.test.beans.Duck;
+import org.jboss.webbeans.test.beans.Order;
+import org.jboss.webbeans.test.beans.Sheep;
+import org.jboss.webbeans.test.beans.Spider;
+import org.jboss.webbeans.test.beans.Tarantula;
+import org.jboss.webbeans.test.beans.Turkey;
import org.jboss.webbeans.test.beans.broken.OuterBean.InnerBean;
+import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
import org.testng.annotations.Test;
-@SpecVersion("20080925")
+@SpecVersion("PDR")
public class SimpleBeanModelTest extends AbstractTest
{
- // **** TESTS FOR STEREOTYPES **** //
+ //*** BEAN CLASS CHECKS ****//
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
+ public void testAbstractClassDeclaredInJavaIsNotAllowed()
+ {
+ new SimpleBeanModel<Cow>(new SimpleAnnotatedType<Cow>(Cow.class), getEmptyAnnotatedType(Cow.class), manager);
+ }
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
+ public void testNonStaticInnerClassDeclaredInJavaIsNotAllowed()
+ {
+ new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
+ }
- //*** BEAN CLASS CHECKS ****//
+ @Test @SpecAssertion(section="3.2")
+ public void testStaticInnerClassDeclaredInJavaAllowed()
+ {
+ assert false;
+ }
- @Test
- public void testAbstractClassIsNotAllowed()
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2")
+ public void testParameterizedClassDeclaredInJavaIsNotAllowed()
{
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Cow>(new SimpleAnnotatedType<Cow>(Cow.class), getEmptyAnnotatedType(Cow.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
+
}
- @Test
- public void testInnerClassIsNotAllowed()
+ @Test(expectedExceptions=DefinitionException.class, groups={"interceptors", "decorators"}) @SpecAssertion(section="3.2")
+ public void testClassCannotBeInterceptorAndDecorator()
{
- boolean exception = false;
- try
- {
- new SimpleBeanModel<InnerBean>(new SimpleAnnotatedType<InnerBean>(InnerBean.class), getEmptyAnnotatedType(InnerBean.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
+
}
- @Test
- public void testFinalClassMustBeDependentScoped()
+ @Test(groups="deployment") @SpecAssertion(section="3.2")
+ public void testOnlyOneWebBeanPerAnnotatedClass()
{
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Horse>(new SimpleAnnotatedType<Horse>(Horse.class), getEmptyAnnotatedType(Horse.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Dependent.class, new DependentAnnotationLiteral());
- AnnotatedType<Horse> annotatedItem = new SimpleAnnotatedType<Horse>(Horse.class, annotations);
- try
- {
- new SimpleBeanModel<Horse>(new SimpleAnnotatedType<Horse>(Horse.class), annotatedItem, manager);
- }
- catch (Exception e)
- {
- assert false;
- }
}
- @Test
- public void testClassWithFinalMethodMustBeDependentScoped()
+ @Test @SpecAssertion(section="3.2.2")
+ public void testApiTypes()
{
- boolean exception = false;
- try
- {
- new SimpleBeanModel<Pig>(new SimpleAnnotatedType<Pig>(Pig.class), getEmptyAnnotatedType(Pig.class), manager);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
+ Bean<Tarantula> bean = createSimpleWebBean(Tarantula.class, manager);
+ assert bean.getTypes().size() == 6;
+ assert bean.getTypes().contains(Tarantula.class);
+ assert bean.getTypes().contains(Spider.class);
+ assert bean.getTypes().contains(Animal.class);
+ assert bean.getTypes().contains(Object.class);
+ assert bean.getTypes().contains(DeadlySpider.class);
+ assert bean.getTypes().contains(DeadlyAnimal.class);
+ }
+
+ @Test(groups="producerMethod") @SpecAssertion(section="3.2.4")
+ public void testBeanDeclaredInXmlIgnoresProducerMethodDeclaredInJava()
+ {
+ assert false;
+ }
+
+ @Test(groups="disposalMethod") @SpecAssertion(section="3.2.4")
+ public void testBeanDeclaredInXmlIgnoresDisposalMethodDeclaredInJava()
+ {
+ assert false;
+ }
+
+ @Test(groups="eventbus") @SpecAssertion(section="3.2.4")
+ public void testBeanDeclaredInXmlIgnoresObserverMethodDeclaredInJava()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
+ public void testAbstractClassDeclaredInXmlIsNotAllowed()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
+ public void testNonStaticInnerClassDeclaredInXmlIsNotAllowed()
+ {
+ assert false;
+ }
+
+ @Test @SpecAssertion(section="3.2.4")
+ public void testStaticInnerClassDeclaredInXmlAllowed()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.4")
+ public void testParameterizedClassDeclaredInXmlIsNotAllowed()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class, groups={"interceptors"}) @SpecAssertion(section="3.2.4")
+ public void testClassHasInterceptorInJavaMustHaveInterceptorInXml()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class, groups={"interceptors"}) @SpecAssertion(section="3.2.4")
+ public void testClassHasDecoratorInJavaMustHaveDecoratorInXml()
+ {
+ assert false;
+ }
+
+ @Test @SpecAssertion(section="3.2.5.1")
+ public void testInitializerAnnotatedConstructor()
+ {
+ SimpleConstructor<Sheep> constructor = new SimpleBeanModel<Sheep>(new SimpleAnnotatedType<Sheep>(Sheep.class), getEmptyAnnotatedType(Sheep.class), manager).getConstructor();
+ assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Sheep.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 2;
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[0].equals(String.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes()[1].equals(Double.class);
+ assert constructor.getParameters().size() == 2;
+ assert constructor.getParameters().get(0).getType().equals(String.class);
+ assert constructor.getParameters().get(1).getType().equals(Double.class);
+ assert constructor.getParameters().get(0).getBindingTypes().size() == 1;
+ assert constructor.getParameters().get(0).getBindingTypes().contains(new CurrentAnnotationLiteral());
+ assert constructor.getParameters().get(1).getBindingTypes().size() == 1;
+ assert constructor.getParameters().get(1).getBindingTypes().contains(new CurrentAnnotationLiteral());
+ }
+
+ @Test @SpecAssertion(section="3.2.5.1")
+ public void testImplicitConstructorUsed()
+ {
+ SimpleConstructor<Order> constructor = new SimpleBeanModel<Order>(new SimpleAnnotatedType<Order>(Order.class), getEmptyAnnotatedType(Order.class), manager).getConstructor();
+ assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
+ assert constructor.getParameters().size() == 0;
+ }
+
+ @Test @SpecAssertion(section="3.2.5.1")
+ public void testEmptyConstructorUsed()
+ {
+ SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor(); assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
+ assert constructor.getParameters().size() == 0;
+ }
+
+ @Test @SpecAssertion(section="3.2.5.1")
+ public void testInitializerAnnotatedConstructorUsedOverEmptyConstuctor()
+ {
+ SimpleConstructor<Turkey> constructor = new SimpleBeanModel<Turkey>(new SimpleAnnotatedType<Turkey>(Turkey.class), getEmptyAnnotatedType(Turkey.class), manager).getConstructor();
+ assert constructor.getParameters().size() == 2;
+ Iterator<InjectableParameter<?>> it = constructor.getParameters().iterator();
+ assert it.next().getType().equals(String.class);
+ assert it.next().getType().equals(Integer.class);
+ }
+
+ @Test(expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.5.1")
+ public void testTooManyInitializerAnnotatedConstructor()
+ {
+ new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
+ }
+
+ @Test(expectedExceptions=DefinitionException.class, groups="disposalMethod") @SpecAssertion(section="3.2.5.1")
+ public void testConstructorHasDisposesParameter()
+ {
+ new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
+ }
+
+ @Test(expectedExceptions=DefinitionException.class, groups="eventBus") @SpecAssertion(section="3.2.5.1")
+ public void testConstructorHasObservesParameter()
+ {
+ new SimpleBeanModel<Chicken>(new SimpleAnnotatedType<Chicken>(Chicken.class), getEmptyAnnotatedType(Chicken.class), manager);
+ }
+
+ @Test @SpecAssertion(section="3.2.5.2")
+ public void testImplicitConstructorDeclaredInXmlUsed()
+ {
+ SimpleConstructor<Order> constructor = new SimpleBeanModel<Order>(new SimpleAnnotatedType<Order>(Order.class), getEmptyAnnotatedType(Order.class), manager).getConstructor();
+ assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
+ assert constructor.getParameters().size() == 0;
+ assert false;
+ }
+
+ @Test @SpecAssertion(section="3.2.5.2")
+ public void testEmptyConstructorDeclaredInXmlUsed()
+ {
+ SimpleConstructor<Donkey> constructor = new SimpleBeanModel<Donkey>(new SimpleAnnotatedType<Donkey>(Donkey.class), getEmptyAnnotatedType(Donkey.class), manager).getConstructor(); assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Order.class);
+ assert constructor.getAnnotatedItem().getDelegate().getParameterTypes().length == 0;
+ assert constructor.getParameters().size() == 0;
+ assert false;
+ }
+
+ @Test(expectedExceptions=NonexistentConstructorException.class) @SpecAssertion(section="3.2.5.2")
+ public void testConstructorDeclaredInXmlDoesNotExist()
+ {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Dependent.class, new DependentAnnotationLiteral());
- AnnotatedType<Pig> annotatedItem = new SimpleAnnotatedType<Pig>(Pig.class, annotations);
- try
- {
- new SimpleBeanModel<Pig>(new SimpleAnnotatedType<Pig>(Pig.class), annotatedItem, manager);
- }
- catch (Exception e)
- {
- assert false;
- }
}
+ @Test @SpecAssertion(section="3.2.5.2")
+ public void testConstructorDeclaredInXmlIgnoresBindingTypesDeclaredInJava()
+ {
+
+ }
+ @Test @SpecAssertion(section="3.2.5.3")
+ public void testBindingTypeAnnotatedConstructor()
+ {
+ SimpleConstructor<Duck> constructor = new SimpleBeanModel<Duck>(new SimpleAnnotatedType<Duck>(Duck.class), getEmptyAnnotatedType(Duck.class), manager).getConstructor();
+ assert constructor.getAnnotatedItem().getDelegate().getDeclaringClass().equals(Duck.class);
+ assert constructor.getParameters().size() == 2;
+ Iterator<InjectableParameter<?>> it = constructor.getParameters().iterator();
+ assert it.next().getType().equals(String.class);
+ assert it.next().getType().equals(Integer.class);
+ assert constructor.getParameters().size() == 2;
+ assert constructor.getParameters().get(0).getType().equals(String.class);
+ assert constructor.getParameters().get(1).getType().equals(Integer.class);
+ assert constructor.getParameters().get(0).getBindingTypes().size() == 1;
+ assert constructor.getParameters().get(0).getBindingTypes().contains(new CurrentAnnotationLiteral());
+ assert constructor.getParameters().get(1).getBindingTypes().size() == 1;
+ assert constructor.getParameters().get(1).getBindingTypes().contains(new SynchronousAnnotationLiteral());
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testSpecializedClassInheritsBindingTypes()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testSpecializedClassInheritsName()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testLessSpecializedClassNotInstantiated()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization",expectedExceptions=DefinitionException.class) @SpecAssertion(section="3.2.6")
+ public void testSpecializedClassMustExtendAnotherWebBean()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testSpecializedClassDeclaredInXmlInheritsBindingTypes()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testSpecializedClassDeclaredInXmlInheritsName()
+ {
+ assert false;
+ }
+
+ @Test(groups="specialization") @SpecAssertion(section="3.2.6")
+ public void testLessSpecializedClassDeclaredInXmlNotInstantiated()
+ {
+ assert false;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Donkey.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Donkey.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Donkey.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -6,6 +6,11 @@
public class Donkey
{
+ public Donkey()
+ {
+
+ }
+
public Donkey(String foo)
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Duck.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Duck.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Duck.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,5 +1,6 @@
package org.jboss.webbeans.test.beans;
+import javax.webbeans.Initializer;
import javax.webbeans.Production;
import org.jboss.webbeans.test.annotations.Synchronous;
@@ -7,12 +8,8 @@
@Production
public class Duck
{
-
- public Duck(String foo)
- {
- // TODO Auto-generated constructor stub
- }
+ @Initializer
public Duck(String foo, @Synchronous Integer bar)
{
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goat.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goat.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goat.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,23 +0,0 @@
-package org.jboss.webbeans.test.beans;
-
-import javax.webbeans.Production;
-
-import org.jboss.webbeans.test.annotations.Asynchronous;
-import org.jboss.webbeans.test.annotations.Synchronous;
-
-@Production
-public class Goat
-{
-
- public Goat(@Synchronous String foo)
- {
- // TODO Auto-generated constructor stub
- }
-
- public Goat(@Asynchronous String foo, String bar)
- {
- // TODO Auto-generated constructor stub
- }
-
-
-}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goose.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goose.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Goose.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,24 +0,0 @@
-package org.jboss.webbeans.test.beans;
-
-import javax.webbeans.Initializer;
-import javax.webbeans.Production;
-
-import org.jboss.webbeans.test.annotations.Synchronous;
-
-@Production
-public class Goose
-{
-
- public Goose(@Synchronous String foo)
- {
- // TODO Auto-generated constructor stub
- }
-
- @Initializer
- public Goose(String foo, String bar)
- {
- // TODO Auto-generated constructor stub
- }
-
-
-}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Sheep.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Sheep.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Sheep.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -6,13 +6,7 @@
@Production
public class Sheep
{
-
- public Sheep(String foo)
- {
-
- }
-
@Initializer
public Sheep(String foo, Double bar)
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Turkey.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Turkey.java 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Turkey.java 2008-10-26 13:33:12 UTC (rev 164)
@@ -1,16 +1,18 @@
package org.jboss.webbeans.test.beans;
+import javax.webbeans.Initializer;
import javax.webbeans.Production;
@Production
public class Turkey
{
- public Turkey(String foo)
+ public Turkey()
{
}
+ @Initializer
public Turkey(String foo, Integer bar)
{
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-26 12:34:06 UTC (rev 163)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-26 13:33:12 UTC (rev 164)
@@ -9,7 +9,7 @@
<exclude name="beanLifecycle" />
<exclude name="deployment" />
<exclude name="disposalMethod" />
- <exclude name="producerExpression" />
+ <exclude name="producerMethod" />
<exclude name="eventbus" />
<exclude name="injection" />
<exclude name="contexts" />
16 years, 1 month