1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.commons.ognl.test;
21
22 import org.apache.commons.ognl.NoSuchPropertyException;
23 import org.apache.commons.ognl.OgnlException;
24 import org.junit.runner.RunWith;
25 import org.junit.runners.Parameterized;
26 import org.junit.runners.Parameterized.Parameters;
27
28 import java.util.ArrayList;
29 import java.util.Collection;
30
31 @RunWith(value = Parameterized.class)
32 public class ShortCircuitingExpressionTest
33 extends OgnlTestCase
34 {
35 private static Object[][] TESTS = { { "#root ? someProperty : 99", new Integer( 99 ) },
36 { "#root ? 99 : someProperty", OgnlException.class },
37 { "(#x=99)? #x.someProperty : #x", NoSuchPropertyException.class },
38 { "#xyzzy.doubleValue()", NullPointerException.class }, { "#xyzzy && #xyzzy.doubleValue()", null },
39 { "(#x=99) && #x.doubleValue()", new Double( 99 ) }, { "#xyzzy || 101", new Integer( 101 ) },
40 { "99 || 101", new Integer( 99 ) }, };
41
42
43
44
45
46 @Parameters
47 public static Collection<Object[]> data()
48 {
49 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
50 for ( int i = 0; i < TESTS.length; i++ )
51 {
52 Object[] tmp = new Object[6];
53 tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
54 tmp[1] = null;
55 tmp[2] = TESTS[i][0];
56 tmp[3] = TESTS[i][1];
57
58 data.add( tmp );
59 }
60 return data;
61 }
62
63
64
65
66
67 public ShortCircuitingExpressionTest( String name, Object root, String expressionString, Object expectedResult,
68 Object setValue, Object expectedAfterSetResult )
69 {
70 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
71 }
72 }