You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/03/15 18:46:23 UTC
svn commit: r923361 - in /myfaces/test/trunk/test12/src:
main/java/org/apache/myfaces/test/mock/MockApplication12.java
test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
Author: jakobk
Date: Mon Mar 15 17:46:23 2010
New Revision: 923361
URL: http://svn.apache.org/viewvc?rev=923361&view=rev
Log:
MYFACESTEST-4 Unable to call setValue of ValueExpression in test (Thanks to Christoph Göldner for the patch)
Added:
myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java (with props)
Modified:
myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java?rev=923361&r1=923360&r2=923361&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java Mon Mar 15 17:46:23 2010
@@ -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 M
if (locale == null) {
locale = Locale.getDefault();
}
- return ResourceBundle.getBundle(name, locale);
-
+ try
+ {
+ return ResourceBundle.getBundle(name, locale);
+ }
+ catch (MissingResourceException e)
+ {
+ return null;
+ }
}
Added: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java?rev=923361&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java (added)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java Mon Mar 15 17:46:23 2010
@@ -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 Gldner
+ * @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);
+ }
+
+}
Propchange: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain