[webbeans-commits] Webbeans SVN: r3303 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection: enterprise and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jul 28 03:35:19 EDT 2009


Author: jharting
Date: 2009-07-28 03:35:19 -0400 (Tue, 28 Jul 2009)
New Revision: 3303

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Farm.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmInterceptor.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmLocal.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBean.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBeanLocal.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/SessionBeanInjectionTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Sheep.java
Log:
Added integration tests for injection into contextual and non-contextual Session beans and their interceptors

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Farm.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Farm.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Farm.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Current;
+import javax.interceptor.Interceptors;
+
+ at Stateless
+public class Farm implements FarmLocal
+{
+   @Current private Sheep sheep;
+   private boolean injectionPerformedCorrectly = false;
+
+   @Interceptors(FarmInterceptor.class)
+   public int getAnimalCount() {
+      return 1;
+   }
+   
+   @PostConstruct
+   public void postConstruct() {
+      injectionPerformedCorrectly = sheep != null;
+   }
+
+   public boolean isInjectionPerformedCorrectly()
+   {
+      return injectionPerformedCorrectly;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmInterceptor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmInterceptor.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmInterceptor.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+import javax.enterprise.inject.Current;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+public class FarmInterceptor
+{
+
+   @Current
+   private Sheep sheep;
+
+   @AroundInvoke
+   public Object intercept(InvocationContext invocation) throws Exception
+   {
+      if (sheep == null)
+      {
+         throw new RuntimeException("Sheep not injected.");
+      }
+      return (Integer)invocation.proceed() + 1;  
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmLocal.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/FarmLocal.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+import javax.ejb.Local;
+
+ at Local
+public interface FarmLocal
+{
+   int getAnimalCount();
+   boolean isInjectionPerformedCorrectly();
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBean.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBean.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+
+ at Stateless
+public class InjectedSessionBean implements InjectedSessionBeanLocal
+{
+   @EJB
+   private FarmLocal farm;
+
+   public FarmLocal getFarm()
+   {
+      return farm;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBeanLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBeanLocal.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/InjectedSessionBeanLocal.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+import javax.ejb.Local;
+
+ at Local
+public interface InjectedSessionBeanLocal
+{
+   FarmLocal getFarm();
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/SessionBeanInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/SessionBeanInjectionTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/SessionBeanInjectionTest.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,63 @@
+/*
+ * 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.injection.enterprise;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at IntegrationTest
+ at Packaging(PackagingType.EAR)
+ at SpecVersion("20090625")
+public class SessionBeanInjectionTest extends AbstractJSR299Test
+{
+
+   @Test
+   @SpecAssertions({
+      @SpecAssertion(section = "5.6", id = "a"),
+      @SpecAssertion(section = "5.6.4", id = "a")})
+   public void testInjectionOnContextualSessionBean()
+   {
+      assert getInstanceByType(FarmLocal.class).isInjectionPerformedCorrectly();
+   }
+
+   @Test
+   @SpecAssertions({
+      @SpecAssertion(section = "5.6", id = "c"),
+      @SpecAssertion(section = "5.6.4", id = "a")})
+   public void testInjectionOnNonContextualSessionBean()
+   {
+      assert getInstanceByType(InjectedSessionBeanLocal.class).getFarm().isInjectionPerformedCorrectly();
+   }
+
+   @Test(groups = "ri-broken")
+   @SpecAssertion(section = "5.6", id = "e")
+   public void testInjectionOnEJBInterceptor()
+   {
+      // Test interceptor that intercepts contextual Session Bean
+      assert getInstanceByType(FarmLocal.class).getAnimalCount() == 2;
+      // Test interceptor that intercepts non-contextual Session Bean
+      assert getInstanceByType(InjectedSessionBeanLocal.class).getFarm().getAnimalCount() == 2;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Sheep.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Sheep.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/Sheep.java	2009-07-28 07:35:19 UTC (rev 3303)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
+
+public class Sheep
+{
+
+}




More information about the weld-commits mailing list