You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ba...@apache.org on 2007/12/31 07:55:02 UTC

svn commit: r607689 - /jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java

Author: bayard
Date: Sun Dec 30 22:55:01 2007
New Revision: 607689

URL: http://svn.apache.org/viewvc?rev=607689&view=rev
Log:
Transferred one of the old tests over to JUnit - #43640

Modified:
    jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java

Modified: jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java
URL: http://svn.apache.org/viewvc/jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java?rev=607689&r1=607688&r2=607689&view=diff
==============================================================================
--- jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java (original)
+++ jakarta/taglibs/proper/standard/trunk/test/org/apache/taglibs/standard/lang/jstl/test/StaticFunctionTests.java Sun Dec 30 22:55:01 2007
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */ 
-
 package org.apache.taglibs.standard.lang.jstl.test;
 
 import java.util.HashMap;
@@ -22,46 +21,51 @@
 
 import org.apache.taglibs.standard.lang.jstl.Evaluator;
 
+import junit.framework.TestCase;
+
 /**
- *
  * <p>This class contains some test functions.</p>
  * 
  * @author Shawn Bayern
  */
+public class StaticFunctionTests extends TestCase {
 
-public class StaticFunctionTests {
+  public void testFunctions() throws Exception {
 
-  public static void main(String args[]) throws Exception {
+    System.setProperty("javax.servlet.jsp.functions.allowed", "true");
     Map m = getSampleMethodMap();
     Evaluator e = new Evaluator();
     Object o;
+
     o = e.evaluate("", "4", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("4", o.toString());
     o = e.evaluate("", "${4}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("4", o.toString());
     o = e.evaluate("", "${2+2}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("4", o.toString());
     o = e.evaluate("", "${foo:add(2, 3)}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("5", o.toString());
     o = e.evaluate("", "${foo:multiply(2, 3)}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("6", o.toString());
     o = e.evaluate("", "${add(2, 3)}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("5", o.toString());
     o = e.evaluate("", "${multiply(2, 3)}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("6", o.toString());
     o = e.evaluate("", "${add(2, 3) + 5}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("10", o.toString());
 
-    System.out.println("---");
+    
     o = e.evaluate("", "${getInt(getInteger(getInt(5)))}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("5", o.toString());
+    
     o = e.evaluate("", "${getInteger(getInt(getInteger(5)))}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("5", o.toString());
+    
     o = e.evaluate("", "${getInt(getInt(getInt(5)))}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
+    assertEquals("5", o.toString());
+    
     o = e.evaluate("", "${getInteger(getInteger(getInteger(5)))}", Integer.class, null, null, m, "foo");
-    System.out.println(o);
-
+    assertEquals("5", o.toString());
   }
 
   public static int add(int a, int b) {
@@ -83,14 +87,10 @@
   public static Map getSampleMethodMap() throws Exception {
     Map m = new HashMap();
     Class c = StaticFunctionTests.class;
-    m.put("foo:add",
-     c.getMethod("add", new Class[] { Integer.TYPE, Integer.TYPE }));
-    m.put("foo:multiply",
-     c.getMethod("multiply", new Class[] { Integer.TYPE, Integer.TYPE }));
-    m.put("foo:getInt",
-     c.getMethod("getInt", new Class[] { Integer.class }));
-    m.put("foo:getInteger",
-     c.getMethod("getInteger", new Class[] { Integer.TYPE }));
+    m.put("foo:add", c.getMethod("add", new Class[] { Integer.TYPE, Integer.TYPE }));
+    m.put("foo:multiply", c.getMethod("multiply", new Class[] { Integer.TYPE, Integer.TYPE }));
+    m.put("foo:getInt", c.getMethod("getInt", new Class[] { Integer.class }));
+    m.put("foo:getInteger", c.getMethod("getInteger", new Class[] { Integer.TYPE }));
     return m;
   }
 



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