[webbeans-commits] Webbeans SVN: r3103 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken and 6 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jul 21 03:54:15 EDT 2009


Author: jharting
Date: 2009-07-21 03:54:15 -0400 (Tue, 21 Jul 2009)
New Revision: 3103

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/Cat.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/CatDecorator.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/TransientFieldInjectionPointBean.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/Cat_Broken.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/NormalScopedBeanWithInjectionPoint.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/Dog.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/InjectionPointOnNonBeanTest.java
   tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/injectionpoint/
   tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/injectionpoint/beans.xml
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/FieldInjectionPointBean.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
Log:
InjectionPoint tests

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/Cat.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/Cat.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/Cat.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.lookup.injectionpoint;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+class Cat
+{
+   @Current private InjectionPoint injectionPoint;
+   
+   public String hello() {
+      return "hello";
+   }
+   
+   public InjectionPoint getInjectionPoint() {
+      return injectionPoint;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/CatDecorator.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/CatDecorator.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/CatDecorator.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.lookup.injectionpoint;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+ at Decorator
+class CatDecorator extends Cat
+{
+   @Decorates Cat bean;
+
+   public String hello()
+   {
+      return bean.hello() + " world!";
+   }
+}

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/FieldInjectionPointBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/FieldInjectionPointBean.java	2009-07-21 07:31:00 UTC (rev 3102)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/FieldInjectionPointBean.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -30,7 +30,7 @@
 @RequestScoped
 class FieldInjectionPointBean
 {
-   @Current @AnimalStereotype
+   @Current @AnimalStereotype 
    private BeanWithInjectionPointMetadata injectedBean;
 
    public BeanWithInjectionPointMetadata getInjectedBean()

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java	2009-07-21 07:31:00 UTC (rev 3102)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -24,7 +24,8 @@
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Current;
-import javax.enterprise.inject.deployment.Standard;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 
@@ -33,16 +34,19 @@
 import org.jboss.jsr299.tck.AbstractJSR299Test;
 import org.jboss.jsr299.tck.literals.CurrentLiteral;
 import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
 import org.testng.annotations.Test;
 
 /**
  * Injection point metadata tests
  * 
  * @author David Allen
+ * @author Jozef Hartinger
  * 
  * Spec version: 20090625
  */
 @Artifact
+ at BeansXml("beans.xml")
 public class InjectionPointTest extends AbstractJSR299Test
 {
 
@@ -176,9 +180,9 @@
       }.run();
    }
 
-   @Test(groups = { "injectionPoint", "rewrite" })
+   @Test(groups = { "injectionPoint", "ri-broken" })
    @SpecAssertion(section = "5.6.9", id = "daa")
-   public void testGetAnnotation() throws Exception
+   public void testGetAnnotatedField() throws Exception
    {
       // Get an instance of the bean which has another bean injected into it
       new RunInDependentContext()
@@ -190,10 +194,31 @@
             FieldInjectionPointBean beanWithInjectedBean = getInstanceByType(FieldInjectionPointBean.class,new CurrentLiteral());
             BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
             assert beanWithInjectionPoint.getInjectedMetadata() != null;
-            assert beanWithInjectionPoint.getInjectedMetadata().getAnnotated().getAnnotation(AnimalStereotype.class) != null;
+            assert beanWithInjectionPoint.getInjectedMetadata().getAnnotated() instanceof AnnotatedField;
+            assert beanWithInjectionPoint.getInjectedMetadata().getAnnotated().isAnnotationPresent(AnimalStereotype.class);
          }
       }.run();
    }
+   
+   @Test(groups = { "injectionPoint", "ri-broken" })
+ 	@SpecAssertion(section = "5.6.9", id = "daa")
+   public void testGetAnnotatedParameter() throws Exception
+   {
+      // Get an instance of the bean which has another bean injected into it
+      new RunInDependentContext()
+      {
+         
+         @Override
+         protected void execute() throws Exception
+         {
+            MethodInjectionPointBean beanWithInjectedBean = getInstanceByType(MethodInjectionPointBean.class,new CurrentLiteral());
+            BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
+            assert beanWithInjectionPoint.getInjectedMetadata() != null;
+            assert beanWithInjectionPoint.getInjectedMetadata().getAnnotated() instanceof AnnotatedParameter;
+            assert beanWithInjectionPoint.getInjectedMetadata().getAnnotated().isAnnotationPresent(Current.class);
+         }
+      }.run();
+   }
 
    @Test(groups = { "injectionPoint" })
    @SpecAssertion(section = "5.6.9", id = "e")
@@ -252,4 +277,41 @@
          }
       }.run();
    }
