myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [myfaces-test] 06/08: MYFACESTEST-4 Unable to call setValue of ValueExpression in test (Thanks to Christoph Göldner for the patch)
Date Thu, 03 May 2018 18:26:19 GMT
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_2
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 869f785c550cdf31903eaa4c6dbdf8151a89cac0
Author: Jakob Korherr <jakobk@apache.org>
AuthorDate: Mon Mar 15 17:46:23 2010 +0000

    MYFACESTEST-4 Unable to call setValue of ValueExpression in test (Thanks to Christoph
Göldner for the patch)
---
 .../myfaces/test/mock/MockApplication12.java       | 11 +++-
 .../myfaces/test/el/MockValueExpressionTest.java   | 63 ++++++++++++++++++++++
 2 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
index 28e4ba5..cdcabfc 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import javax.el.ArrayELResolver;
 import javax.el.BeanELResolver;
@@ -259,8 +260,14 @@ public class MockApplication12 extends MockApplication {
         if (locale == null) {
             locale = Locale.getDefault();
         }
-        return ResourceBundle.getBundle(name, locale);
-
+        try 
+        {
+            return ResourceBundle.getBundle(name, locale);
+        }
+        catch (MissingResourceException e) 
+        {
+            return null;
+        }
     }
 
 
diff --git a/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
b/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
new file mode 100644
index 0000000..d8caeec
--- /dev/null
+++ b/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.test.el;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+
+/**
+ * Test class for ValueExpressions
+ * 
+ * @author Jakob Korherr (latest modification by $Author$)
+ * @author Christoph G�ldner
+ * @version $Revision$ $Date$
+ */
+public class MockValueExpressionTest extends AbstractJsfTestCase
+{
+    
+    public MockValueExpressionTest(String name) 
+    {
+        super(name);
+    }
+
+    public void testSetValue() 
+    {
+        // set value of #{foo} to BAR via ValueExpression
+        ELContext elContext = facesContext.getELContext();
+        ValueExpression ve = application.getExpressionFactory()
+                .createValueExpression(elContext, "#{foo}", String.class);
+        ve.setValue(elContext, "BAR");
+        assertEquals("BAR", externalContext.getRequestMap().get("foo"));
+    }
+
+    public void testGetValue() 
+    {
+        // set value of #{foo} to BAR in request scope
+        externalContext.getRequestMap().put("foo", "BAR");
+        // resolve value of #{foo} via ValueExpression
+        ELContext elContext = facesContext.getELContext();
+        ValueExpression ve = application.getExpressionFactory()
+                .createValueExpression(elContext, "#{foo}", String.class);
+        Object value = ve.getValue(elContext);
+        assertEquals("BAR", value);
+    }
+    
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

Mime
View raw message