[webbeans-commits] Webbeans SVN: r1750 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Mar 2 09:12:02 EST 2009


Author: dallen6
Date: 2009-03-02 09:12:02 -0500 (Mon, 02 Mar 2009)
New Revision: 1750

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java
Log:
Corrected some observer method/dependent context tests and fixed problem with invoking observer methods on session beans.

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/Exceptions.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -57,42 +57,42 @@
    
    public static void rethrowException(IllegalArgumentException e)
    {
-       rethrowException(e.getCause());
+       rethrowException(e.getCause() != null ? e.getCause() : e);
    }
    
    public static void rethrowException(IllegalArgumentException e, Class<? extends RuntimeException> exceptionToThrow)
    {
-       rethrowException(e.getCause(), exceptionToThrow);
+       rethrowException(e.getCause() != null ? e.getCause() : e, exceptionToThrow);
    }
    
    public static void rethrowException(InstantiationException e, Class<? extends RuntimeException> exceptionToThrow)
    {
-       rethrowException(e.getCause(), exceptionToThrow);
+       rethrowException(e.getCause() != null ? e.getCause() : e, exceptionToThrow);
    }
    
    public static void rethrowException(InstantiationException e)
    {
-       rethrowException(e.getCause());
+       rethrowException(e.getCause() != null ? e.getCause() : e);
    }
    
    public static void rethrowException(IllegalAccessException e)
    {
-       rethrowException(e.getCause());
+       rethrowException(e.getCause() != null ? e.getCause() : e);
    }
    
    public static void rethrowException(IllegalAccessException e, Class<? extends RuntimeException> exceptionToThrow)
    {
-       rethrowException(e.getCause(), exceptionToThrow);
+       rethrowException(e.getCause() != null ? e.getCause() : e, exceptionToThrow);
    }
    
    public static void rethrowException(InvocationTargetException e, Class<? extends RuntimeException> exceptionToThrow)
    {
-       rethrowException(e.getCause(), exceptionToThrow);
+       rethrowException(e.getCause() != null ? e.getCause() : e, exceptionToThrow);
    }
    
    public static void rethrowException(InvocationTargetException e)
    {
-       rethrowException(e.getCause());
+       rethrowException(e.getCause() != null ? e.getCause() : e);
    }
    
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -33,6 +33,7 @@
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 import org.jboss.webbeans.introspector.ForwardingAnnotatedMethod;
+import org.jboss.webbeans.util.Reflections;
 
 public class MethodInjectionPoint<T> extends ForwardingAnnotatedMethod<T> implements AnnotatedInjectionPoint<T, Method>
 {
@@ -116,11 +117,20 @@
       return null;
    }
    
+   @SuppressWarnings("unchecked")
    public T invokeWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
    {
       try
       {
-         return delegate().invoke(declaringInstance, getParameterValues(getParameters(), annotatedParameter, parameter, manager, creationalContext));
+         if (delegate().getDeclaringClass().getType().equals(declaringInstance.getClass()))
+         {
+            return delegate().invoke(declaringInstance, getParameterValues(getParameters(), annotatedParameter, parameter, manager, creationalContext));
+         }
+         else
+         {
+            Method proxiedMethod = Reflections.lookupMethod(delegate().getAnnotatedMethod(), declaringInstance);
+            return (T) proxiedMethod.invoke(declaringInstance, getParameterValues(getParameters(), annotatedParameter, parameter, manager, creationalContext));
+         }
       }
       catch (IllegalArgumentException e)
       {

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -85,10 +85,11 @@
       getCurrentManager().getContext(Unregistered.class);
    }
 
-   @Test(groups = { "manager" })
+   @Test(groups = { "manager", "broken" })
    @SpecAssertion(section = "8.6", id = "b")
    public void testGetContextReturnsActiveContext()
    {
+      //TODO This is not testing the assertion at all
       getCurrentManager().getContext(RequestScoped.class);
    }
 

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -216,7 +216,7 @@
 
    @Test(groups = { "contexts", "observerMethod" })
    @SpecAssertion(section = "8.3", id = "g")
-   public void testContextIsActiveWhenInvokingObserverMethod()
+   public void testContextIsActiveWhenCreatingObserverMethodInstance()
    {
       getCurrentManager().fireEvent(new HorseInStableEvent());
       assert HorseStable.isDependentContextActive();
@@ -241,7 +241,7 @@
 
    @Test(groups = { "contexts", "observerMethod" })
    @SpecAssertion(section = "8.3", id = "i")
-   public void testContextIsActiveWhenInvokingObserver()
+   public void testContextIsActiveWhenInvokingObserverMethod()
    {
       getCurrentManager().fireEvent(new HorseInStableEvent());
       assert ApplicationHorseStable.isDependentContextActive();

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -3,22 +3,26 @@
 import javax.context.Dependent;
 import javax.event.Observes;
 import javax.inject.Current;
+import javax.inject.Initializer;
 import javax.inject.manager.Manager;
 
 @Dependent
 class HorseStable
 {
-   @Current
-   private Manager manager;
    private static boolean dependentContextActive = false;
    private static HorseStable instanceThatObservedEvent = null;
-   
-   public void horseEntered(@Observes HorseInStableEvent horseEvent)
+
+   @Initializer
+   public HorseStable(@Current Manager manager)
    {
       if (manager.getContext(Dependent.class).isActive())
       {
          dependentContextActive = true;
       }
+   }
+
+   public void horseEntered(@Observes HorseInStableEvent horseEvent)
+   {
       instanceThatObservedEvent = this;
    }
 

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -333,9 +333,7 @@
       assert beans != null;
    }
 
-   // TODO This test was working well in January 2009 but no longer creates the
-   // observer
-   @Test(groups = { "events", "broken" })
+   @Test(groups = { "events" })
    @SpecAssertions( { @SpecAssertion(section = "7.5.5", id = "a"), @SpecAssertion(section = "7.5.5", id = "b")} )
    public void testConditionalObserver() throws Exception
    {
@@ -353,9 +351,11 @@
          {
             RecluseSpider bean = getCurrentManager().getInstanceByType(RecluseSpider.class);
             assert bean != null;
+            // Must invoke a method to really create the instance
+            assert !bean.isNotified();
 
             getCurrentManager().fireEvent(new ConditionalEvent());
-            assert RecluseSpider.notified;
+            assert bean.isNotified();
          }
 
       }.run();

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java	2009-03-01 22:13:29 UTC (rev 1749)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/RecluseSpider.java	2009-03-02 14:12:02 UTC (rev 1750)
@@ -1,5 +1,6 @@
 package org.jboss.jsr299.tck.tests.event;
 
+import javax.context.RequestScoped;
 import javax.event.IfExists;
 import javax.event.Observes;
 
@@ -7,6 +8,7 @@
  * Simple web bean that conditionally listens to events.
  *
  */
+ at RequestScoped
 class RecluseSpider
 {
    public static boolean notified = false;
@@ -16,4 +18,8 @@
       notified = true;
    }
    
+   public boolean isNotified()
+   {
+      return notified;
+   }
 }




More information about the weld-commits mailing list