+   
+   @Test(groups = { "injectionPoint" })
+   @SpecAssertion(section = "5.6.9", id = "dca")
+   public void testIsTransient() throws Exception
+   {
+	   new RunInDependentContext()
+	   {
+		   @Override
+		   protected void execute() throws Exception
+		   {
+			   FieldInjectionPointBean bean1 = getInstanceByType(FieldInjectionPointBean.class,new CurrentLiteral());
+			   TransientFieldInjectionPointBean bean2 = getInstanceByType(TransientFieldInjectionPointBean.class,new CurrentLiteral());
+			   InjectionPoint ip1 = bean1.getInjectedBean().getInjectedMetadata();
+			   InjectionPoint ip2 = bean2.getInjectedBean().getInjectedMetadata();
+			   assert !ip1.isTransient();
+			   assert ip2.isTransient();
+		   }
+	   }.run();
+   }
+   
+   @Test(groups = { "injectionPoint", "ri-broken" })
+   @SpecAssertion(section = "5.6.9", id="dba")
+   public void testIsDelegate() throws Exception {
+      new RunInDependentContext()
+      {
+         @Override
+         protected void execute() throws Exception
+         {
+            assert !getInstanceByType(FieldInjectionPointBean.class,new CurrentLiteral()).getInjectedBean().getInjectedMetadata().isDelegate();
+            
+            Cat cat = getInstanceByType(Cat.class, new CurrentLiteral());
+            assert cat.hello().equals("hello world!");
+            assert cat.getInjectionPoint() != null;
+            assert cat.getInjectionPoint().isDelegate();
+         }
+      }.run();
+   }
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/TransientFieldInjectionPointBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/TransientFieldInjectionPointBean.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/TransientFieldInjectionPointBean.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,40 @@
+/*
+ * 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.jsr299.tck.tests.lookup.injectionpoint;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Current;
+
+/**
+ * Test bean to inject another bean which uses injection point metadata in a
+ * field
+ * 
+ * @author David Allen
+ * 
+ */
+ at RequestScoped
+class TransientFieldInjectionPointBean
+{
+   @Current @AnimalStereotype
+   private transient BeanWithInjectionPointMetadata injectedBean;
+
+   public BeanWithInjectionPointMetadata getInjectedBean()
+   {
+      return injectedBean;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/Cat_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/Cat_Broken.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/Cat_Broken.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,30 @@
+/*
+ * 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.jsr299.tck.tests.lookup.injectionpoint.broken.normal.scope;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+ at SuppressWarnings("unused")
+ at RequestScoped
+class Cat_Broken {
+
+	@Current private InjectionPoint ip;
+	
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/NormalScopedBeanWithInjectionPoint.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/NormalScopedBeanWithInjectionPoint.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/normal/scope/NormalScopedBeanWithInjectionPoint.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,39 @@
+/*
+ * 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.jsr299.tck.tests.lookup.injectionpoint.broken.normal.scope;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.DefinitionError;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * Spec version: 2009625
+ */
+ at Artifact
+ at ExpectedDeploymentException(DefinitionError.class)
+public class NormalScopedBeanWithInjectionPoint {
+	
+	@Test(groups = { "injectionPoint", "ri-broken" })
+	@SpecAssertion(section="5.6.9", id="f")
+	public void testSessionScopedBeanWithInjectionPoint() {
+		assert false;
+	}
+
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/Dog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/Dog.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/Dog.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,27 @@
+/*
+ * 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.jsr299.tck.tests.lookup.injectionpoint.broken.not.bean;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+class Dog
+{
+   public String bark(@Current InjectionPoint ip) {
+      return "ruff";
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/InjectionPointOnNonBeanTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/InjectionPointOnNonBeanTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/not/bean/InjectionPointOnNonBeanTest.java	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,39 @@
+/*
+ * 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.jsr299.tck.tests.lookup.injectionpoint.broken.not.bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.DefinitionError;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * Spec version: 2009625
+ */
+ at Artifact
+ at ExpectedDeploymentException(DefinitionError.class)
+public class InjectionPointOnNonBeanTest
+{
+   @Test(groups = { "injectionPoint", "ri-broken" })
+   @SpecAssertion(section = "5.6.9", id = "g")
+   public void test()
+   {
+      assert false;
+   }
+}

Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/injectionpoint/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/injectionpoint/beans.xml	                        (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/injectionpoint/beans.xml	2009-07-21 07:54:15 UTC (rev 3103)
@@ -0,0 +1,5 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.jsr299.tck.tests.lookup.injectionpoint.CatDecorator</class>
+   </decorators>
+</beans>




More information about the weld-commits mailing list