myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r513982 - in /myfaces/core/branches/jsf12/impl/src: main/java/org/apache/myfaces/application/ApplicationImpl.java test/java/org/apache/myfaces/application/ApplicationImplTest.java
Date Fri, 02 Mar 2007 22:00:03 GMT
Author: mbr
Date: Fri Mar  2 14:00:03 2007
New Revision: 513982

URL: http://svn.apache.org/viewvc?view=rev&rev=513982
Log:
Application.createComponent(ValueExpression, FacesContext, String) must create a FacesException
if component can not be created

Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?view=diff&rev=513982&r1=513981&r2=513982
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
Fri Mar  2 14:00:03 2007
@@ -283,12 +283,12 @@
 
         ELContext elContext = facesContext.getELContext();
 
-        Object retVal = componentExpression.getValue(elContext);
-
-        UIComponent createdComponent;
-
         try
         {
+            Object retVal = componentExpression.getValue(elContext);
+
+            UIComponent createdComponent;
+
             if (retVal instanceof UIComponent)
             {
                 createdComponent = (UIComponent) retVal;
@@ -298,13 +298,17 @@
                 createdComponent = createComponent(componentType);
                 componentExpression.setValue(elContext, createdComponent);
             }
+
+            return createdComponent;
+        }
+        catch (FacesException e)
+        {
+            throw e;
         }
         catch (Exception e)
         {
             throw new FacesException(e);
         }
-
-        return createdComponent;
     }
 
     @Override

Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java?view=diff&rev=513982&r1=513981&r2=513982
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/application/ApplicationImplTest.java
Fri Mar  2 14:00:03 2007
@@ -142,6 +142,29 @@
         assertTrue(UIOutput.class.isAssignableFrom(app.createComponent(expr, context, "testComponent").getClass()));
     }
 
+    public void testCreateComponentExpressionFacesExceptionTest() throws Exception
+    {
+        ValueExpression expr = createMock(ValueExpression.class);
+        FacesContext context = createMock(FacesContext.class);
+        ELContext elcontext = createMock(ELContext.class);
+        expect(context.getELContext()).andReturn(elcontext);
+        expect(expr.getValue(elcontext)).andThrow(new IllegalArgumentException());
+        replay(context);
+        replay(expr);
+        try
+        {
+            app.createComponent(expr, context, "testComponent");
+        }
+        catch (FacesException e)
+        {
+            // ok
+        }
+        catch (Throwable e)
+        {
+            fail("FacesException expected: " + e.getMessage());
+        }
+    }
+
     private void assertGetResourceBundleWithLocale(final Locale expectedLocale)
     {
         final String var = "test";



Mime
View raw message