[webbeans-commits] Webbeans SVN: r1949 - tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Mar 12 18:18:47 EDT 2009


Author: dallen6
Date: 2009-03-12 18:18:47 -0400 (Thu, 12 Mar 2009)
New Revision: 1949

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/RoemerPassage.java
Modified:
   ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
   tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
Log:
Added a couple more lifecycle tests for EJBs and added new operation to Beans in TCK API.

Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-03-12 17:32:50 UTC (rev 1948)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -2,6 +2,7 @@
 
 import org.jboss.jsr299.tck.spi.Beans;
 import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
 import org.jboss.webbeans.ejb.spi.EjbDescriptor;
 import org.jboss.webbeans.util.Reflections;
 
@@ -71,4 +72,25 @@
       return Reflections.isProxy(instance);
    }
 
+   public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterface)
+   {
+      T enterpriseBean = null;
+      if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(beanType))
+      {
+         EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getEjbDescriptorCache().get(beanType).iterator().next();
+         String jndiName = null;
+         for (BusinessInterfaceDescriptor<?> businessInterface : ejbDescriptor.getLocalBusinessInterfaces())
+         {
+            if (businessInterface.getInterface().equals(localInterface))
+            {
+               jndiName = businessInterface.getJndiName();
+            }
+         }
+         if (jndiName == null)
+            throw new NullPointerException("No JNDI name found for interface " + localInterface.getName() + " on bean " + beanType.getName());
+         enterpriseBean = CurrentManager.rootManager().getNaming().lookup(jndiName, localInterface);
+      }      
+      return enterpriseBean;
+   }
+
 }

Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java	2009-03-12 17:32:50 UTC (rev 1948)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -52,6 +52,22 @@
     */
    public boolean isEntityBean(Class<?> clazz);
    
+   /**
+    * Determines if the object instance is actually a proxy object.
+    * 
+    * @param instance The object which might be a proxy
+    * @return true if the object is a proxy
+    */
    public boolean isProxy(Object instance);
    
+   /**
+    * Retrieves the EJB which implements the local interface provided.
+    * 
+    * @param <T> The local interface type
+    * @param beanType The class of the EJB implementing bean
+    * @param localInterface The business interface of the bean proxy to return
+    * @return the EJB proxy from the container
+    */
+   public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterface);
+   
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.ejb.Local;
+
+ at Local
+public interface AlteStadt
+{
+   public String getPlaceOfInterest();
+   
+   public void performPostConstructChecks();
+   
+   public void initializeBean(GutenbergMuseum pointOfInterest);
+   
+   public GutenbergMuseum getAnotherPlaceOfInterest();
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/AlteStadt.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2009-03-12 17:32:50 UTC (rev 1948)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -120,11 +120,13 @@
       assert interfaces.contains(GeschichtslosStadt.class);
    }
 
-   @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "stub" })
+   @Test(groups = { "enterpriseBeans", "lifecycle", "integration" })
    @SpecAssertion(section = "6.11", id = "a")
    public void testFieldInjectionsOnNonContextualEjbs()
    {
-      assert false;
+      AlteStadt alteStadt = this.getCurrentConfiguration().getBeans().getEnterpriseBean(Mainz.class, AlteStadt.class);
+      assert alteStadt != null : "Could not find the AlteStadt EJB";
+      assert alteStadt.getPlaceOfInterest().equals(RoemerPassage.name);
    }
 
    @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "stub" })
@@ -134,11 +136,13 @@
       assert false;
    }
 
-   @Test(groups = { "enterpriseBeans", "lifecycle", "integration", "stub" })
+   @Test(groups = { "enterpriseBeans", "lifecycle", "integration" })
    @SpecAssertion(section = "6.11", id = "c")
    public void testInitializerMethodsCalledWithCurrentParameterValues()
    {
-      assert false;
+      AlteStadt alteStadt = this.getCurrentConfiguration().getBeans().getEnterpriseBean(Mainz.class, AlteStadt.class);
+      assert alteStadt != null : "Could not find the AlteStadt EJB";
+      assert alteStadt.getAnotherPlaceOfInterest() != null;
    }
 
    @Test(groups = { "enterpriseBeans", "lifecycle", "interceptors", "stub" })

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+public class GutenbergMuseum
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/GutenbergMuseum.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -0,0 +1,40 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Stateless;
+import javax.inject.Current;
+import javax.inject.Initializer;
+
+ at Stateless
+public class Mainz implements AlteStadt
+{
+   @Current
+   private RoemerPassage placeOfInterest;
+   
+   private GutenbergMuseum anotherPlaceOfInterest;
+   
+   private String name;
+
+   public String getPlaceOfInterest()
+   {
+      return name;
+   }
+
+   @PostConstruct
+   public void performPostConstructChecks()
+   {
+      assert placeOfInterest != null : "Injected field is missing";
+      name = placeOfInterest.getName();
+   }
+   
+   @Initializer
+   public void initializeBean(@Current GutenbergMuseum pointOfInterest)
+   {
+      this.anotherPlaceOfInterest = pointOfInterest;
+   }
+
+   public GutenbergMuseum getAnotherPlaceOfInterest()
+   {
+      return anotherPlaceOfInterest;
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/Mainz.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/RoemerPassage.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/RoemerPassage.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/RoemerPassage.java	2009-03-12 22:18:47 UTC (rev 1949)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+
+class RoemerPassage
+{
+   public final static String name = "RoemerPassage";
+   
+   public String getName()
+   {
+      return name;
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/RoemerPassage.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list