[webbeans-commits] Webbeans SVN: r823 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/bootstrap and 4 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Jan 8 02:41:03 EST 2009
Author: nickarls
Date: 2009-01-08 02:41:03 -0500 (Thu, 08 Jan 2009)
New Revision: 823
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewEnterpriseBeanTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewSimpleBeanTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedEnterpriseBean.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedSimpleBean.java
Removed:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewBeanTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedBean.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.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/newbean/invalid/NewAndOtherBindingType.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedConstructorParameter.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedField.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedInitializerParameter.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedProducerParameter.java
Log:
Starting on NewEnterpriseBean
Fix tests (every registered EJB now adds two beans)
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -0,0 +1,80 @@
+package org.jboss.webbeans.bean;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.webbeans.Dependent;
+import javax.webbeans.Standard;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.binding.NewBinding;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedField;
+import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+
+public class NewEnterpriseBean<T> extends EnterpriseBean<T>
+{
+ private static Set<Annotation> NEW_BINDING_SET = new HashSet<Annotation>(Arrays.asList(new NewBinding()));
+
+ public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager)
+ {
+ return new NewEnterpriseBean<T>(clazz, manager);
+ }
+
+ public static <T> NewEnterpriseBean<T> of(Class<T> clazz, ManagerImpl manager)
+ {
+ return of(AnnotatedClassImpl.of(clazz), manager);
+ }
+
+ protected NewEnterpriseBean(AnnotatedClass<T> type, ManagerImpl manager)
+ {
+ super(type, manager);
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Standard.class;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<AnnotatedMethod<Object>> getObserverMethods()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<AnnotatedField<Object>> getProducerFields()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<AnnotatedMethod<Object>> getProducerMethods()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<Annotation> getBindingTypes()
+ {
+ return NEW_BINDING_SET;
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -40,6 +40,7 @@
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.EventBean;
import org.jboss.webbeans.bean.InstanceBean;
+import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.ProducerFieldBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
@@ -201,6 +202,7 @@
if (getManager().getEjbDescriptorCache().containsKey(clazz))
{
createBean(EnterpriseBean.of(annotatedClass, getManager()), beans);
+ beans.add(NewEnterpriseBean.of(annotatedClass, manager));
}
else if (isTypeSimpleWebBean(clazz))
{
Modified: 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 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventBusTest.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -326,7 +326,7 @@
webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(Pomeranian.class));
webBeansBootstrap.boot();
List<Bean<?>> beans = manager.getBeans();
- assert beans.size() == 1 + BUILT_IN_BEANS;
+ assert beans.size() == 2 + BUILT_IN_BEANS;
Set<Observer<String>> observers = manager.resolveObservers("An event");
assert observers.size() == 2;
}
@@ -338,7 +338,7 @@
webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(TibetanTerrier.class));
webBeansBootstrap.boot();
List<Bean<?>> beans = manager.getBeans();
- assert beans.size() == 1 + BUILT_IN_BEANS;
+ assert beans.size() == 2 + BUILT_IN_BEANS;
Set<Observer<String>> observers = manager.resolveObservers("An event");
assert observers.size() == 1;
}
@@ -381,7 +381,7 @@
webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(Pomeranian.class));
webBeansBootstrap.boot();
List<Bean<?>> beans = manager.getBeans();
- assert beans.size() == 1 + BUILT_IN_BEANS;
+ assert beans.size() == 2 + BUILT_IN_BEANS;
// Resolve registered observers with an event containing no binding types
Set<Observer<String>> resolvedObservers = manager.resolveObservers("A new event");
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewBeanTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewBeanTest.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewBeanTest.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -1,440 +0,0 @@
-package org.jboss.webbeans.test.newbean;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import javax.webbeans.DefinitionException;
-import javax.webbeans.Dependent;
-import javax.webbeans.Standard;
-
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.SimpleBean;
-import org.jboss.webbeans.binding.NewBinding;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.test.AbstractTest;
-import org.jboss.webbeans.test.SpecAssertion;
-import org.jboss.webbeans.test.SpecVersion;
-import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
-import org.jboss.webbeans.test.newbean.invalid.NewAndOtherBindingType;
-import org.jboss.webbeans.test.newbean.valid.AnnotatedConstructorParameter;
-import org.jboss.webbeans.test.newbean.valid.AnnotatedField;
-import org.jboss.webbeans.test.newbean.valid.AnnotatedInitializerParameter;
-import org.jboss.webbeans.test.newbean.valid.AnnotatedProducerParameter;
-import org.jboss.webbeans.test.newbean.valid.WrappedBean;
-import org.jboss.webbeans.util.Proxies.TypeInfo;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
- at SpecVersion("20081222")
-public class NewBeanTest extends AbstractTest
-{
- private SimpleBean<WrappedBean> wrappedBean;
- private NewSimpleBean<WrappedBean> newBean;
-
- @BeforeMethod
- public void initNewBean() {
- wrappedBean = SimpleBean.of(WrappedBean.class, manager);
- manager.addBean(wrappedBean);
- newBean = NewSimpleBean.of(WrappedBean.class, manager);
- manager.addBean(newBean);
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanIsDependentScoped()
- {
- assert Dependent.class.equals(newBean.getScopeType());
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanIsOfStandardDeploymentType()
- {
- assert Standard.class.equals(newBean.getDeploymentType());
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanIsHasOnlyNewBinding()
- {
- assert newBean.getBindingTypes().size() == 1;
- assert newBean.getBindingTypes().iterator().next().annotationType().equals(new NewBinding().annotationType());
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoWebBeanName()
- {
- assert newBean.getName() == null;
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "stub", "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoStereotypes()
- {
- assert false;
- }
-
- /**
- * When the built-in binding type @New is applied to an injection point, a
- * Web Bean is implicitly defined with: scope @Dependent, deployment type
- *
- * @Standard, @New as the only binding annotation, no Web Bean name, no
- * stereotypes, and such that the implementation class is the
- * declared type of the injection point.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasImplementationClassOfInjectionPointType()
- {
- assert newBean.getType().equals(WrappedBean.class);
- }
-
- /**
- * If the parameter type satisfies the definition of a simple Web Bean
- * implementation class, Section 3.2.1, Which Java classes are simple Web
- * Beans?, then the Web Bean is a simple Web Bean. If the parameter type
- * satisfies the definition of an enterprise Web Bean implementation class,
- * Section 3.3.2, Which EJBs are enterprise Web Beans?, then the Web Bean
- * is an enterprise Web Bean.
- */
- @Test(groups = { "stub", "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanIsSimpleWebBeanIfParameterTypeIsSimpleWebBean()
- {
- // TODO: has to be?
- assert false;
- }
-
- /**
- * If the parameter type satisfies the definition of a simple Web Bean
- * implementation class, Section 3.2.1, Which Java classes are simple Web
- * Beans?, then the Web Bean is a simple Web Bean. If the parameter type
- * satisfies the definition of an enterprise Web Bean implementation class,
- * Section 3.3.2, Which EJBs are enterprise Web Beans?, then the Web Bean
- * is an enterprise Web Bean.
- */
- @Test(groups = { "stub", "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanIsEnterpriseWebBeanIfParameterTypeIsEnterpriseWebBean()
- {
- // TODO: has to be?
- assert false;
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasSameConstructorAsWrappedBean()
- {
- assert wrappedBean.getConstructor().equals(newBean.getConstructor());
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasSameInitializerMethodsAsWrappedBean()
- {
- assert newBean.getInitializerMethods().equals(wrappedBean.getInitializerMethods());
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasSameInjectedFieldsAsWrappedBean()
- {
- Set<AnnotatedItem<?, ?>> wrappedBeanInjectionPoints = wrappedBean.getInjectionPoints();
- Set<AnnotatedItem<?, ?>> newBeanInjectionPoints = newBean.getInjectionPoints();
- assert wrappedBeanInjectionPoints.equals(newBeanInjectionPoints);
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = {"new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoObservers()
- {
- assert newBean.getObserverMethods().isEmpty();
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoProducerFields()
- {
- assert newBean.getProducerFields().isEmpty();
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoProducerMethods()
- {
- assert newBean.getProducerMethods().isEmpty();
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoDisposalMethods()
- {
- Class<?> type = TypeInfo.ofTypes(newBean.getTypes()).getSuperClass();
- assert manager.resolveDisposalMethods(type, newBean.getBindingTypes().toArray(new Annotation[0])).isEmpty();
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "stub", "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasSameInterceptorMethodsAsWrappedBean()
- {
- assert false;
- }
-
- /**
- * Furthermore, this Web Bean: has the same Web Bean constructor,
- * initializer methods and injected fields as a Web Bean defined using
- * annotations that is, it has any Web Bean constructor, initializer method
- * or injected field declared by annotations that appear on the
- * implementation class, has no observer methods, producer methods or
- * fields or disposal methods, has the same interceptors as a Web Bean
- * defined using annotationsthat is, it has all the interceptor binding
- * types declared by annotations that appear on the implementation class, and
- * has no decorators.
- */
- @Test(groups = { "new" })
- @SpecAssertion(section = "3.9")
- public void testNewBeanHasNoDecorators()
- {
- Annotation[] bindingTypes = newBean.getBindingTypes().toArray(new Annotation[0]);
- assert manager.resolveDecorators(newBean.getTypes(), bindingTypes).isEmpty();
- }
-
- /**
- * The @New annotation or <New> element may be applied to any field of a Web
- * Bean implementation class or to any parameter of a producer method,
- * initializer method, disposal method or Web Bean constructor where the type
- * of the field or parameter is a concrete Java type which satisfies the
- * requirements of a simple Web Bean implementation class or enterprise Web
- * Bean implementation class.
- */
- @Test(groups = { "new" , "broken" })
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationMayBeAppliedToField()
- {
- webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedField.class));
- webBeansBootstrap.boot();
- assert manager.resolveByType(WrappedBean.class, new NewBinding()).size() == 1;
- }
-
- /**
- * The @New annotation or <New> element may be applied to any field of a Web
- * Bean implementation class or to any parameter of a producer method,
- * initializer method, disposal method or Web Bean constructor where the type
- * of the field or parameter is a concrete Java type which satisfies the
- * requirements of a simple Web Bean implementation class or enterprise Web
- * Bean implementation class.
- */
- @Test(groups = { "new" , "broken" })
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationMayBeAppliedToProducerMethodParameter()
- {
- webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedProducerParameter.class));
- webBeansBootstrap.boot();
- assert manager.resolveByType(WrappedBean.class, new NewBinding()).size() == 1;
- }
-
- /**
- * The @New annotation or <New> element may be applied to any field of a Web
- * Bean implementation class or to any parameter of a producer method,
- * initializer method, disposal method or Web Bean constructor where the type
- * of the field or parameter is a concrete Java type which satisfies the
- * requirements of a simple Web Bean implementation class or enterprise Web
- * Bean implementation class.
- */
- @Test(groups = { "new", "broken" })
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationMayBeAppliedToInitializerMethodParameter()
- {
- webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedInitializerParameter.class));
- webBeansBootstrap.boot();
- assert manager.resolveByType(WrappedBean.class, new NewBinding()).size() == 1;
- }
-
- /**
- * The @New annotation or <New> element may be applied to any field of a Web
- * Bean implementation class or to any parameter of a producer method,
- * initializer method, disposal method or Web Bean constructor where the type
- * of the field or parameter is a concrete Java type which satisfies the
- * requirements of a simple Web Bean implementation class or enterprise Web
- * Bean implementation class.
- */
- @Test(groups = { "new", "broken" })
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationMayBeAppliedToConstructorMethodParameter()
- {
- webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedConstructorParameter.class));
- webBeansBootstrap.boot();
- assert manager.resolveByType(WrappedBean.class, new NewBinding()).size() == 1;
- }
-
- /**
- * If the @New binding type appears in conjunction with some other binding
- * type, or is specified for a field or parameter of a type which does not
- * satisfy the definition of a simple Web Bean implementation class or
- * enterprise Web Bean implementation class, a DefinitionException is thrown
- * by the container at deployment time.
- */
- @Test(groups = { "new" , "broken"}, expectedExceptions = DefinitionException.class)
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationCannotAppearInConjunctionWithOtherBindingType()
- {
- webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(NewAndOtherBindingType.class));
- webBeansBootstrap.boot();
- }
-
- /**
- * If the @New binding type appears in conjunction with some other binding
- * type, or is specified for a field or parameter of a type which does not
- * satisfy the definition of a simple Web Bean implementation class or
- * enterprise Web Bean implementation class, a DefinitionException is thrown
- * by the container at deployment time.
- */
- @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationCannotBeAppliedToNonWebBeanImplementationClass()
- {
- assert false;
- }
-
- /**
- * No Web Bean defined using annotations or XML may explicitly declare @New
- * as a binding type
- */
- @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
- @SpecAssertion(section = "3.9")
- public void testNewAnnotationCannotBeExplicitlyDeclared()
- {
- assert false;
- }
-
-
-}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewEnterpriseBeanTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewEnterpriseBeanTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewEnterpriseBeanTest.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -0,0 +1,428 @@
+package org.jboss.webbeans.test.newbean;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.webbeans.DefinitionException;
+import javax.webbeans.Dependent;
+import javax.webbeans.Standard;
+
+import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.NewEnterpriseBean;
+import org.jboss.webbeans.binding.NewBinding;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.test.AbstractTest;
+import org.jboss.webbeans.test.SpecAssertion;
+import org.jboss.webbeans.test.SpecVersion;
+import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
+import org.jboss.webbeans.test.newbean.invalid.NewAndOtherBindingType;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedConstructorParameter;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedField;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedInitializerParameter;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedProducerParameter;
+import org.jboss.webbeans.test.newbean.valid.WrappedEnterpriseBean;
+import org.jboss.webbeans.test.newbean.valid.WrappedSimpleBean;
+import org.jboss.webbeans.util.Proxies.TypeInfo;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at SpecVersion("20081222")
+public class NewEnterpriseBeanTest extends AbstractTest
+{
+ private EnterpriseBean<WrappedEnterpriseBean> wrappedEnterpriseBean;
+ private NewEnterpriseBean<WrappedEnterpriseBean> newEnterpriseBean;
+
+ @BeforeMethod
+ public void initNewBean() {
+ addToEjbCache(WrappedEnterpriseBean.class);
+ wrappedEnterpriseBean = EnterpriseBean.of(WrappedEnterpriseBean.class, manager);
+ manager.addBean(wrappedEnterpriseBean);
+ newEnterpriseBean = NewEnterpriseBean.of(WrappedEnterpriseBean.class, manager);
+ manager.addBean(newEnterpriseBean);
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsDependentScoped()
+ {
+ assert Dependent.class.equals(newEnterpriseBean.getScopeType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsOfStandardDeploymentType()
+ {
+ assert Standard.class.equals(newEnterpriseBean.getDeploymentType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsHasOnlyNewBinding()
+ {
+ assert newEnterpriseBean.getBindingTypes().size() == 1;
+ assert newEnterpriseBean.getBindingTypes().iterator().next().annotationType().equals(new NewBinding().annotationType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoWebBeanName()
+ {
+ assert newEnterpriseBean.getName() == null;
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoStereotypes()
+ {
+ assert false;
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new", "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasImplementationClassOfInjectionPointType()
+ {
+ assert newEnterpriseBean.getType().equals(WrappedSimpleBean.class);
+ }
+
+ /**
+ * If the parameter type satisfies the definition of a simple Web Bean
+ * implementation class, Section 3.2.1, Which Java classes are simple Web
+ * Beans?, then the Web Bean is a simple Web Bean. If the parameter type
+ * satisfies the definition of an enterprise Web Bean implementation class,
+ * Section 3.3.2, Which EJBs are enterprise Web Beans?, then the Web Bean
+ * is an enterprise Web Bean.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsEnterpriseWebBeanIfParameterTypeIsEnterpriseWebBean()
+ {
+ // TODO: has to be?
+ assert false;
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameConstructorAsWrappedBean()
+ {
+ // N/A for EJB
+ assert true;
+// assert wrappedEnterpriseBean.getConstructor().equals(newEnterpriseBean.getConstructor());
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInitializerMethodsAsWrappedBean()
+ {
+ assert newEnterpriseBean.getInitializerMethods().equals(wrappedEnterpriseBean.getInitializerMethods());
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInjectedFieldsAsWrappedBean()
+ {
+ Set<AnnotatedItem<?, ?>> wrappedBeanInjectionPoints = wrappedEnterpriseBean.getInjectionPoints();
+ Set<AnnotatedItem<?, ?>> newBeanInjectionPoints = newEnterpriseBean.getInjectionPoints();
+ assert wrappedBeanInjectionPoints.equals(newBeanInjectionPoints);
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = {"new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoObservers()
+ {
+ assert newEnterpriseBean.getObserverMethods().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoProducerFields()
+ {
+ assert newEnterpriseBean.getProducerFields().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoProducerMethods()
+ {
+ assert newEnterpriseBean.getProducerMethods().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoDisposalMethods()
+ {
+ Class<?> type = TypeInfo.ofTypes(newEnterpriseBean.getTypes()).getSuperClass();
+ assert manager.resolveDisposalMethods(type, newEnterpriseBean.getBindingTypes().toArray(new Annotation[0])).isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInterceptorMethodsAsWrappedBean()
+ {
+ assert false;
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoDecorators()
+ {
+ Annotation[] bindingTypes = newEnterpriseBean.getBindingTypes().toArray(new Annotation[0]);
+ assert manager.resolveDecorators(newEnterpriseBean.getTypes(), bindingTypes).isEmpty();
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new" , "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToField()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedField.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new" , "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToProducerMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedProducerParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new", "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToInitializerMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedInitializerParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new", "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToConstructorMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedConstructorParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * If the @New binding type appears in conjunction with some other binding
+ * type, or is specified for a field or parameter of a type which does not
+ * satisfy the definition of a simple Web Bean implementation class or
+ * enterprise Web Bean implementation class, a DefinitionException is thrown
+ * by the container at deployment time.
+ */
+ @Test(groups = { "new" , "broken"}, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotAppearInConjunctionWithOtherBindingType()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(NewAndOtherBindingType.class));
+ webBeansBootstrap.boot();
+ }
+
+ /**
+ * If the @New binding type appears in conjunction with some other binding
+ * type, or is specified for a field or parameter of a type which does not
+ * satisfy the definition of a simple Web Bean implementation class or
+ * enterprise Web Bean implementation class, a DefinitionException is thrown
+ * by the container at deployment time.
+ */
+ @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotBeAppliedToNonWebBeanImplementationClass()
+ {
+ assert false;
+ }
+
+ /**
+ * No Web Bean defined using annotations or XML may explicitly declare @New
+ * as a binding type
+ */
+ @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotBeExplicitlyDeclared()
+ {
+ assert false;
+ }
+
+
+}
Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewSimpleBeanTest.java (from rev 821, ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewBeanTest.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewSimpleBeanTest.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/NewSimpleBeanTest.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -0,0 +1,424 @@
+package org.jboss.webbeans.test.newbean;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.webbeans.DefinitionException;
+import javax.webbeans.Dependent;
+import javax.webbeans.Standard;
+
+import org.jboss.webbeans.bean.NewSimpleBean;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.binding.NewBinding;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.test.AbstractTest;
+import org.jboss.webbeans.test.SpecAssertion;
+import org.jboss.webbeans.test.SpecVersion;
+import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
+import org.jboss.webbeans.test.newbean.invalid.NewAndOtherBindingType;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedConstructorParameter;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedField;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedInitializerParameter;
+import org.jboss.webbeans.test.newbean.valid.AnnotatedProducerParameter;
+import org.jboss.webbeans.test.newbean.valid.WrappedSimpleBean;
+import org.jboss.webbeans.util.Proxies.TypeInfo;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+ at SpecVersion("20081222")
+public class NewSimpleBeanTest extends AbstractTest
+{
+ private SimpleBean<WrappedSimpleBean> wrappedSimpleBean;
+ private NewSimpleBean<WrappedSimpleBean> newSimpleBean;
+
+ @BeforeMethod
+ public void initNewBean() {
+ wrappedSimpleBean = SimpleBean.of(WrappedSimpleBean.class, manager);
+ manager.addBean(wrappedSimpleBean);
+ newSimpleBean = NewSimpleBean.of(WrappedSimpleBean.class, manager);
+ manager.addBean(newSimpleBean);
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsDependentScoped()
+ {
+ assert Dependent.class.equals(newSimpleBean.getScopeType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsOfStandardDeploymentType()
+ {
+ assert Standard.class.equals(newSimpleBean.getDeploymentType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsHasOnlyNewBinding()
+ {
+ assert newSimpleBean.getBindingTypes().size() == 1;
+ assert newSimpleBean.getBindingTypes().iterator().next().annotationType().equals(new NewBinding().annotationType());
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoWebBeanName()
+ {
+ assert newSimpleBean.getName() == null;
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoStereotypes()
+ {
+ assert false;
+ }
+
+ /**
+ * When the built-in binding type @New is applied to an injection point, a
+ * Web Bean is implicitly defined with: scope @Dependent, deployment type
+ *
+ * @Standard, @New as the only binding annotation, no Web Bean name, no
+ * stereotypes, and such that the implementation class is the
+ * declared type of the injection point.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasImplementationClassOfInjectionPointType()
+ {
+ assert newSimpleBean.getType().equals(WrappedSimpleBean.class);
+ }
+
+ /**
+ * If the parameter type satisfies the definition of a simple Web Bean
+ * implementation class, Section 3.2.1, Which Java classes are simple Web
+ * Beans?, then the Web Bean is a simple Web Bean. If the parameter type
+ * satisfies the definition of an enterprise Web Bean implementation class,
+ * Section 3.3.2, Which EJBs are enterprise Web Beans?, then the Web Bean
+ * is an enterprise Web Bean.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanIsSimpleWebBeanIfParameterTypeIsSimpleWebBean()
+ {
+ // TODO: has to be?
+ assert false;
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameConstructorAsWrappedBean()
+ {
+ assert wrappedSimpleBean.getConstructor().equals(newSimpleBean.getConstructor());
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInitializerMethodsAsWrappedBean()
+ {
+ assert newSimpleBean.getInitializerMethods().equals(wrappedSimpleBean.getInitializerMethods());
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInjectedFieldsAsWrappedBean()
+ {
+ Set<AnnotatedItem<?, ?>> wrappedBeanInjectionPoints = wrappedSimpleBean.getInjectionPoints();
+ Set<AnnotatedItem<?, ?>> newBeanInjectionPoints = newSimpleBean.getInjectionPoints();
+ assert wrappedBeanInjectionPoints.equals(newBeanInjectionPoints);
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = {"new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoObservers()
+ {
+ assert newSimpleBean.getObserverMethods().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoProducerFields()
+ {
+ assert newSimpleBean.getProducerFields().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoProducerMethods()
+ {
+ assert newSimpleBean.getProducerMethods().isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoDisposalMethods()
+ {
+ Class<?> type = TypeInfo.ofTypes(newSimpleBean.getTypes()).getSuperClass();
+ assert manager.resolveDisposalMethods(type, newSimpleBean.getBindingTypes().toArray(new Annotation[0])).isEmpty();
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "stub", "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasSameInterceptorMethodsAsWrappedBean()
+ {
+ assert false;
+ }
+
+ /**
+ * Furthermore, this Web Bean: has the same Web Bean constructor,
+ * initializer methods and injected fields as a Web Bean defined using
+ * annotations that is, it has any Web Bean constructor, initializer method
+ * or injected field declared by annotations that appear on the
+ * implementation class, has no observer methods, producer methods or
+ * fields or disposal methods, has the same interceptors as a Web Bean
+ * defined using annotationsthat is, it has all the interceptor binding
+ * types declared by annotations that appear on the implementation class, and
+ * has no decorators.
+ */
+ @Test(groups = { "new" })
+ @SpecAssertion(section = "3.9")
+ public void testNewBeanHasNoDecorators()
+ {
+ Annotation[] bindingTypes = newSimpleBean.getBindingTypes().toArray(new Annotation[0]);
+ assert manager.resolveDecorators(newSimpleBean.getTypes(), bindingTypes).isEmpty();
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new" , "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToField()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedField.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new" , "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToProducerMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedProducerParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new", "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToInitializerMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedInitializerParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * The @New annotation or <New> element may be applied to any field of a Web
+ * Bean implementation class or to any parameter of a producer method,
+ * initializer method, disposal method or Web Bean constructor where the type
+ * of the field or parameter is a concrete Java type which satisfies the
+ * requirements of a simple Web Bean implementation class or enterprise Web
+ * Bean implementation class.
+ */
+ @Test(groups = { "new", "broken" })
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationMayBeAppliedToConstructorMethodParameter()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(AnnotatedConstructorParameter.class));
+ webBeansBootstrap.boot();
+ assert manager.resolveByType(WrappedSimpleBean.class, new NewBinding()).size() == 1;
+ }
+
+ /**
+ * If the @New binding type appears in conjunction with some other binding
+ * type, or is specified for a field or parameter of a type which does not
+ * satisfy the definition of a simple Web Bean implementation class or
+ * enterprise Web Bean implementation class, a DefinitionException is thrown
+ * by the container at deployment time.
+ */
+ @Test(groups = { "new" , "broken"}, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotAppearInConjunctionWithOtherBindingType()
+ {
+ webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(NewAndOtherBindingType.class));
+ webBeansBootstrap.boot();
+ }
+
+ /**
+ * If the @New binding type appears in conjunction with some other binding
+ * type, or is specified for a field or parameter of a type which does not
+ * satisfy the definition of a simple Web Bean implementation class or
+ * enterprise Web Bean implementation class, a DefinitionException is thrown
+ * by the container at deployment time.
+ */
+ @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotBeAppliedToNonWebBeanImplementationClass()
+ {
+ assert false;
+ }
+
+ /**
+ * No Web Bean defined using annotations or XML may explicitly declare @New
+ * as a binding type
+ */
+ @Test(groups = { "stub", "new" }, expectedExceptions = DefinitionException.class)
+ @SpecAssertion(section = "3.9")
+ public void testNewAnnotationCannotBeExplicitlyDeclared()
+ {
+ assert false;
+ }
+
+
+}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/invalid/NewAndOtherBindingType.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/invalid/NewAndOtherBindingType.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/invalid/NewAndOtherBindingType.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -3,9 +3,9 @@
import javax.webbeans.Current;
import javax.webbeans.New;
-import org.jboss.webbeans.test.newbean.valid.WrappedBean;
+import org.jboss.webbeans.test.newbean.valid.WrappedSimpleBean;
public class NewAndOtherBindingType
{
- public @New @Current WrappedBean violation;
+ public @New @Current WrappedSimpleBean violation;
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedConstructorParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedConstructorParameter.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedConstructorParameter.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -7,7 +7,7 @@
public class AnnotatedConstructorParameter
{
@Initializer
- public AnnotatedConstructorParameter(@New WrappedBean reference)
+ public AnnotatedConstructorParameter(@New WrappedSimpleBean reference)
{
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedField.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedField.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedField.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -6,6 +6,6 @@
public class AnnotatedField
{
@New
- WrappedBean reference;
+ WrappedSimpleBean reference;
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedInitializerParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedInitializerParameter.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedInitializerParameter.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -7,7 +7,7 @@
public class AnnotatedInitializerParameter
{
@Initializer
- public void init(@New WrappedBean reference)
+ public void init(@New WrappedSimpleBean reference)
{
}
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedProducerParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedProducerParameter.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/AnnotatedProducerParameter.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -7,7 +7,7 @@
public class AnnotatedProducerParameter
{
@Produces
- Object produce(@New WrappedBean reference)
+ Object produce(@New WrappedSimpleBean reference)
{
return new Object();
}
Deleted: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedBean.java 2009-01-08 07:15:08 UTC (rev 822)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedBean.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -1,15 +0,0 @@
-package org.jboss.webbeans.test.newbean.valid;
-
-import java.io.Serializable;
-
-import javax.webbeans.Named;
-import javax.webbeans.SessionScoped;
-
- at SessionScoped
- at Named("Fred")
-public class WrappedBean implements Serializable
-{
- public WrappedBean() {
-
- }
-}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedEnterpriseBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedEnterpriseBean.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.newbean.valid;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.webbeans.Named;
+import javax.webbeans.SessionScoped;
+
+ at SessionScoped
+ at Stateful
+ at Named("John")
+public class WrappedEnterpriseBean
+{
+ @Remove
+ public void bye() {
+ }
+}
Copied: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedSimpleBean.java (from rev 821, ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedBean.java)
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedSimpleBean.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedSimpleBean.java 2009-01-08 07:41:03 UTC (rev 823)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.test.newbean.valid;
+
+import java.io.Serializable;
+
+import javax.webbeans.Named;
+import javax.webbeans.SessionScoped;
+
+ at SessionScoped
+ at Named("Fred")
+public class WrappedSimpleBean implements Serializable
+{
+ public WrappedSimpleBean() {
+
+ }
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/newbean/valid/WrappedSimpleBean.java
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the weld-commits
mailing list