[webbeans-commits] Webbeans SVN: r2682 - in ri/trunk: tests/src/test/java/org/jboss/webbeans/test/unit/definition and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon May 11 15:59:27 EDT 2009


Author: dan.j.allen
Date: 2009-05-11 15:59:27 -0400 (Mon, 11 May 2009)
New Revision: 2682

Added:
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/Beer.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/BeerProducer.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java
Log:
WBRI-261


Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java	2009-05-11 19:28:07 UTC (rev 2681)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java	2009-05-11 19:59:27 UTC (rev 2682)
@@ -108,6 +108,11 @@
                return namespace.get(propertyString);
             }
          }
+         else
+         {
+            // let the standard EL resolver chain handle the property
+            return null;
+         }
          final String name;
          if (namespace != null)
          {

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/Beer.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/Beer.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/Beer.java	2009-05-11 19:59:27 UTC (rev 2682)
@@ -0,0 +1,30 @@
+package org.jboss.webbeans.test.unit.definition;
+
+import javax.annotation.Named;
+
+public
+ at Named
+class Beer
+{
+   private String name = "Chimay Grande Reserve (Blue)";
+   
+   private String style = "Belgium Strong Dark Ale";
+
+   public Beer() {}
+   
+   public Beer(String name, String style)
+   {
+      this.name = name;
+      this.style = style;
+   }
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public String getStyle()
+   {
+      return style;
+   }
+}

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/BeerProducer.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/BeerProducer.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/BeerProducer.java	2009-05-11 19:59:27 UTC (rev 2682)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.test.unit.definition;
+
+import javax.annotation.Named;
+import javax.inject.Produces;
+
+public class BeerProducer
+{
+   public
+   @Produces
+   @Named
+   Beer getBeerOnTap()
+   {
+      return new Beer("Dragon's Breathe", "IPA");
+   }
+   
+   public
+   @Produces
+   @Named
+   String getStyle()
+   {
+      return "Bogus!";
+   }
+}

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java	2009-05-11 19:28:07 UTC (rev 2681)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java	2009-05-11 19:59:27 UTC (rev 2682)
@@ -1,12 +1,21 @@
 package org.jboss.webbeans.test.unit.definition;
 
+import static org.testng.Assert.*;
+
 import javax.el.ELContext;
+import javax.el.ExpressionFactory;
 
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.webbeans.mock.el.EL;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
+/**
+ * Test the WebBeansELResolver and that it collaborates with the standard EL resolver chain.
+ * 
+ * @author Pete Muir
+ * @author Dan Allen
+ */
 @Artifact
 public class ELResolverTest extends AbstractWebBeansTest
 {
@@ -18,4 +27,38 @@
       assert EL.EXPRESSION_FACTORY.createValueExpression(elContext, "#{foo.bar}", Object.class).getValue(elContext) == null;
    }
    
+   /**
+    * Test that the WebBeansELResolver only works to resolve the base of an EL
+    * expression, in this case a named bean. Once the base is resolved, the
+    * remainder of the expression should be delegated to the standard chain of
+    * property resolvers. If the WebBeansELResolver oversteps its bounds by
+    * trying to resolve the property against the Web Beans namespace, the test
+    * will fail.
+    */
+   @Test
+   public void testResolveBeanPropertyOfNamedBean()
+   {
+      ELContext elContext = EL.createELContext();
+      ExpressionFactory exprFactory = EL.EXPRESSION_FACTORY;
+      
+      assertEquals(exprFactory.createValueExpression(elContext, "#{beer.style}", String.class).getValue(elContext), "Belgium Strong Dark Ale");
+   }
+
+   /**
+    * Test that the WebBeansELResolver only works to resolve the base of an EL
+    * expression, in this case from a producer method. Once the base is
+    * resolved, the remainder of the expression should be delegated to the
+    * standard chain of property resolvers. If the WebBeansELResolver oversteps
+    * its bounds by trying to resolve the property against the Web Beans
+    * namespace, the test will fail.
+    */
+   @Test
+   public void testResolveBeanPropertyOfProducerBean()
+   {
+      ELContext elContext = EL.createELContext();
+      ExpressionFactory exprFactory = EL.EXPRESSION_FACTORY;
+      
+      assertEquals(exprFactory.createValueExpression(elContext, "#{beerOnTap.style}", String.class).getValue(elContext), "IPA");
+   }
+   
 }




More information about the weld-commits mailing list