[webbeans-commits] Webbeans SVN: r753 - in ri/trunk/webbeans-ri/src: test/java/org/jboss/webbeans/test and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Sat Jan 3 09:23:41 EST 2009


Author: dallen6
Date: 2009-01-03 09:23:41 -0500 (Sat, 03 Jan 2009)
New Revision: 753

Added:
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionPointTest.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPoint.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPointBean.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPoint.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPointBean.java
Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
Log:
Test framework for injection points; all tests marked broken till final integration of feature is done.

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java	2009-01-02 18:57:22 UTC (rev 752)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -41,9 +41,10 @@
    private final AbstractAnnotatedMember<?, ? extends Member> memberInjectionPoint;
    private final Bean<?> bean;
    private final Object beanInstance;
-   
+
    /**
     * Creates a new metadata bean for the given injection point information.
+    * 
     * @param injectedMember The member of the bean being injected
     * @param bean The bean being injected
     * @param beanInstance The instance of the bean being injected
@@ -55,49 +56,41 @@
       this.beanInstance = beanInstance;
    }
 
-   //@Override
    public <T extends Annotation> T getAnnotation(Class<T> annotationType)
    {
       return this.memberInjectionPoint.getAnnotation(annotationType);
    }
 
-   //@Override
    public Annotation[] getAnnotations()
    {
       return this.memberInjectionPoint.getAnnotations().toArray(new Annotation[0]);
    }
 
-   //@Override
    public Bean<?> getBean()
    {
       return this.bean;
    }
 
-   //@Override
    public Set<Annotation> getBindingTypes()
    {
       return this.memberInjectionPoint.getBindingTypes();
    }
 
-   //@Override
    public Object getInstance()
    {
       return this.beanInstance;
    }
 
-   //@Override
    public Member getMember()
    {
       return this.memberInjectionPoint.getDelegate();
    }
 
-   //@Override
    public Type getType()
    {
       return this.memberInjectionPoint.getType();
    }
 
-   //@Override
    public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
    {
       return this.memberInjectionPoint.isAnnotationPresent(annotationType);

Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionPointTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionPointTest.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionPointTest.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.util.Set;
+
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
+import javax.webbeans.InjectionPoint;
+import javax.webbeans.Standard;
+import javax.webbeans.manager.Bean;
+
+import org.jboss.webbeans.binding.CurrentBinding;
+import org.jboss.webbeans.test.beans.ConstructorInjectionPoint;
+import org.jboss.webbeans.test.beans.ConstructorInjectionPointBean;
+import org.jboss.webbeans.test.beans.FieldInjectionPoint;
+import org.jboss.webbeans.test.beans.FieldInjectionPointBean;
+import org.jboss.webbeans.test.mock.MockWebBeanDiscovery;
+import org.testng.annotations.Test;
+
+/**
+ * Injection point metadata tests
+ * 
+ * @author David Allen
+ * 
+ */
+ at SpecVersion("20081222")
+public class InjectionPointTest extends AbstractTest
+{
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetInstance()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getInstance().equals(beanWithInjectedBean);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetBean()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+
+      Set<Bean<FieldInjectionPointBean>> theBean = manager.resolveByType(FieldInjectionPointBean.class);
+      assert beanWithInjectionPoint.injectedMetadata.getBean().equals(theBean);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetType()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getType().equals(FieldInjectionPointBean.class);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetBindingTypes()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      Set<Annotation> bindingTypes = beanWithInjectionPoint.injectedMetadata.getBindingTypes();
+      assert bindingTypes.size() == 1;
+      assert bindingTypes.iterator().next().equals(Current.class);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetMemberField()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert Field.class.isAssignableFrom(beanWithInjectionPoint.injectedMetadata.getMember().getClass());
+   }
+
+   @Test(groups = { "stub", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetMemberMethod()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetMemberConstructor()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(ConstructorInjectionPointBean.class, ConstructorInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      ConstructorInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(ConstructorInjectionPointBean.class, new CurrentBinding());
+      ConstructorInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert Constructor.class.isAssignableFrom(beanWithInjectionPoint.injectedMetadata.getMember().getClass());
+   }
+
+   @Test(groups = { "stub", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetAnnotation()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "stub", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testGetAnnotations()
+   {
+      assert false;
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testStandardDeployment()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getBean().getDeploymentType().equals(Standard.class);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testDependentScope()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getBean().getScopeType().equals(Dependent.class);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testApiTypeInjectionPoint()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getBean().getTypes().contains(InjectionPoint.class);
+   }
+
+   @Test(groups = { "broken", "injectionPoint" })
+   @SpecAssertion(section = "5.11")
+   public void testCurrentBinding()
+   {
+      webBeansBootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(FieldInjectionPointBean.class, FieldInjectionPoint.class));
+      webBeansBootstrap.boot();
+
+      // Get an instance of the bean which has another bean injected into it
+      FieldInjectionPointBean beanWithInjectedBean = manager.getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+      FieldInjectionPoint beanWithInjectionPoint = beanWithInjectedBean.injectedBean;
+      assert beanWithInjectionPoint.injectedMetadata != null;
+      assert beanWithInjectionPoint.injectedMetadata.getBean().getBindingTypes().contains(Current.class);
+   }
+}


Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/InjectionPointTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPoint.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPoint.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.InjectionPoint;
+
+/**
+ * Test bean with injection point on the constructor of the bean
+ * 
+ * @author David Allen
+ *
+ */
+public class ConstructorInjectionPoint
+{
+   public InjectionPoint injectedMetadata;
+
+   public ConstructorInjectionPoint(InjectionPoint injectionPoint)
+   {
+      injectedMetadata = injectionPoint;
+   }
+}


Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPoint.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPointBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPointBean.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPointBean.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.SessionScoped;
+
+/**
+ * Test bean to inject another bean which uses injection point metadata on the constructor
+ * 
+ * @author David Allen
+ *
+ */
+ at SessionScoped
+public class ConstructorInjectionPointBean
+{
+   @Current
+   public ConstructorInjectionPoint injectedBean;
+}


Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/ConstructorInjectionPointBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPoint.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPoint.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.InjectionPoint;
+
+/**
+ * Test bean with injected metadata in a field about where this bean is injected
+ * into another bean
+ * 
+ * @author David Allen
+ *
+ */
+public class FieldInjectionPoint
+{
+   @Current
+   public InjectionPoint injectedMetadata;
+}


Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPoint.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPointBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPointBean.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPointBean.java	2009-01-03 14:23:41 UTC (rev 753)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.beans;
+
+import javax.webbeans.Current;
+import javax.webbeans.SessionScoped;
+
+/**
+ * Test bean to inject another bean which uses injection point metadata in a field
+ * 
+ * @author David Allen
+ *
+ */
+ at SessionScoped
+public class FieldInjectionPointBean
+{
+   @Current
+   public FieldInjectionPoint injectedBean;
+}


Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/beans/FieldInjectionPointBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list