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.test.objects.Root;
23 import org.junit.runner.RunWith;
24 import org.junit.runners.Parameterized;
25 import org.junit.runners.Parameterized.Parameters;
26
27 import java.math.BigInteger;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collection;
31
32 @RunWith(value = Parameterized.class)
33 public class ProjectionSelectionTest
34 extends OgnlTestCase
35 {
36 private static Root ROOT = new Root();
37
38 private static Object[][] TESTS = {
39
40 { ROOT, "array.{class}",
41 Arrays.asList( new Class[] { Integer.class, Integer.class, Integer.class, Integer.class } ) },
42 { ROOT, "map.array.{? #this > 2 }", Arrays.asList( new Integer[] { new Integer( 3 ), new Integer( 4 ) } ) },
43 { ROOT, "map.array.{^ #this > 2 }", Arrays.asList( new Integer[] { new Integer( 3 ) } ) },
44 { ROOT, "map.array.{$ #this > 2 }", Arrays.asList( new Integer[] { new Integer( 4 ) } ) },
45 { ROOT, "map.array[*].{?true} instanceof java.util.Collection", Boolean.TRUE },
46 { null, "#fact=1, 30H.{? #fact = #fact * (#this+1), false }, #fact",
47 new BigInteger( "265252859812191058636308480000000" ) }, };
48
49
50
51
52
53 @Parameters
54 public static Collection<Object[]> data()
55 {
56 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
57 for ( int i = 0; i < TESTS.length; i++ )
58 {
59 Object[] tmp = new Object[6];
60 tmp[0] = TESTS[i][1];
61 tmp[1] = TESTS[i][0];
62 tmp[2] = TESTS[i][1];
63 tmp[3] = TESTS[i][2];
64
65 data.add( tmp );
66 }
67 return data;
68 }
69
70
71
72
73
74 public ProjectionSelectionTest( String name, Object root, String expressionString, Object expectedResult,
75 Object setValue, Object expectedAfterSetResult )
76 {
77 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
78 }
79 }