Author: markt
Date: Mon Jul 8 13:58:50 2013
New Revision: 1500736
URL: http://svn.apache.org/r1500736
Log:
Add a test case for EvaluationListener.propertyResolved() and update the
various resolvers to call the new ELContext.setPropertyResolved(Object, Object)
method
Added:
tomcat/trunk/test/javax/el/TestEvaluationListener.java (with props)
tomcat/trunk/test/javax/el/TesterEvaluationListener.java (with props)
Modified:
tomcat/trunk/java/javax/el/ArrayELResolver.java
tomcat/trunk/java/javax/el/BeanELResolver.java
tomcat/trunk/java/javax/el/BeanNameELResolver.java
tomcat/trunk/java/javax/el/ListELResolver.java
tomcat/trunk/java/javax/el/MapELResolver.java
tomcat/trunk/java/javax/el/ResourceBundleELResolver.java
tomcat/trunk/java/javax/el/StaticFieldELResolver.java
tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java
tomcat/trunk/test/javax/el/TesterELResolverOne.java
tomcat/trunk/test/javax/el/TesterELResolverTwo.java
Modified: tomcat/trunk/java/javax/el/ArrayELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ArrayELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ArrayELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ArrayELResolver.java Mon Jul 8 13:58:50 2013
@@ -41,7 +41,7 @@ public class ArrayELResolver extends ELR
}
if (base != null && base.getClass().isArray()) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
int idx = coerce(property);
checkBounds(base, idx);
return base.getClass().getComponentType();
@@ -57,7 +57,7 @@ public class ArrayELResolver extends ELR
}
if (base != null && base.getClass().isArray()) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
int idx = coerce(property);
if (idx < 0 || idx >= Array.getLength(base)) {
return null;
@@ -76,7 +76,7 @@ public class ArrayELResolver extends ELR
}
if (base != null && base.getClass().isArray()) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (this.readOnly) {
throw new PropertyNotWritableException(Util.message(context,
@@ -103,7 +103,7 @@ public class ArrayELResolver extends ELR
}
if (base != null && base.getClass().isArray()) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
int idx = coerce(property);
checkBounds(base, idx);
}
Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Mon Jul 8 13:58:50 2013
@@ -78,7 +78,7 @@ public class BeanELResolver extends ELRe
return null;
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return this.property(context, base, property).getPropertyType();
}
@@ -91,7 +91,7 @@ public class BeanELResolver extends ELRe
return null;
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
Method m = this.property(context, base, property).read(context);
try {
return m.invoke(base, (Object[]) null);
@@ -122,7 +122,7 @@ public class BeanELResolver extends ELRe
return;
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (this.readOnly) {
throw new PropertyNotWritableException(Util.message(context,
@@ -185,7 +185,7 @@ public class BeanELResolver extends ELRe
throw new ELException(cause);
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, method);
return result;
}
@@ -198,7 +198,7 @@ public class BeanELResolver extends ELRe
return false;
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return this.readOnly
|| this.property(context, base, property).isReadOnly();
}
Modified: tomcat/trunk/java/javax/el/BeanNameELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanNameELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanNameELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanNameELResolver.java Mon Jul 8 13:58:50 2013
@@ -45,7 +45,7 @@ public class BeanNameELResolver extends
if (beanNameResolver.isNameResolved(beanName)) {
try {
Object result = beanNameResolver.getBean((String) property);
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return result;
} catch (Throwable t) {
Util.handleThrowable(t);
@@ -90,7 +90,7 @@ public class BeanNameELResolver extends
beanNameResolver.canCreateBean(beanName)) {
try {
beanNameResolver.setBeanValue(beanName, value);
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
} catch (Throwable t) {
Util.handleThrowable(t);
throw new ELException(t);
@@ -113,7 +113,7 @@ public class BeanNameELResolver extends
try {
if (beanNameResolver.isNameResolved(beanName)) {
Class<?> result =
beanNameResolver.getBean(beanName).getClass();
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return result;
}
} catch (Throwable t) {
@@ -145,7 +145,7 @@ public class BeanNameELResolver extends
Util.handleThrowable(t);
throw new ELException(t);
}
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return result;
}
Modified: tomcat/trunk/java/javax/el/ListELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ListELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ListELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ListELResolver.java Mon Jul 8 13:58:50 2013
@@ -46,7 +46,7 @@ public class ListELResolver extends ELRe
}
if (base instanceof List<?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
List<?> list = (List<?>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
@@ -66,7 +66,7 @@ public class ListELResolver extends ELRe
}
if (base instanceof List<?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
List<?> list = (List<?>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
@@ -86,7 +86,7 @@ public class ListELResolver extends ELRe
}
if (base instanceof List<?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
@SuppressWarnings("unchecked") // Must be OK to cast to Object
List<Object> list = (List<Object>) base;
@@ -113,7 +113,7 @@ public class ListELResolver extends ELRe
}
if (base instanceof List<?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
List<?> list = (List<?>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
Modified: tomcat/trunk/java/javax/el/MapELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/MapELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/MapELResolver.java (original)
+++ tomcat/trunk/java/javax/el/MapELResolver.java Mon Jul 8 13:58:50 2013
@@ -47,7 +47,7 @@ public class MapELResolver extends ELRes
}
if (base instanceof Map<?,?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return Object.class;
}
@@ -61,7 +61,7 @@ public class MapELResolver extends ELRes
}
if (base instanceof Map<?,?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return ((Map<?,?>) base).get(property);
}
@@ -76,7 +76,7 @@ public class MapELResolver extends ELRes
}
if (base instanceof Map<?, ?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (this.readOnly) {
throw new PropertyNotWritableException(Util.message(context,
@@ -100,7 +100,7 @@ public class MapELResolver extends ELRes
}
if (base instanceof Map<?, ?>) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return this.readOnly || UNMODIFIABLE.equals(base.getClass());
}
Modified: tomcat/trunk/java/javax/el/ResourceBundleELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ResourceBundleELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/ResourceBundleELResolver.java (original)
+++ tomcat/trunk/java/javax/el/ResourceBundleELResolver.java Mon Jul 8
13:58:50 2013
@@ -39,7 +39,7 @@ public class ResourceBundleELResolver ex
}
if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (property != null) {
try {
@@ -61,7 +61,7 @@ public class ResourceBundleELResolver ex
}
if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
}
return null;
@@ -75,7 +75,7 @@ public class ResourceBundleELResolver ex
}
if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
throw new PropertyNotWritableException(Util.message(context,
"resolverNotWriteable", base.getClass().getName()));
}
@@ -88,7 +88,7 @@ public class ResourceBundleELResolver ex
}
if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
}
return true;
Modified: tomcat/trunk/java/javax/el/StaticFieldELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/StaticFieldELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/StaticFieldELResolver.java (original)
+++ tomcat/trunk/java/javax/el/StaticFieldELResolver.java Mon Jul 8 13:58:50
2013
@@ -37,7 +37,7 @@ public class StaticFieldELResolver exten
}
if (base instanceof ELClass && property instanceof String) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
Class<?> clazz = ((ELClass) base).getKlass();
String name = (String) property;
@@ -93,7 +93,7 @@ public class StaticFieldELResolver exten
}
if (base instanceof ELClass && method instanceof String) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, method);
Class<?> clazz = ((ELClass) base).getKlass();
String methodName = (String) method;
@@ -156,7 +156,7 @@ public class StaticFieldELResolver exten
}
if (base instanceof ELClass && property instanceof String) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
Class<?> clazz = ((ELClass) base).getKlass();
String name = (String) property;
@@ -191,7 +191,7 @@ public class StaticFieldELResolver exten
}
if (base instanceof ELClass && property instanceof String) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
}
return true;
}
Modified: tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
(original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java Mon
Jul 8 13:58:50 2013
@@ -87,7 +87,7 @@ public class ImplicitObjectELResolver ex
if (idx >= 0) {
PageContext page = (PageContext) context
.getContext(JspContext.class);
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
switch (idx) {
case APPLICATIONSCOPE:
return ScopeManager.get(page).getApplicationScope();
@@ -127,7 +127,7 @@ public class ImplicitObjectELResolver ex
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
if (idx >= 0) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
}
}
return null;
@@ -143,7 +143,7 @@ public class ImplicitObjectELResolver ex
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
if (idx >= 0) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
throw new PropertyNotWritableException();
}
}
@@ -158,7 +158,7 @@ public class ImplicitObjectELResolver ex
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
if (idx >= 0) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return true;
}
}
Modified: tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
(original)
+++ tomcat/trunk/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java Mon
Jul 8 13:58:50 2013
@@ -44,7 +44,7 @@ public class ScopedAttributeELResolver e
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
@@ -64,7 +64,7 @@ public class ScopedAttributeELResolver e
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return Object.class;
}
@@ -79,7 +79,7 @@ public class ScopedAttributeELResolver e
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
@@ -101,7 +101,7 @@ public class ScopedAttributeELResolver e
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
}
return false;
Modified: tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java Mon Jul 8
13:58:50 2013
@@ -43,7 +43,7 @@ public final class ELResolverImpl extend
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (property != null) {
try {
return this.variableResolver.resolveVariable(property
@@ -67,7 +67,7 @@ public final class ELResolverImpl extend
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
if (property != null) {
try {
Object obj = this.variableResolver.resolveVariable(property
@@ -93,7 +93,7 @@ public final class ELResolverImpl extend
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
throw new PropertyNotWritableException(
"Legacy VariableResolver wrapped, not writable");
}
@@ -110,7 +110,7 @@ public final class ELResolverImpl extend
}
if (base == null) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(base, property);
return true;
}
Added: tomcat/trunk/test/javax/el/TestEvaluationListener.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestEvaluationListener.java?rev=1500736&view=auto
==============================================================================
--- tomcat/trunk/test/javax/el/TestEvaluationListener.java (added)
+++ tomcat/trunk/test/javax/el/TestEvaluationListener.java Mon Jul 8 13:58:50
2013
@@ -0,0 +1,80 @@
+/*
+ * 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 javax.el;
+
+import java.util.List;
+
+import javax.el.TesterEvaluationListener.Pair;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestEvaluationListener {
+
+
+ @Test
+ public void testPropertyResolved01() {
+ ELContext context = new TesterELContext();
+ ELResolver resolver = new BeanELResolver();
+ TesterBean bean = new TesterBean("test");
+ TesterEvaluationListener listener = new TesterEvaluationListener();
+
+ context.addEvaluationListener(listener);
+
+ Object result = resolver.getValue(context, bean, "name");
+
+ Assert.assertTrue(context.isPropertyResolved());
+ Assert.assertEquals("test", result);
+ List<Pair> events = listener.getResolvedProperties();
+
+ Assert.assertEquals(1, events.size());
+ Pair p = events.get(0);
+ Assert.assertEquals(bean, p.getBase());
+ Assert.assertEquals("name", p.getProperty());
+ }
+
+
+ @Test
+ public void testPropertyResolved02() {
+ ELContext context = new TesterELContext();
+ ELResolver resolver = new BeanELResolver();
+ TesterBean bean = new TesterBean("test");
+ TesterEvaluationListener listener = new TesterEvaluationListener();
+
+ context.addEvaluationListener(listener);
+
+ Exception exception = null;
+ try {
+ resolver.getValue(context, bean, "foo");
+ } catch (PropertyNotFoundException e) {
+ exception = e;
+ }
+
+ Assert.assertNotNull(exception);
+
+ // Still expect the property to be resolved and the listener to fire
+ // since the vent is at the time of resolution. The EL spec could be a
+ // lot clear on this.
+ Assert.assertTrue(context.isPropertyResolved());
+ List<Pair> events = listener.getResolvedProperties();
+
+ Assert.assertEquals(1, events.size());
+ Pair p = events.get(0);
+ Assert.assertEquals(bean, p.getBase());
+ Assert.assertEquals("foo", p.getProperty());
+ }
+}
Propchange: tomcat/trunk/test/javax/el/TestEvaluationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/test/javax/el/TesterELResolverOne.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TesterELResolverOne.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/test/javax/el/TesterELResolverOne.java (original)
+++ tomcat/trunk/test/javax/el/TesterELResolverOne.java Mon Jul 8 13:58:50 2013
@@ -21,7 +21,7 @@ public class TesterELResolverOne extends
@Override
public Object convertToType(ELContext context, Object obj, Class<?> type) {
if ("1".equals(obj) && type == String.class) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(obj, type);
return "ONE";
}
return null;
Modified: tomcat/trunk/test/javax/el/TesterELResolverTwo.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TesterELResolverTwo.java?rev=1500736&r1=1500735&r2=1500736&view=diff
==============================================================================
--- tomcat/trunk/test/javax/el/TesterELResolverTwo.java (original)
+++ tomcat/trunk/test/javax/el/TesterELResolverTwo.java Mon Jul 8 13:58:50 2013
@@ -21,7 +21,7 @@ public class TesterELResolverTwo extends
@Override
public Object convertToType(ELContext context, Object obj, Class<?> type) {
if ("2".equals(obj) && type == String.class) {
- context.setPropertyResolved(true);
+ context.setPropertyResolved(obj, type);
return "TWO";
}
return null;
Added: tomcat/trunk/test/javax/el/TesterEvaluationListener.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TesterEvaluationListener.java?rev=1500736&view=auto
==============================================================================
--- tomcat/trunk/test/javax/el/TesterEvaluationListener.java (added)
+++ tomcat/trunk/test/javax/el/TesterEvaluationListener.java Mon Jul 8
13:58:50 2013
@@ -0,0 +1,55 @@
+/*
+ * 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 javax.el;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TesterEvaluationListener extends EvaluationListener {
+
+ private final List<Pair> resolvedProperties = new ArrayList<>();
+
+
+ @Override
+ public void propertyResolved(ELContext context, Object base,
+ Object property) {
+ resolvedProperties.add(new Pair(base, property));
+ }
+
+
+ public List<Pair> getResolvedProperties() {
+ return resolvedProperties;
+ }
+
+ public static class Pair {
+ private final Object base;
+ private final Object property;
+
+ public Pair(Object base, Object property) {
+ this.base = base;
+ this.property = property;
+ }
+
+ public Object getBase() {
+ return base;
+ }
+
+ public Object getProperty() {
+ return property;
+ }
+ }
+}
Propchange: tomcat/trunk/test/javax/el/TesterEvaluationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]