Author: kkolinko Date: Mon Jul 25 15:57:51 2011 New Revision: 1150761 URL: http://svn.apache.org/viewvc?rev=1150761&view=rev Log: Converted the tests to JUnit 4.
Modified: tomcat/trunk/test/org/apache/el/TestELEvaluation.java tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java tomcat/trunk/test/org/apache/el/lang/TestELSupport.java tomcat/trunk/test/org/apache/el/parser/TestELParser.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=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/TestELEvaluation.java (original) +++ tomcat/trunk/test/org/apache/el/TestELEvaluation.java Mon Jul 25 15:57:51 2011 @@ -25,7 +25,12 @@ import javax.el.ELException; import javax.el.FunctionMapper; import javax.el.ValueExpression; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; import org.apache.el.lang.ELSupport; import org.apache.jasper.el.ELContextImpl; @@ -35,12 +40,13 @@ import org.apache.jasper.el.ELContextImp * {@link org.apache.jasper.compiler.TestAttributeParser} and * {@link TestELInJsp}. */ -public class TestELEvaluation extends TestCase { +public class TestELEvaluation { /** * Test use of spaces in ternary expressions. This was primarily an EL * parser bug. */ + @Test public void testBug42565() { assertEquals("false", evaluateExpression("${false?true:false}")); assertEquals("false", evaluateExpression("${false?true: false}")); @@ -64,6 +70,7 @@ public class TestELEvaluation extends Te /** * Test use nested ternary expressions. This was primarily an EL parser bug. */ + @Test public void testBug44994() { assertEquals("none", evaluateExpression( "${0 lt 0 ? 1 lt 0 ? 'many': 'one': 'none'}")); @@ -72,8 +79,8 @@ public class TestELEvaluation extends Te assertEquals("many", evaluateExpression( "${0 lt 2 ? 1 lt 2 ? 'many': 'one': 'none'}")); } - - + + @Test public void testParserBug45511() { // Test cases provided by OP assertEquals("true", evaluateExpression("${empty ('')}")); @@ -82,11 +89,13 @@ public class TestELEvaluation extends Te assertEquals("false", evaluateExpression("${(true)and(false)}")); } + @Test public void testBug48112() { // bug 48112 assertEquals("{world}", evaluateExpression("${fn:trim('{world}')}")); } + @Test public void testParserLiteralExpression() { // Inspired by work on bug 45451, comments from kkolinko on the dev // list and looking at the spec to find some edge cases @@ -111,6 +120,7 @@ public class TestELEvaluation extends Te assertEquals("\\#{", evaluateExpression("\\\\#{")); } + @Test public void testParserStringLiteral() { // Inspired by work on bug 45451, comments from kkolinko on the dev // list and looking at the spec to find some edge cases @@ -154,6 +164,7 @@ public class TestELEvaluation extends Te assertEquals(msg,expected, -i2); } + @Test public void testElSupportCompare(){ compareBoth("Nulls should compare equal", 0, null, null); compareBoth("Null should compare equal to \"\"", 0, "", null); @@ -172,6 +183,7 @@ public class TestELEvaluation extends Te /** * Test mixing ${...} and #{...} in the same expression. */ + @Test public void testMixedTypes() { // Mixing types should throw an error Exception e = null; Modified: tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java?rev=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java (original) +++ tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java Mon Jul 25 15:57:51 2011 @@ -22,16 +22,22 @@ import javax.el.ExpressionFactory; import javax.el.MethodExpression; import javax.el.ValueExpression; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; import org.apache.jasper.el.ELContextImpl; -public class TestMethodExpressionImpl extends TestCase { +public class TestMethodExpressionImpl { private ExpressionFactory factory; private ELContext context; - - @Override + + @Before public void setUp() { factory = ExpressionFactory.newInstance(); context = new ELContextImpl(); @@ -70,7 +76,8 @@ public class TestMethodExpressionImpl ex context.getVariableMapper().setVariable("beanC", factory.createValueExpression(beanC, TesterBeanC.class)); } - + + @Test public void testIsParametersProvided() { TesterBeanB beanB = new TesterBeanB(); beanB.setName("Tomcat"); @@ -88,6 +95,7 @@ public class TestMethodExpressionImpl ex assertTrue(me2.isParmetersProvided()); } + @Test public void testInvoke() { TesterBeanB beanB = new TesterBeanB(); beanB.setName("B"); @@ -116,6 +124,7 @@ public class TestMethodExpressionImpl ex me3.invoke(context, new Object[] { null })); } + @Test public void testInvokeWithSuper() { MethodExpression me = factory.createMethodExpression(context, "${beanA.setBean(beanBB)}", null , @@ -126,21 +135,24 @@ public class TestMethodExpressionImpl ex Object r = ve.getValue(context); assertEquals("BB", r); } - + + @Test public void testInvokeWithSuperABNoReturnTypeNoParamTypes() { MethodExpression me2 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", null , null); Object r2 = me2.invoke(context, null); assertEquals("AB: Hello A from B", r2.toString()); } - + + @Test public void testInvokeWithSuperABReturnTypeNoParamTypes() { MethodExpression me3 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", String.class , null); Object r3 = me3.invoke(context, null); assertEquals("AB: Hello A from B", r3.toString()); } - + + @Test public void testInvokeWithSuperABNoReturnTypeParamTypes() { MethodExpression me4 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", null , @@ -148,7 +160,8 @@ public class TestMethodExpressionImpl ex Object r4 = me4.invoke(context, null); assertEquals("AB: Hello A from B", r4.toString()); } - + + @Test public void testInvokeWithSuperABReturnTypeParamTypes() { MethodExpression me5 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB)}", String.class , @@ -156,28 +169,32 @@ public class TestMethodExpressionImpl ex Object r5 = me5.invoke(context, null); assertEquals("AB: Hello A from B", r5.toString()); } - + + @Test public void testInvokeWithSuperABB() { MethodExpression me6 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBB)}", null , null); Object r6 = me6.invoke(context, null); assertEquals("ABB: Hello A from BB", r6.toString()); } - + + @Test public void testInvokeWithSuperABBB() { MethodExpression me7 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBBB)}", null , null); Object r7 = me7.invoke(context, null); assertEquals("ABB: Hello A from BBB", r7.toString()); } - + + @Test public void testInvokeWithSuperAAB() { MethodExpression me8 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanB)}", null , null); Object r8 = me8.invoke(context, null); assertEquals("AAB: Hello AA from B", r8.toString()); } - + + @Test public void testInvokeWithSuperAABB() { MethodExpression me9 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBB)}", null , null); @@ -190,7 +207,8 @@ public class TestMethodExpressionImpl ex // Expected to fail assertNotNull(e); } - + + @Test public void testInvokeWithSuperAABBB() { // The Java compiler reports this as ambiguous. Using the parameter that // matches exactly seems reasonable to limit the scope of the method @@ -200,14 +218,16 @@ public class TestMethodExpressionImpl ex Object r10 = me10.invoke(context, null); assertEquals("AAB: Hello AA from BBB", r10.toString()); } - + + @Test public void testInvokeWithSuperAAAB() { MethodExpression me11 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanB)}", null , null); Object r11 = me11.invoke(context, null); assertEquals("AAB: Hello AAA from B", r11.toString()); } - + + @Test public void testInvokeWithSuperAAABB() { // The Java compiler reports this as ambiguous. Using the parameter that // matches exactly seems reasonable to limit the scope of the method @@ -217,7 +237,8 @@ public class TestMethodExpressionImpl ex Object r12 = me12.invoke(context, null); assertEquals("ABB: Hello AAA from BB", r12.toString()); } - + + @Test public void testInvokeWithSuperAAABBB() { MethodExpression me13 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBBB)}", null , null); @@ -230,7 +251,8 @@ public class TestMethodExpressionImpl ex // Expected to fail assertNotNull(e); } - + + @Test public void testInvokeWithVarArgsAB() throws Exception { MethodExpression me1 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanB,beanB)}", null , null); @@ -243,21 +265,24 @@ public class TestMethodExpressionImpl ex // Expected to fail assertNotNull(e); } - + + @Test public void testInvokeWithVarArgsABB() throws Exception { MethodExpression me2 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBB,beanBB)}", null , null); Object r2 = me2.invoke(context, null); assertEquals("ABB[]: Hello A from BB, BB", r2.toString()); } - + + @Test public void testInvokeWithVarArgsABBB() throws Exception { MethodExpression me3 = factory.createMethodExpression(context, "${beanC.sayHello(beanA,beanBBB,beanBBB)}", null , null); Object r3 = me3.invoke(context, null); assertEquals("ABB[]: Hello A from BBB, BBB", r3.toString()); } - + + @Test public void testInvokeWithVarArgsAAB() throws Exception { MethodExpression me4 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanB,beanB)}", null , null); @@ -270,21 +295,24 @@ public class TestMethodExpressionImpl ex // Expected to fail assertNotNull(e); } - + + @Test public void testInvokeWithVarArgsAABB() throws Exception { MethodExpression me5 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBB,beanBB)}", null , null); Object r5 = me5.invoke(context, null); assertEquals("ABB[]: Hello AA from BB, BB", r5.toString()); } - + + @Test public void testInvokeWithVarArgsAABBB() throws Exception { MethodExpression me6 = factory.createMethodExpression(context, "${beanC.sayHello(beanAA,beanBBB,beanBBB)}", null , null); Object r6 = me6.invoke(context, null); assertEquals("ABB[]: Hello AA from BBB, BBB", r6.toString()); } - + + @Test public void testInvokeWithVarArgsAAAB() throws Exception { MethodExpression me7 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanB,beanB)}", null , null); @@ -297,25 +325,28 @@ public class TestMethodExpressionImpl ex // Expected to fail assertNotNull(e); } - + + @Test public void testInvokeWithVarArgsAAABB() throws Exception { MethodExpression me8 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBB,beanBB)}", null , null); Object r8 = me8.invoke(context, null); assertEquals("ABB[]: Hello AAA from BB, BB", r8.toString()); } - + + @Test public void testInvokeWithVarArgsAAABBB() throws Exception { MethodExpression me9 = factory.createMethodExpression(context, "${beanC.sayHello(beanAAA,beanBBB,beanBBB)}", null , null); Object r9 = me9.invoke(context, null); assertEquals("ABB[]: Hello AAA from BBB, BBB", r9.toString()); } - + /* * This is also tested implicitly in numerous places elsewhere in this * class. */ + @Test public void testBug49655() throws Exception { // This is the call the failed MethodExpression me = factory.createMethodExpression(context, @@ -326,7 +357,8 @@ public class TestMethodExpressionImpl ex "#{beanA.name}", java.lang.String.class); assertEquals("New value", ve.getValue(context)); } - + + @Test public void testBugPrimitives() throws Exception { MethodExpression me = factory.createMethodExpression(context, "${beanA.setValLong(5)}", null, null); @@ -335,7 +367,8 @@ public class TestMethodExpressionImpl ex "#{beanA.valLong}", java.lang.String.class); assertEquals("5", ve.getValue(context)); } - + + @Test public void testBug50449a() throws Exception { MethodExpression me1 = factory.createMethodExpression(context, "${beanB.sayHello()}", null, null); @@ -343,13 +376,15 @@ public class TestMethodExpressionImpl ex assertEquals("Hello from B", actual); } + @Test public void testBug50449b() throws Exception { MethodExpression me1 = factory.createMethodExpression(context, "${beanB.sayHello('Tomcat')}", null, null); String actual = (String) me1.invoke(context, null); assertEquals("Hello Tomcat from B", actual); } - + + @Test public void testBug50790a() throws Exception { ValueExpression ve = factory.createValueExpression(context, "#{beanAA.name.contains(beanA.name)}", java.lang.Boolean.class); @@ -357,6 +392,7 @@ public class TestMethodExpressionImpl ex assertEquals(Boolean.TRUE, actual); } + @Test public void testBug50790b() throws Exception { ValueExpression ve = factory.createValueExpression(context, "#{beanA.name.contains(beanAA.name)}", java.lang.Boolean.class); Modified: tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java?rev=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java (original) +++ tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java Mon Jul 25 15:57:51 2011 @@ -28,12 +28,16 @@ import javax.el.ExpressionFactory; import javax.el.ValueExpression; import javax.el.ValueReference; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; import org.apache.jasper.el.ELContextImpl; -public class TestValueExpressionImpl extends TestCase { +public class TestValueExpressionImpl { + @Test public void testGetValueReference() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -59,7 +63,7 @@ public class TestValueExpressionImpl ext assertEquals("name", vr.getProperty()); } - + @Test public void testBug49345() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -88,7 +92,7 @@ public class TestValueExpressionImpl ext assertEquals("name", vr.getProperty()); } - + @Test public void testBug50105() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -111,6 +115,7 @@ public class TestValueExpressionImpl ext assertEquals("fooAPPLEbar", result2); } + @Test public void testBug51177ObjectMap() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -136,7 +141,8 @@ public class TestValueExpressionImpl ext ve2.setValue(context, o1); assertEquals(o1, ve2.getValue(context)); } - + + @Test public void testBug51177ObjectList() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -167,6 +173,7 @@ public class TestValueExpressionImpl ext /** * Test returning an empty list as a bean property. */ + @Test public void testBug51544Bean() throws Exception { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -189,6 +196,7 @@ public class TestValueExpressionImpl ext /** * Test using list directly as variable. */ + @Test public void testBug51544Direct() throws Exception { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); Modified: tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java?rev=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java (original) +++ tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java Mon Jul 25 15:57:51 2011 @@ -19,64 +19,78 @@ package org.apache.el.lang; import java.math.BigDecimal; import java.math.BigInteger; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; -public class TestELArithmetic extends TestCase { +import org.junit.Test; + +public class TestELArithmetic { private static final String a = "1.1"; private static final BigInteger b = new BigInteger("1000000000000000000000"); + @Test public void testAdd() throws Exception { assertEquals("1000000000000000000001.1", String.valueOf(ELArithmetic.add(a, b))); } + @Test public void testSubtract() throws Exception { assertEquals("-999999999999999999998.9", String.valueOf(ELArithmetic.subtract(a, b))); } + @Test public void testMultiply() throws Exception { assertEquals("1100000000000000000000.0", String.valueOf(ELArithmetic.multiply(a, b))); } + @Test public void testDivide() throws Exception { assertEquals("0.0", String.valueOf(ELArithmetic.divide(a, b))); } + @Test public void testMod() throws Exception { assertEquals("1.1", String.valueOf(ELArithmetic.mod(a, b))); } + @Test public void testBug47371bigDecimal() throws Exception { assertEquals(BigDecimal.valueOf(1), ELArithmetic.add("", BigDecimal.valueOf(1))); } + @Test public void testBug47371double() throws Exception { assertEquals(Double.valueOf(7), ELArithmetic.add("", Double.valueOf(7))); } + @Test public void testBug47371doubleString() throws Exception { assertEquals(Double.valueOf(2), ELArithmetic.add("", "2.")); } + @Test public void testBug47371bigInteger() throws Exception { assertEquals(BigInteger.valueOf(0), ELArithmetic.multiply("", BigInteger.valueOf(1))); } + @Test public void testBug47371long() throws Exception { assertEquals(Long.valueOf(1), ELArithmetic.add("", Integer.valueOf(1))); } + @Test public void testBug47371long2() throws Exception { assertEquals(Long.valueOf(-3), ELArithmetic.subtract("1", "4")); } + @Test public void testBug47371doubleString2() throws Exception { assertEquals(Double.valueOf(2), ELArithmetic.add("1.", "1")); } Modified: tomcat/trunk/test/org/apache/el/lang/TestELSupport.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELSupport.java?rev=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original) +++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Mon Jul 25 15:57:51 2011 @@ -21,54 +21,68 @@ import java.math.BigInteger; import javax.el.ELException; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -public class TestELSupport extends TestCase { +import org.junit.Test; + +public class TestELSupport { + @Test public void testBigDecimal() { testIsSame(new BigDecimal( "0.123456789012345678901234567890123456789012345678901234567890123456789")); } + @Test public void testBigInteger() { testIsSame(new BigInteger( "1234567890123456789012345678901234567890123456789012345678901234567890")); } + @Test public void testLong() { testIsSame(Long.valueOf(0x0102030405060708L)); } + @Test public void testInteger() { testIsSame(Integer.valueOf(0x01020304)); } + @Test public void testShort() { testIsSame(Short.valueOf((short) 0x0102)); } + @Test public void testByte() { testIsSame(Byte.valueOf((byte) 0xEF)); } + @Test public void testDouble() { testIsSame(Double.valueOf(0.123456789012345678901234)); } + @Test public void testFloat() { testIsSame(Float.valueOf(0.123456F)); } + @Test public void testCoerceIntegerToNumber() { Integer input = Integer.valueOf(4390241); Object output = ELSupport.coerceToType(input, Number.class); assertEquals(input, output); } + @Test public void testCoerceNullToNumber() { Object output = ELSupport.coerceToType(null, Number.class); assertEquals(Long.valueOf(0), output); } - + + @Test public void testCoerceEnumAToEnumA() { Object output = null; try { @@ -77,7 +91,8 @@ public class TestELSupport extends TestC assertEquals(TestEnumA.VALA1, output); } } - + + @Test public void testCoerceEnumAToEnumB() { Object output = null; try { @@ -88,6 +103,7 @@ public class TestELSupport extends TestC assertNull(output); } + @Test public void testCoerceEnumAToEnumC() { Object output = null; try { Modified: tomcat/trunk/test/org/apache/el/parser/TestELParser.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/parser/TestELParser.java?rev=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/parser/TestELParser.java (original) +++ tomcat/trunk/test/org/apache/el/parser/TestELParser.java Mon Jul 25 15:57:51 2011 @@ -22,12 +22,16 @@ import javax.el.ELException; import javax.el.ExpressionFactory; import javax.el.ValueExpression; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; import org.apache.jasper.el.ELContextImpl; -public class TestELParser extends TestCase { +public class TestELParser { + @Test public void testBug49081() { // OP's report testExpression("#${1+1}", "#2"); @@ -55,7 +59,8 @@ public class TestELParser extends TestCa testExpression("$#{1+1}", "$2"); testExpression("$#${1+1}", "$#2"); } - + + @Test public void testJavaKeyWordSuffix() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); @@ -77,6 +82,7 @@ public class TestELParser extends TestCa assertNotNull(e); } + @Test public void testJavaKeyWordIdentifier() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); 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=1150761&r1=1150760&r2=1150761&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java (original) +++ tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java Mon Jul 25 15:57:51 2011 @@ -22,7 +22,9 @@ import java.lang.reflect.Method; import javax.el.FunctionMapper; import javax.el.ValueExpression; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; import org.apache.el.ExpressionFactoryImpl; import org.apache.el.TesterFunctions; @@ -32,12 +34,13 @@ import org.apache.jasper.el.ELContextImp * Test the EL processing from JSP attributes. Similar tests may be found in * {@link org.apache.el.TestELEvaluation} and {@link org.apache.el.TestELInJsp}. */ -public class TestAttributeParser extends TestCase { +public class TestAttributeParser { /** * Test use of spaces in ternary expressions. This was primarily an EL * parser bug. */ + @Test public void testBug42565() { assertEquals("false", evalAttr("${false?true:false}", '\"')); assertEquals("false", evalAttr("${false?true: false}", '\"')); @@ -63,6 +66,7 @@ public class TestAttributeParser extends * {@link org.apache.el.TestELEvaluation}. This is just a smoke test to * ensure JSP attribute processing doesn't cause any additional issues. */ + @Test public void testBug44994() { assertEquals("none", evalAttr("${0 lt 0 ? 1 lt 0 ? 'many': 'one': 'none'}", '\"')); @@ -78,6 +82,7 @@ public class TestAttributeParser extends * EL. See {@link #testBug45451()} for a test that combines JSP attribute * quoting and EL quoting. */ + @Test public void testBug45015() { // Warning: Java String quoting vs. JSP attribute quoting assertEquals("hello 'world'", evalAttr("hello 'world'", '\"')); @@ -103,18 +108,20 @@ public class TestAttributeParser extends assertEquals("hello world\"", evalAttr("hello world\\\"", '\'')); } - + @Test public void testBug45451() { assertEquals("2", evalAttr("${1+1}", '\"')); assertEquals("${1+1}", evalAttr("\\${1+1}", '\"')); assertEquals("\\2", evalAttr("\\\\${1+1}", '\"')); } - + + @Test public void testBug49081() { assertEquals("#2", evalAttr("#${1+1}", '\"')); } + @Test public void testLiteral() { // Inspired by work on bug 45451, comments from kkolinko on the dev // list and looking at the spec to find some edge cases @@ -154,6 +161,7 @@ public class TestAttributeParser extends assertEquals("foo\\bar\\baz", evalAttr("${\"foo\"}\\\\${\\\'bar\\\'}\\\\${\"baz\"}", '\'')); } + @Test public void testScriptExpressionLiterals() { assertEquals(" \"hello world\" ", parseScriptExpression( " \"hello world\" ", (char) 0)); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org