Author: pete.muir(a)jboss.org
Date: 2008-10-26 08:18:02 -0400 (Sun, 26 Oct 2008)
New Revision: 161
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SpecializationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypesTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/HighlandCow.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Reindeer.java
Removed:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypeModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Gorilla.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
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/AbstractClassBeanModel.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ScopeTypeTest.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/RedSnapper.java
ri/trunk/webbeans-ri/testng.xml
Log:
Update tests and impl for rest of chapter 2 to PDR
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -24,23 +24,33 @@
private boolean beanNameDefaulted;
private Set<Class<?>> requiredTypes;
private Set<Class<? extends Annotation>> supportedScopes;
+ private boolean isDeclaredInXml;
- public MergedStereotypesModel(AnnotatedItem<T, E> annotatedItem,
AnnotatedItem<T, E> xmlAnnotatedItem, ManagerImpl container)
+ public MergedStereotypesModel(AnnotatedItem<T, E> annotatedItem,
AnnotatedItem<T, E> xmlAnnotatedItem, ManagerImpl manager)
{
possibleDeploymentTypes = new HashMap<Class<? extends Annotation>,
Annotation>();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
- // All stereotypes declared in java and xml are merged
- Set<Annotation> stereotypeAnnotations = new HashSet<Annotation>();
- stereotypeAnnotations.addAll(annotatedItem.getAnnotations(Stereotype.class));
- stereotypeAnnotations.addAll(xmlAnnotatedItem.getAnnotations(Stereotype.class));
+ if (xmlAnnotatedItem.getAnnotations(Stereotype.class).size() > 0)
+ {
+ merge(xmlAnnotatedItem.getAnnotations(Stereotype.class), manager);
+ isDeclaredInXml = true;
+ }
+ else
+ {
+ merge(annotatedItem.getAnnotations(Stereotype.class), manager);
+ }
+ }
+
+ private void merge(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
+ {
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
- StereotypeModel<?> stereotype =
container.getModelManager().getStereotype(stereotypeAnnotation.annotationType());
+ StereotypeModel<?> stereotype =
manager.getModelManager().getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new NullPointerException("Stereotype " + stereotypeAnnotation
+ " not registered with container");
@@ -87,4 +97,9 @@
return supportedScopes;
}
+ public boolean isDeclaredInXml()
+ {
+ return isDeclaredInXml;
+ }
+
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -6,6 +6,7 @@
import java.util.Set;
import javax.webbeans.BindingType;
+import javax.webbeans.DefinitionException;
import javax.webbeans.DeploymentType;
import javax.webbeans.InterceptorBindingType;
import javax.webbeans.Named;
@@ -49,7 +50,7 @@
Set<Annotation> bindingTypes =
annotatedClass.getAnnotations(BindingType.class);
if (bindingTypes.size() > 0)
{
- throw new RuntimeException("Cannot declare binding types on a stereotype
" + annotatedClass);
+ throw new DefinitionException("Cannot declare binding types on a stereotype
" + annotatedClass);
}
}
@@ -96,7 +97,7 @@
{
if (!"".equals(annotatedElement.getAnnotation(Named.class).value()))
{
- throw new RuntimeException("Cannot specify a value for a @Named
stereotype " + annotatedElement);
+ throw new DefinitionException("Cannot specify a value for a @Named
stereotype " + annotatedElement);
}
beanNameDefaulted = true;
}
@@ -107,7 +108,7 @@
Set<Annotation> scopeTypes =
annotatedElement.getAnnotations(ScopeType.class);
if (scopeTypes.size() > 1)
{
- throw new RuntimeException("At most one scope type may be specified for
" + annotatedElement);
+ throw new DefinitionException("At most one scope type may be specified for
" + annotatedElement);
}
else if (scopeTypes.size() == 1)
{
@@ -120,7 +121,7 @@
Set<Annotation> deploymentTypes =
annotatedElement.getAnnotations(DeploymentType.class);
if (deploymentTypes.size() > 1)
{
- throw new RuntimeException("At most one deployment type may be specified on
" + annotatedElement);
+ throw new DefinitionException("At most one deployment type may be specified
on " + annotatedElement);
}
else if (deploymentTypes.size() == 1)
{
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
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractBeanModel.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -96,7 +96,7 @@
protected void initBindingTypes()
{
Set<Annotation> xmlBindingTypes =
getXmlAnnotatedItem().getAnnotations(BindingType.class);
- if (xmlBindingTypes.size() > 0)
+ if (xmlBindingTypes.size() > 0 || mergedStereotypes.isDeclaredInXml())
{
// TODO support producer expression default binding type
log.finest("Using binding types " + xmlBindingTypes + " specified
in XML");
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
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/AbstractClassBeanModel.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -3,6 +3,7 @@
import java.util.logging.Logger;
import javax.webbeans.BindingType;
+import javax.webbeans.DefinitionException;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -117,7 +118,7 @@
log.finest("Checking if required type " + requiredType + " is
implemented");
if (!requiredType.isAssignableFrom(type))
{
- throw new RuntimeException("Required type " + requiredType + "
isn't implemented on " + type);
+ throw new DefinitionException("Required type " + requiredType +
" isn't implemented on " + type);
}
}
}
@@ -133,7 +134,7 @@
{
if (!getMergedStereotypes().getSupportedScopes().contains(getScopeType()))
{
- throw new RuntimeException("Scope " + getScopeType() + " is
not an allowed by the stereotype for " + type);
+ throw new DefinitionException("Scope " + getScopeType() + " is
not an allowed by the stereotype for " + type);
}
}
}
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/DeploymentTypeTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -14,6 +14,7 @@
import javax.webbeans.Production;
import javax.webbeans.RequestScoped;
import javax.webbeans.Standard;
+import javax.webbeans.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -23,6 +24,7 @@
import org.jboss.webbeans.test.annotations.FishStereotype;
import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
import org.jboss.webbeans.test.beans.Antelope;
+import org.jboss.webbeans.test.beans.Reindeer;
import org.jboss.webbeans.test.beans.SeaBass;
import org.jboss.webbeans.test.beans.Tuna;
import org.jboss.webbeans.test.beans.broken.BeanWithTooManyDeploymentTypes;
@@ -154,4 +156,11 @@
{
}
+
+ @Test @SpecAssertion(section="2.7.2")
+ public void testWebBeanDeploymentTypeOverridesStereotype()
+ {
+ Bean<Reindeer> bean = createSimpleWebBean(Reindeer.class, manager);
+ assert bean.getDeploymentType().equals(Production.class);
+ }
}
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
11:26:12 UTC (rev 160)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/NameTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -114,7 +114,7 @@
assert trout.getName().equals("seaBass");
}
- @Test @SpecAssertion(section="2.6.3")
+ @Test @SpecAssertion(section={"2.6.3", "2.7"})
public void testSterotypeDefaultsName()
{
BeanModel<?, ?> model = createSimpleModel(RedSnapper.class, manager);
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ScopeTypeTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ScopeTypeTest.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ScopeTypeTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -28,6 +28,7 @@
import org.jboss.webbeans.test.beans.Haddock;
import org.jboss.webbeans.test.beans.Mullet;
import org.jboss.webbeans.test.beans.Order;
+import org.jboss.webbeans.test.beans.RedSnapper;
import org.jboss.webbeans.test.beans.SeaBass;
import org.jboss.webbeans.test.bindings.AnimalStereotypeAnnotationLiteral;
import org.jboss.webbeans.test.bindings.FishStereotypeAnnotationLiteral;
@@ -178,4 +179,11 @@
assert haddock.getScopeType().equals(ApplicationScoped.class);
}
+ @Test @SpecAssertion(section="2.7.2")
+ public void testWebBeanScopeTypeOverridesStereotype()
+ {
+ Bean<RedSnapper> bean = createSimpleWebBean(RedSnapper.class, manager);
+ assert bean.getScopeType().equals(RequestScoped.class);
+ }
+
}
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
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SimpleBeanModelTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -6,30 +6,16 @@
import java.util.HashMap;
import java.util.Map;
-import javax.webbeans.Current;
import javax.webbeans.Dependent;
-import javax.webbeans.Named;
-import javax.webbeans.Production;
-import javax.webbeans.RequestScoped;
-import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
import org.jboss.webbeans.bindings.DependentAnnotationLiteral;
-import org.jboss.webbeans.bindings.NamedAnnotationLiteral;
import org.jboss.webbeans.introspector.AnnotatedType;
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.Chair;
import org.jboss.webbeans.test.beans.Cow;
-import org.jboss.webbeans.test.beans.Goldfish;
-import org.jboss.webbeans.test.beans.Gorilla;
import org.jboss.webbeans.test.beans.Horse;
-import org.jboss.webbeans.test.beans.Order;
-import org.jboss.webbeans.test.beans.broken.Carp;
import org.jboss.webbeans.test.beans.broken.Pig;
import org.jboss.webbeans.test.beans.broken.OuterBean.InnerBean;
-import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
-import org.jboss.webbeans.util.Reflections;
import org.testng.annotations.Test;
@SpecVersion("20080925")
@@ -38,87 +24,8 @@
// **** TESTS FOR STEREOTYPES **** //
- @SuppressWarnings("unchecked")
- @Test @SpecAssertion(section="2.7.3")
- public void testStereotypeDeclaredInXmlAndJava()
- {
- Map<Class<? extends Annotation>, Annotation> orderXmlAnnotations = new
HashMap<Class<? extends Annotation>, Annotation>();
- orderXmlAnnotations.put(Current.class, new CurrentAnnotationLiteral());
- orderXmlAnnotations.put(Synchronous.class, new SynchronousAnnotationLiteral());
- orderXmlAnnotations.put(Named.class, new NamedAnnotationLiteral (){
-
- public String value()
- {
- return "currentSynchronousOrder";
- }
-
- });
- AnnotatedType currentSynchronousOrderAnnotatedItem = new
SimpleAnnotatedType(Order.class, orderXmlAnnotations);
-
- SimpleBeanModel<Order> order = new SimpleBeanModel<Order>(new
SimpleAnnotatedType(Order.class), currentSynchronousOrderAnnotatedItem, manager);
- assert Production.class.equals(order.getDeploymentType());
- assert "currentSynchronousOrder".equals(order.getName());
- assert order.getBindingTypes().size() == 2;
- assert Reflections.annotationSetMatches(order.getBindingTypes(), Current.class,
Synchronous.class);
- assert order.getScopeType().equals(Dependent.class);
- }
- @Test @SpecAssertion(section="2.7.2")
- public void testSingleStereotype()
- {
- SimpleBeanModel<Gorilla> gorilla = new SimpleBeanModel<Gorilla>(new
SimpleAnnotatedType<Gorilla>(Gorilla.class), getEmptyAnnotatedType(Gorilla.class),
manager);
- assert gorilla.getName() == null;
- assert gorilla.getDeploymentType().equals(Production.class);
- assert
gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
- assert gorilla.getScopeType().equals(RequestScoped.class);
- }
- @Test @SpecAssertion(section="2.7.4")
- public void testRequiredTypeIsImplemented()
- {
- try
- {
- new SimpleBeanModel<Gorilla>(new
SimpleAnnotatedType<Gorilla>(Gorilla.class), getEmptyAnnotatedType(Gorilla.class),
manager);
- }
- catch (Exception e)
- {
- assert false;
- }
-
- }
-
- @Test(expectedExceptions=Exception.class) @SpecAssertion(section="2.7.4")
- public void testRequiredTypeIsNotImplemented()
- {
- new SimpleBeanModel<Chair>(new SimpleAnnotatedType<Chair>(Chair.class),
getEmptyAnnotatedType(Chair.class), manager);
- }
-
- @Test @SpecAssertion(section="2.7.4")
- public void testScopeIsSupported()
- {
- try
- {
- new SimpleBeanModel<Goldfish>(new
SimpleAnnotatedType<Goldfish>(Goldfish.class),
getEmptyAnnotatedType(Goldfish.class), manager);
- }
- catch (Exception e)
- {
- assert false;
- }
-
- }
-
- @Test(expectedExceptions=Exception.class) @SpecAssertion(section="2.7.4")
- public void testScopeIsNotSupported()
- {
- new SimpleBeanModel<Carp>(new SimpleAnnotatedType<Carp>(Carp.class),
getEmptyAnnotatedType(Carp.class), manager);
- }
-
- @Test @SpecAssertion(section="2.7.2")
- public void testMultipleStereotypes()
- {
- assert false;
- }
-
//*** BEAN CLASS CHECKS ****//
@Test
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SpecializationTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SpecializationTest.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SpecializationTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test;
+
+import javax.webbeans.InconsistentSpecializationException;
+
+import org.testng.annotations.Test;
+
+public class SpecializationTest
+{
+
+ @Test(expectedExceptions=InconsistentSpecializationException.class,
groups="specialization")
+ public void testInconsistentSpecialization()
+ {
+
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/SpecializationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypeModelTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypeModelTest.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypeModelTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -1,135 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.util.Arrays;
-
-import javax.webbeans.RequestScoped;
-
-import org.jboss.webbeans.introspector.SimpleAnnotatedType;
-import org.jboss.webbeans.model.StereotypeModel;
-import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
-import org.jboss.webbeans.test.annotations.AnimalStereotype;
-import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
-import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
-import org.jboss.webbeans.test.annotations.broken.StereotypeWithBindingTypes;
-import org.jboss.webbeans.test.annotations.broken.StereotypeWithNonEmptyNamed;
-import org.jboss.webbeans.test.annotations.broken.StereotypeWithTooManyDeploymentTypes;
-import org.jboss.webbeans.test.annotations.broken.StereotypeWithTooManyScopeTypes;
-import org.jboss.webbeans.test.beans.Animal;
-import org.jboss.webbeans.test.beans.Order;
-import org.testng.annotations.Test;
-
-@SpecVersion("20080925")
-public class StereotypeModelTest
-{
-
- @Test @SpecAssertion(section="2.7.1")
- public void testHasCorrectTarget()
- {
- assert false;
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testHasCorrectRetention()
- {
- assert false;
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testHasStereotypeAnnotation()
- {
- assert false;
- }
-
- @Test
- public void testAnimalStereotype()
- {
- StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
- assert
animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
- assert animalStereotype.getInterceptorBindings().size() == 0;
- assert animalStereotype.getRequiredTypes().size() == 1;
- assert animalStereotype.getRequiredTypes().contains(Animal.class);
- assert animalStereotype.getSupportedScopes().size() == 0;
- assert !animalStereotype.isBeanNameDefaulted();
- assert animalStereotype.getDefaultDeploymentType() == null;
- }
-
- @Test
- public void testAnimalOrderStereotype()
- {
- StereotypeModel<AnimalOrderStereotype> animalStereotype = new
StereotypeModel<AnimalOrderStereotype>(new
SimpleAnnotatedType<AnimalOrderStereotype>(AnimalOrderStereotype.class));
- assert animalStereotype.getDefaultScopeType() == null;
- assert animalStereotype.getInterceptorBindings().size() == 0;
- assert animalStereotype.getRequiredTypes().size() == 2;
- Class<?> [] requiredTypes = {Animal.class, Order.class};
- assert
animalStereotype.getRequiredTypes().containsAll(Arrays.asList(requiredTypes));
- assert animalStereotype.getSupportedScopes().size() == 0;
- assert !animalStereotype.isBeanNameDefaulted();
- assert animalStereotype.getDefaultDeploymentType() == null;
- }
-
- @Test
- public void testRequestScopedAnimalStereotype()
- {
- StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new
StereotypeModel<RequestScopedAnimalStereotype>(new
SimpleAnnotatedType<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class));
- assert animalStereotype.getDefaultScopeType() == null;
- assert animalStereotype.getInterceptorBindings().size() == 0;
- assert animalStereotype.getRequiredTypes().size() == 1;
- assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
- assert animalStereotype.getSupportedScopes().size() == 1;
- assert animalStereotype.getSupportedScopes().contains(RequestScoped.class);
- assert !animalStereotype.isBeanNameDefaulted();
- assert animalStereotype.getDefaultDeploymentType() == null;
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testStereotypeWithScopeType()
- {
- StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
- assert
animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testStereotypeWithoutScopeType()
- {
- StereotypeModel<HornedMammalStereotype> animalStereotype = new
StereotypeModel<HornedMammalStereotype>(new
SimpleAnnotatedType<HornedMammalStereotype>(HornedMammalStereotype.class));
- assert animalStereotype.getDefaultScopeType() == null;
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testStereotypeWithoutInterceptors()
- {
- StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
- assert animalStereotype.getInterceptorBindings().size() == 0;
- }
-
- @Test @SpecAssertion(section="2.7.1")
- public void testStereotypeWithInterceptors()
- {
- assert false;
- }
-
- @Test(expectedExceptions=RuntimeException.class)
@SpecAssertion(section="2.7.1")
- public void testStereotypeWithTooManyScopeTypes()
- {
- new StereotypeModel<StereotypeWithTooManyScopeTypes>(new
SimpleAnnotatedType<StereotypeWithTooManyScopeTypes>(StereotypeWithTooManyScopeTypes.class));
- }
-
- @Test(expectedExceptions=RuntimeException.class)
@SpecAssertion(section="2.7.1")
- public void testStereotypeWithTooManyDeploymentTypes()
- {
- new StereotypeModel<StereotypeWithTooManyDeploymentTypes>(new
SimpleAnnotatedType<StereotypeWithTooManyDeploymentTypes>(StereotypeWithTooManyDeploymentTypes.class));
- }
-
- @Test(expectedExceptions=RuntimeException.class)
@SpecAssertion(section="2.7.1")
- public void testStereotypeWithNonEmptyNamed()
- {
- new StereotypeModel<StereotypeWithNonEmptyNamed>(new
SimpleAnnotatedType<StereotypeWithNonEmptyNamed>(StereotypeWithNonEmptyNamed.class));
- }
-
- @Test(expectedExceptions=RuntimeException.class)
@SpecAssertion(section="2.7.1")
- public void testStereotypeWithBindingTypes()
- {
- new StereotypeModel<StereotypeWithBindingTypes>(new
SimpleAnnotatedType<StereotypeWithBindingTypes>(StereotypeWithBindingTypes.class));
- }
-
-}
Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypesTest.java
(from rev 154,
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypeModelTest.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypesTest.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypesTest.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -0,0 +1,220 @@
+package org.jboss.webbeans.test;
+
+import static org.jboss.webbeans.test.util.Util.createSimpleModel;
+import static org.jboss.webbeans.test.util.Util.getEmptyAnnotatedType;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.webbeans.DefinitionException;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.introspector.AnnotatedType;
+import org.jboss.webbeans.introspector.SimpleAnnotatedType;
+import org.jboss.webbeans.model.StereotypeModel;
+import org.jboss.webbeans.model.bean.SimpleBeanModel;
+import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.annotations.Tame;
+import org.jboss.webbeans.test.annotations.broken.StereotypeWithBindingTypes;
+import org.jboss.webbeans.test.annotations.broken.StereotypeWithNonEmptyNamed;
+import org.jboss.webbeans.test.annotations.broken.StereotypeWithTooManyDeploymentTypes;
+import org.jboss.webbeans.test.annotations.broken.StereotypeWithTooManyScopeTypes;
+import org.jboss.webbeans.test.beans.Animal;
+import org.jboss.webbeans.test.beans.Chair;
+import org.jboss.webbeans.test.beans.Goldfish;
+import org.jboss.webbeans.test.beans.HighlandCow;
+import org.jboss.webbeans.test.beans.Order;
+import org.jboss.webbeans.test.beans.broken.Carp;
+import org.jboss.webbeans.test.bindings.HornedMamalStereotypeAnnotationLiteral;
+import org.jboss.webbeans.test.bindings.SynchronousAnnotationLiteral;
+import org.testng.annotations.Test;
+
+@SpecVersion("PDR")
+public class StereotypesTest extends AbstractTest
+{
+
+ @Test(groups="annotationDefinition",
expectedExceptions=DefinitionException.class) @SpecAssertion(section="2.7.1")
+ public void testHasCorrectTarget()
+ {
+ assert false;
+ }
+
+ @Test(groups="annotationDefinition",
expectedExceptions=DefinitionException.class) @SpecAssertion(section="2.7.1")
+ public void testHasCorrectRetention()
+ {
+ assert false;
+ }
+
+ @Test(groups="annotationDefinition",
expectedExceptions=DefinitionException.class) @SpecAssertion(section="2.7.1")
+ public void testHasStereotypeAnnotation()
+ {
+ assert false;
+ }
+
+ @Test
+ public void testAnimalStereotype()
+ {
+ StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
+ assert
animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 1;
+ assert animalStereotype.getRequiredTypes().contains(Animal.class);
+ assert animalStereotype.getSupportedScopes().size() == 0;
+ assert !animalStereotype.isBeanNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+ @Test
+ public void testAnimalOrderStereotype()
+ {
+ StereotypeModel<AnimalOrderStereotype> animalStereotype = new
StereotypeModel<AnimalOrderStereotype>(new
SimpleAnnotatedType<AnimalOrderStereotype>(AnimalOrderStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 2;
+ Class<?> [] requiredTypes = {Animal.class, Order.class};
+ assert
animalStereotype.getRequiredTypes().containsAll(Arrays.asList(requiredTypes));
+ assert animalStereotype.getSupportedScopes().size() == 0;
+ assert !animalStereotype.isBeanNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+ @Test
+ public void testRequestScopedAnimalStereotype()
+ {
+ StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new
StereotypeModel<RequestScopedAnimalStereotype>(new
SimpleAnnotatedType<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 1;
+ assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+ assert animalStereotype.getSupportedScopes().size() == 1;
+ assert animalStereotype.getSupportedScopes().contains(RequestScoped.class);
+ assert !animalStereotype.isBeanNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+ @Test @SpecAssertion(section="2.7.1")
+ public void testStereotypeWithScopeType()
+ {
+ StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
+ assert
animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test @SpecAssertion(section="2.7.1")
+ public void testStereotypeWithoutScopeType()
+ {
+ StereotypeModel<HornedMammalStereotype> animalStereotype = new
StereotypeModel<HornedMammalStereotype>(new
SimpleAnnotatedType<HornedMammalStereotype>(HornedMammalStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ }
+
+ @Test @SpecAssertion(section="2.7.1")
+ public void testStereotypeWithoutInterceptors()
+ {
+ StereotypeModel<AnimalStereotype> animalStereotype = new
StereotypeModel<AnimalStereotype>(new
SimpleAnnotatedType<AnimalStereotype>(AnimalStereotype.class));
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ }
+
+ @Test(groups="interceptors") @SpecAssertion(section="2.7.1")
+ public void testStereotypeWithInterceptors()
+ {
+ assert false;
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.1")
+ public void testStereotypeWithTooManyScopeTypes()
+ {
+ new StereotypeModel<StereotypeWithTooManyScopeTypes>(new
SimpleAnnotatedType<StereotypeWithTooManyScopeTypes>(StereotypeWithTooManyScopeTypes.class));
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.1")
+ public void testStereotypeWithTooManyDeploymentTypes()
+ {
+ new StereotypeModel<StereotypeWithTooManyDeploymentTypes>(new
SimpleAnnotatedType<StereotypeWithTooManyDeploymentTypes>(StereotypeWithTooManyDeploymentTypes.class));
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.1")
+ public void testStereotypeWithNonEmptyNamed()
+ {
+ new StereotypeModel<StereotypeWithNonEmptyNamed>(new
SimpleAnnotatedType<StereotypeWithNonEmptyNamed>(StereotypeWithNonEmptyNamed.class));
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.1")
+ public void testStereotypeWithBindingTypes()
+ {
+ new StereotypeModel<StereotypeWithBindingTypes>(new
SimpleAnnotatedType<StereotypeWithBindingTypes>(StereotypeWithBindingTypes.class));
+ }
+
+ @Test @SpecAssertion(section={"2.7.2", "2.7.4"})
+ public void testMultipleStereotypes()
+ {
+ SimpleBeanModel<HighlandCow> highlandCow = new
SimpleBeanModel<HighlandCow>(new
SimpleAnnotatedType<HighlandCow>(HighlandCow.class),
getEmptyAnnotatedType(HighlandCow.class), manager);
+ assert highlandCow.getName() == null;
+ assert
highlandCow.getBindingTypes().iterator().next().annotationType().equals(Tame.class);
+ assert highlandCow.getScopeType().equals(RequestScoped.class);
+ assert highlandCow.getMergedStereotypes().getRequiredTypes().size() == 1;
+ assert
highlandCow.getMergedStereotypes().getRequiredTypes().contains(Animal.class);
+ assert highlandCow.getMergedStereotypes().getSupportedScopes().size() == 1;
+ assert
highlandCow.getMergedStereotypes().getSupportedScopes().contains(RequestScoped.class);
+ assert highlandCow.getDeploymentType().equals(HornedAnimalDeploymentType.class);
+ }
+
+ @Test @SpecAssertion(section="2.7.3")
+ public void testStereotypeDeclaredInXmlIgnoresJavaStereotypes()
+ {
+ Map<Class<? extends Annotation>, Annotation> cooXmlAnnotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ cooXmlAnnotations.put(HornedMammalStereotype.class, new
HornedMamalStereotypeAnnotationLiteral());
+ AnnotatedType<HighlandCow> cooXmlAnnotatedItem = new
SimpleAnnotatedType<HighlandCow>(HighlandCow.class, cooXmlAnnotations);
+
+ SimpleBeanModel<HighlandCow> coo = createSimpleModel(HighlandCow.class,
cooXmlAnnotatedItem, manager);
+ assert coo.getDeploymentType().equals(HornedAnimalDeploymentType.class);
+ assert coo.getScopeType().equals(RequestScoped.class);
+ assert coo.getMergedStereotypes().getRequiredTypes().size() == 1;
+ assert coo.getMergedStereotypes().getRequiredTypes().contains(Animal.class);
+ assert coo.getMergedStereotypes().getSupportedScopes().size() == 0;
+ }
+
+ @Test @SpecAssertion(section="2.7.3")
+ public void testStereotypeDeclaredInXmlIgnoresJavaBindingTypes()
+ {
+ Map<Class<? extends Annotation>, Annotation> cooXmlAnnotations = new
HashMap<Class<? extends Annotation>, Annotation>();
+ cooXmlAnnotations.put(HornedMammalStereotype.class, new
HornedMamalStereotypeAnnotationLiteral());
+ cooXmlAnnotations.put(Synchronous.class, new SynchronousAnnotationLiteral());
+ AnnotatedType<HighlandCow> cooXmlAnnotatedItem = new
SimpleAnnotatedType<HighlandCow>(HighlandCow.class, cooXmlAnnotations);
+
+ SimpleBeanModel<HighlandCow> coo = createSimpleModel(HighlandCow.class,
cooXmlAnnotatedItem, manager);
+ assert coo.getBindingTypes().size() == 1;
+ assert coo.getBindingTypes().contains(new SynchronousAnnotationLiteral());
+
+ }
+
+ @Test(a)SpecAssertion(section="2.7.4")
+ public void testRequiredTypeIsImplemented()
+ {
+ new SimpleBeanModel<HighlandCow>(new
SimpleAnnotatedType<HighlandCow>(HighlandCow.class),
getEmptyAnnotatedType(HighlandCow.class), manager);
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.4")
+ public void testRequiredTypeIsNotImplemented()
+ {
+ new SimpleBeanModel<Chair>(new SimpleAnnotatedType<Chair>(Chair.class),
getEmptyAnnotatedType(Chair.class), manager);
+ }
+
+ @Test @SpecAssertion(section="2.7.4")
+ public void testScopeIsSupported()
+ {
+ new SimpleBeanModel<Goldfish>(new
SimpleAnnotatedType<Goldfish>(Goldfish.class),
getEmptyAnnotatedType(Goldfish.class), manager);
+ }
+
+ @Test(expectedExceptions=DefinitionException.class)
@SpecAssertion(section="2.7.4")
+ public void testScopeIsNotSupported()
+ {
+ new SimpleBeanModel<Carp>(new SimpleAnnotatedType<Carp>(Carp.class),
getEmptyAnnotatedType(Carp.class), manager);
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/StereotypesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Gorilla.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Gorilla.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Gorilla.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -1,12 +0,0 @@
-package org.jboss.webbeans.test.beans;
-
-import javax.webbeans.Production;
-
-import org.jboss.webbeans.test.annotations.AnimalStereotype;
-
-@AnimalStereotype
-@Production
-public class Gorilla implements Animal
-{
-
-}
Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/HighlandCow.java
(from rev 154,
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Gorilla.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/HighlandCow.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/HighlandCow.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.Tame;
+
+@HornedMammalStereotype
+@RequestScopedAnimalStereotype
+@RequestScoped
+@Tame
+public class HighlandCow implements Animal
+{
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/HighlandCow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/RedSnapper.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/RedSnapper.java 2008-10-26
11:26:12 UTC (rev 160)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/RedSnapper.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -1,8 +1,11 @@
package org.jboss.webbeans.test.beans;
+import javax.webbeans.RequestScoped;
+
import org.jboss.webbeans.test.annotations.FishStereotype;
@FishStereotype
+@RequestScoped
public class RedSnapper implements Animal
{
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Reindeer.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Reindeer.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Reindeer.java 2008-10-26
12:18:02 UTC (rev 161)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+
+@HornedMammalStereotype
+@Production
+public class Reindeer implements Animal
+{
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/Reindeer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/testng.xml
===================================================================
--- ri/trunk/webbeans-ri/testng.xml 2008-10-26 11:26:12 UTC (rev 160)
+++ ri/trunk/webbeans-ri/testng.xml 2008-10-26 12:18:02 UTC (rev 161)
@@ -18,6 +18,7 @@
<exclude name="webbeansxml" />
<exclude name="el" />
<exclude name="jms" />
+ <exclude name="interceptors" />
</run>
</groups>
<packages>