You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/12/01 11:39:44 UTC

svn commit: r1772174 - in /tomcat/trunk/test/org/apache: el/TestELEvaluation.java el/TesterFunctions.java jasper/compiler/TestAttributeParser.java

Author: markt
Date: Thu Dec  1 11:39:44 2016
New Revision: 1772174

URL: http://svn.apache.org/viewvc?rev=1772174&view=rev
Log:
Refactor to remove duplicated code

Modified:
    tomcat/trunk/test/org/apache/el/TestELEvaluation.java
    tomcat/trunk/test/org/apache/el/TesterFunctions.java
    tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java

Modified: tomcat/trunk/test/org/apache/el/TestELEvaluation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELEvaluation.java?rev=1772174&r1=1772173&r2=1772174&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestELEvaluation.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELEvaluation.java Thu Dec  1 11:39:44 2016
@@ -18,11 +18,9 @@
 package org.apache.el;
 
 import java.io.File;
-import java.lang.reflect.Method;
 import java.util.Date;
 
 import javax.el.ELException;
-import javax.el.FunctionMapper;
 import javax.el.ValueExpression;
 
 import static org.junit.Assert.assertEquals;
@@ -239,28 +237,9 @@ public class TestELEvaluation {
     private String evaluateExpression(String expression) {
         ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
         ELContextImpl ctx = new ELContextImpl(exprFactory);
-        ctx.setFunctionMapper(new FMapper());
+        ctx.setFunctionMapper(new TesterFunctions.FMapper());
         ValueExpression ve = exprFactory.createValueExpression(ctx, expression,
                 String.class);
         return (String) ve.getValue(ctx);
     }
-
-    public static class FMapper extends FunctionMapper {
-
-        @Override
-        public Method resolveFunction(String prefix, String localName) {
-            if ("trim".equals(localName)) {
-                Method m;
-                try {
-                    m = TesterFunctions.class.getMethod("trim", String.class);
-                    return m;
-                } catch (SecurityException e) {
-                    // Ignore
-                } catch (NoSuchMethodException e) {
-                    // Ignore
-                }
-            }
-            return null;
-        }
-    }
 }

Modified: tomcat/trunk/test/org/apache/el/TesterFunctions.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TesterFunctions.java?rev=1772174&r1=1772173&r2=1772174&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TesterFunctions.java (original)
+++ tomcat/trunk/test/org/apache/el/TesterFunctions.java Thu Dec  1 11:39:44 2016
@@ -17,6 +17,10 @@
 
 package org.apache.el;
 
+import java.lang.reflect.Method;
+
+import javax.el.FunctionMapper;
+
 public class TesterFunctions {
     public static String trim(String input) {
         return input.trim();
@@ -41,4 +45,24 @@ public class TesterFunctions {
             return RETVAL;
         }
     }
+
+
+    public static class FMapper extends FunctionMapper {
+
+        @Override
+        public Method resolveFunction(String prefix, String localName) {
+            if ("trim".equals(localName)) {
+                Method m;
+                try {
+                    m = TesterFunctions.class.getMethod("trim", String.class);
+                    return m;
+                } catch (SecurityException e) {
+                    // Ignore
+                } catch (NoSuchMethodException e) {
+                    // Ignore
+                }
+            }
+            return null;
+        }
+    }
 }

Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java?rev=1772174&r1=1772173&r2=1772174&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java Thu Dec  1 11:39:44 2016
@@ -17,9 +17,6 @@
 
 package org.apache.jasper.compiler;
 
-import java.lang.reflect.Method;
-
-import javax.el.FunctionMapper;
 import javax.el.ValueExpression;
 
 import static org.junit.Assert.assertEquals;
@@ -168,7 +165,7 @@ public class TestAttributeParser {
 
         ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
         ELContextImpl ctx = new ELContextImpl(exprFactory);
-        ctx.setFunctionMapper(new FMapper());
+        ctx.setFunctionMapper(new TesterFunctions.FMapper());
         ValueExpression ve = exprFactory.createValueExpression(ctx,
                 AttributeParser.getUnquoted(expression, quote, false, false,
                         false, false),
@@ -180,23 +177,4 @@ public class TestAttributeParser {
         return AttributeParser.getUnquoted(expression, quote, false, false,
                 false, false);
     }
-
-    public static class FMapper extends FunctionMapper {
-
-        @Override
-        public Method resolveFunction(String prefix, String localName) {
-            if ("trim".equals(localName)) {
-                Method m;
-                try {
-                    m = TesterFunctions.class.getMethod("trim", String.class);
-                    return m;
-                } catch (SecurityException e) {
-                    // Ignore
-                } catch (NoSuchMethodException e) {
-                    // Ignore
-                }
-            }
-            return null;
-        }
-    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org