Author: dallen6
Date: 2009-01-29 08:33:26 -0500 (Thu, 29 Jan 2009)
New Revision: 1283
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeA.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeABinding.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeB.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeBBinding.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeC.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeCBinding.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java
Log:
Added a few more test implementations for EventTest and fixed a bug with observer
resolution.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-29
10:11:32 UTC (rev 1282)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -24,6 +24,7 @@
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -228,6 +229,11 @@
throw new IllegalArgumentException("Not a binding type " +
annotation);
}
}
+ HashSet<Annotation> bindingAnnotations = new
HashSet<Annotation>(Arrays.asList(bindings));
+ if (bindingAnnotations.size() < bindings.length)
+ {
+ throw new DuplicateBindingTypeException("Duplicate binding types: " +
bindings);
+ }
for (Type type : element.getActualTypeArguments())
{
if (type instanceof WildcardType)
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeA.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeA.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeA.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface BindingTypeA
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeA.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeABinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeABinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeABinding.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,5 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import javax.inject.AnnotationLiteral;
+
+public class BindingTypeABinding extends AnnotationLiteral<BindingTypeA> implements
BindingTypeA {}
\ No newline at end of file
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeABinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeB.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeB.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeB.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface BindingTypeB
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeB.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeBBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeBBinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeBBinding.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,5 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import javax.inject.AnnotationLiteral;
+
+public class BindingTypeBBinding extends AnnotationLiteral<BindingTypeB> implements
BindingTypeB {}
\ No newline at end of file
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeBBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeC.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeC.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeC.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface BindingTypeC
+{
+ public String value();
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeC.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeCBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeCBinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeCBinding.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.tck.unit.event;
+
+import javax.inject.AnnotationLiteral;
+
+public class BindingTypeCBinding extends AnnotationLiteral<BindingTypeC> implements
BindingTypeC
+{
+
+ private String stringValue;
+
+ public BindingTypeCBinding(String value)
+ {
+ this.stringValue = value;
+ }
+
+ @Override
+ public String value()
+ {
+ return this.stringValue;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/BindingTypeCBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java 2009-01-29
10:11:32 UTC (rev 1282)
+++
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/event/EventTest.java 2009-01-29
13:33:26 UTC (rev 1283)
@@ -25,7 +25,7 @@
* @author Nicklas Karlsson
* @author David Allen
*
- * Spec version: PRD2
+ * Spec version: PRD2
*/
public class EventTest extends AbstractTest
{
@@ -67,6 +67,16 @@
}
}
+ public static class AnotherListObserver implements
Observer<ArrayList<Integer>>
+ {
+ public boolean wasNotified = false;
+
+ public void notify(ArrayList<Integer> event)
+ {
+ wasNotified = true;
+ }
+ }
+
public static class AnObserverWithException implements Observer<AnEventType>
{
public boolean wasNotified = false;
@@ -848,25 +858,41 @@
assert false;
}
- @Test(groups = { "stub", "events" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.7")
public void testEventObjectContainsTypeVariablesWhenResolvingFails()
{
- assert false;
+ eventObjectContainsTypeVariables(new ArrayList<String>());
}
- @Test(groups = { "stub", "events" })
+ private <E> void eventObjectContainsTypeVariables(ArrayList<E>
eventToFire)
+ {
+ @SuppressWarnings("unused")
+ Set<?> resolvedObservers = manager.resolveObservers(eventToFire);
+ }
+
+ @Test(groups = { "broken", "events" }, expectedExceptions = {
IllegalArgumentException.class })
@SpecAssertion(section = "7.7")
public void testEventObjectContainsWildcardsWhenResolvingFails()
{
- assert false;
+ eventObjectContainsWildcards(new ArrayList<String>());
}
- @Test(groups = { "stub", "events" })
+ private void eventObjectContainsWildcards(ArrayList<? extends Object>
eventToFire)
+ {
+ @SuppressWarnings("unused")
+ //TODO There does not seem to be a way to get wildcarded types pass through
+ Set<?> resolvedObservers = manager.resolveObservers(eventToFire);
+ }
+
+ @Test(groups = { "events" }, expectedExceptions = {
DuplicateBindingTypeException.class })
@SpecAssertion(section = "7.7")
public void testDuplicateBindingTypesWhenResolvingFails()
{
- assert false;
+ AnObserver observer = new AnObserver();
+ manager.addObserver(observer, AnEventType.class, new BindingTypeABinding());
+ @SuppressWarnings("unused")
+ Set<Observer<AnEventType>> resolvedObservers =
manager.resolveObservers(new AnEventType(), new BindingTypeABinding(), new
BindingTypeABinding());
}
@Test(groups = { "events" }, expectedExceptions = {
IllegalArgumentException.class })
@@ -893,34 +919,48 @@
assert emptyObserverSet.isEmpty();
}
- @Test(groups = { "stub", "events" })
+ @Test(groups = { "broken", "events" })
@SpecAssertion(section = "7.7")
public void testResolvingChecksTypeParameters()
{
AListObserver observer = new AListObserver();
+ AnotherListObserver anotherObserver = new AnotherListObserver();
manager.addObserver(observer, new TypeLiteral<ArrayList<String>>()
{
});
- Set<Observer<ArrayList<String>>> resolvedObservers =
manager.resolveObservers(new ArrayList<String>(), new
AnimalStereotypeAnnotationLiteral());
- assert !resolvedObservers.isEmpty();
+ manager.addObserver(anotherObserver, new
TypeLiteral<ArrayList<Integer>>()
+ {
+ });
+ Set<Observer<ArrayList<String>>> resolvedObservers =
manager.resolveObservers(new ArrayList<String>());
+ assert resolvedObservers.size() == 1;
}
- @Test(groups = { "stub", "events" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.7")
public void testResolvingChecksBindingTypes()
{
- assert false;
+ AnObserver observer = new AnObserver();
+ AnObserver anotherObserver = new AnObserver();
+ manager.addObserver(observer, AnEventType.class, new BindingTypeABinding());
+ manager.addObserver(anotherObserver, AnEventType.class, new
BindingTypeBBinding());
+ Set<Observer<AnEventType>> resolvedObservers =
manager.resolveObservers(new AnEventType(), new BindingTypeABinding());
+ assert resolvedObservers.size() == 1;
}
- @Test(groups = { "stub", "events" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.7")
public void testResolvingChecksBindingTypeMembers()
{
- assert false;
+ AnObserver observer = new AnObserver();
+ AnObserver anotherObserver = new AnObserver();
+ manager.addObserver(observer, AnEventType.class, new
BindingTypeCBinding("first-observer"));
+ manager.addObserver(anotherObserver, AnEventType.class, new
BindingTypeCBinding("second-observer"));
+ Set<Observer<AnEventType>> resolvedObservers =
manager.resolveObservers(new AnEventType(), new
BindingTypeCBinding("first-observer"));
+ assert resolvedObservers.size() == 1;
}
- @Test
- @SpecAssertion(section = "???")
+ @Test(groups = { "events", "inheritance" })
+ @SpecAssertion(section = "4.")
public void testNonStaticObserverMethodNotInherited()
{
deployBeans(LazyFarmer.class);