myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r524598 - in /myfaces/core/branches/jsf12/impl/src: main/java/org/apache/myfaces/application/ main/java/org/apache/myfaces/el/ test/java/org/apache/myfaces/application/
Date Sun, 01 Apr 2007 14:19:56 GMT
Author: mbr
Date: Sun Apr  1 07:19:55 2007
New Revision: 524598

URL: http://svn.apache.org/viewvc?view=rev&rev=524598
Log:
fix for MYFACES-1579
returned VariableResolver of Application.getVariableResolver() must delegate to application
el resolver
thx Paul McMahan for reporting

Added:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
  (with props)
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=524598&r1=524597&r2=524598
==============================================================================
--- 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
Sun Apr  1 07:19:55 2007
@@ -15,24 +15,15 @@
  */
 package org.apache.myfaces.application;
 
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.application.jsp.JspStateManagerImpl;
-import org.apache.myfaces.application.jsp.JspViewHandlerImpl;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.impl.digester.elements.Property;
-import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
-import org.apache.myfaces.el.PropertyResolverImpl;
-import org.apache.myfaces.el.VariableResolverImpl;
-import org.apache.myfaces.el.convert.MethodExpressionToMethodBinding;
-import org.apache.myfaces.el.convert.ValueBindingToValueExpression;
-import org.apache.myfaces.el.convert.ValueExpressionToValueBinding;
-import org.apache.myfaces.el.unified.ELResolverBuilder;
-import org.apache.myfaces.el.unified.ResolverBuilderForFaces;
-import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
-import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
-import org.apache.myfaces.shared_impl.util.ClassUtils;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
 
 import javax.el.CompositeELResolver;
 import javax.el.ELContext;
@@ -59,15 +50,24 @@
 import javax.faces.event.ActionListener;
 import javax.faces.validator.Validator;
 
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.application.jsp.JspStateManagerImpl;
+import org.apache.myfaces.application.jsp.JspViewHandlerImpl;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.config.impl.digester.elements.Property;
+import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
+import org.apache.myfaces.el.PropertyResolverImpl;
+import org.apache.myfaces.el.VariableResolverToApplicationELResolverAdapter;
+import org.apache.myfaces.el.convert.MethodExpressionToMethodBinding;
+import org.apache.myfaces.el.convert.ValueBindingToValueExpression;
+import org.apache.myfaces.el.convert.ValueExpressionToValueBinding;
+import org.apache.myfaces.el.unified.ELResolverBuilder;
+import org.apache.myfaces.el.unified.ResolverBuilderForFaces;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver;
+import org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.Scope;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
 
 /**
  * DOCUMENT ME!
@@ -83,7 +83,7 @@
 {
     private static final Log log = LogFactory.getLog(ApplicationImpl.class);
 
-    private final static VariableResolver VARIABLERESOLVER = new VariableResolverImpl();
+    private final static VariableResolver VARIABLERESOLVER = new VariableResolverToApplicationELResolverAdapter();
 
     private final static PropertyResolver PROPERTYRESOLVER = new PropertyResolverImpl();
 
@@ -836,9 +836,9 @@
     {
         checkNull(reference, "reference");
         checkEmpty(reference, "reference");
-        
+
         // TODO: this check should be performed by the expression factory. It is a requirement
of the TCK
-        if(! (reference.startsWith("#{") && reference.endsWith("}")))
+        if (!(reference.startsWith("#{") && reference.endsWith("}")))
         {
             throw new ReferenceSyntaxException("Invalid method reference: '" + reference
+ "'");
         }

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java?view=auto&rev=524598
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
Sun Apr  1 07:19:55 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.el;
+
+import javax.el.ELException;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+
+import org.apache.myfaces.shared_impl.util.Assert;
+
+/**
+ * This class is used to delegate {@link #resolveVariable(FacesContext, String)} to the el
resolver of the application.
+ * 
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class VariableResolverToApplicationELResolverAdapter extends VariableResolver
+{
+    @Override
+    public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException
+    {
+        Assert.notNull(facesContext, "facesContext");
+        Assert.notNull(name, "name");
+
+        try
+        {
+            return facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(),
null, name);
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e);
+        }
+    }
+
+}

Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/VariableResolverToApplicationELResolverAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=524598&r1=524597&r2=524598
==============================================================================
--- 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
Sun Apr  1 07:19:55 2007
@@ -19,29 +19,32 @@
 package org.apache.myfaces.application;
 
 import static org.apache.myfaces.test.AssertThrowables.assertThrowable;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.EasyMock.*;
+import static org.easymock.classextension.EasyMock.*;
 
 import java.util.ListResourceBundle;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
 import javax.el.ELContext;
+import javax.el.ELResolver;
 import javax.el.ValueExpression;
 import javax.faces.FacesException;
+import javax.faces.application.Application;
 import javax.faces.component.UIOutput;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.VariableResolver;
 
 import junit.framework.TestCase;
 
 import org.apache.myfaces.config.RuntimeConfig;
 import org.apache.myfaces.test.TestRunnable;
-import org.apache.shale.test.mock.MockFacesContext;
+import org.apache.shale.test.el.MockELContext;
+import org.apache.shale.test.mock.MockFacesContext12;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
 
 /**
  * @author Mathias Broekelmann (latest modification by $Author$)
@@ -51,12 +54,12 @@
 {
 
     private ApplicationImpl app;
-    private MockFacesContext context;
+    private MockFacesContext12 context;
 
     protected void setUp() throws Exception
     {
         app = new ApplicationImpl(new RuntimeConfig());
-        context = new MockFacesContext();
+        context = new MockFacesContext12();
     }
     
     public void testCreateMethodBinding() throws Exception
@@ -174,6 +177,21 @@
         {
             fail("FacesException expected: " + e.getMessage());
         }
+    }
+    
+    public void testGetVariableResolver() throws Exception
+    {
+        VariableResolver variableResolver = app.getVariableResolver();
+        assertNotNull(variableResolver);
+        IMocksControl mocksControl = EasyMock.createControl();
+        Application mockApp = mocksControl.createMock(Application.class);
+        context.setApplication(mockApp);        
+        ELResolver elResolver = mocksControl.createMock(ELResolver.class);
+        expect(mockApp.getELResolver()).andReturn(elResolver);
+        context.setELContext(new MockELContext());
+        expect(elResolver.getValue(eq(context.getELContext()), isNull(), eq("xxx"))).andReturn("testValue");
+        mocksControl.replay();
+        assertEquals("testValue", variableResolver.resolveVariable(context, "xxx"));
     }
 
     private void assertGetResourceBundleWithLocale(final Locale expectedLocale)



Mime
View raw message