Author: pete.muir(a)jboss.org
Date: 2008-07-01 08:54:48 -0400 (Tue, 01 Jul 2008)
New Revision: 30
Added:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cow.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Horse.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Pig.java
Modified:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
Log:
Test component type restrictions
Modified:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
===================================================================
---
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-01
12:49:00 UTC (rev 29)
+++
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-01
12:54:48 UTC (rev 30)
@@ -22,6 +22,7 @@
import org.jboss.webbeans.StereotypeMetaModel;
import org.jboss.webbeans.bindings.ConversationScopedBinding;
import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
import org.jboss.webbeans.bindings.NamedBinding;
import org.jboss.webbeans.bindings.RequestScopedBinding;
import org.jboss.webbeans.bindings.StandardBinding;
@@ -49,11 +50,14 @@
import org.jboss.webbeans.test.components.Chair;
import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
+import org.jboss.webbeans.test.components.Cow;
import org.jboss.webbeans.test.components.Goldfish;
import org.jboss.webbeans.test.components.Gorilla;
import org.jboss.webbeans.test.components.Haddock;
+import org.jboss.webbeans.test.components.Horse;
import org.jboss.webbeans.test.components.Moose;
import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Pig;
import org.jboss.webbeans.test.components.Trout;
import org.jboss.webbeans.test.components.Tuna;
import org.jboss.webbeans.test.mock.MockContainerImpl;
@@ -488,4 +492,74 @@
assert exception;
}
+
+ @Test
+ public void testAbstractClassIsNotAllowed()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentInstanceImpl<Cow>(new ClassAnnotatedItem(Cow.class),
emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testFinalClassMustBeDependentScoped()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentInstanceImpl<Horse>(new ClassAnnotatedItem(Horse.class),
emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Dependent.class, new DependentBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Horse.class, annotations);
+ try
+ {
+ new ComponentInstanceImpl<Horse>(new ClassAnnotatedItem(Horse.class),
annotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ }
+
+ @Test
+ public void testClassWithFinalMethodMustBeDependentScoped()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentInstanceImpl<Pig>(new ClassAnnotatedItem(Pig.class),
emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ Map<Class<? extends Annotation>, Annotation> annotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Dependent.class, new DependentBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Pig.class, annotations);
+ try
+ {
+ new ComponentInstanceImpl<Pig>(new ClassAnnotatedItem(Pig.class),
annotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ }
+
}
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cow.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cow.java
(rev 0)
+++
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cow.java 2008-07-01
12:54:48 UTC (rev 30)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+@Production
+public abstract class Cow
+{
+
+}
Property changes on:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Horse.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Horse.java
(rev 0)
+++
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Horse.java 2008-07-01
12:54:48 UTC (rev 30)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+@Production
+@RequestScoped
+public final class Horse
+{
+
+}
Property changes on:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Horse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Pig.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Pig.java
(rev 0)
+++
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Pig.java 2008-07-01
12:54:48 UTC (rev 30)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+@Production
+@RequestScoped
+public class Pig
+{
+
+ public final void washPig()
+ {
+
+ }
+
+}
Property changes on:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Pig.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date