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 static junit.framework.Assert.assertTrue;
23
24 import java.util.ArrayList;
25 import java.util.Collection;
26
27 import org.apache.commons.ognl.Ognl;
28 import org.junit.Before;
29 import org.junit.runner.RunWith;
30 import org.junit.runners.Parameterized;
31 import org.junit.runners.Parameterized.Parameters;
32
33 @RunWith(value = Parameterized.class)
34 public class SimplePropertyTreeTest
35 extends OgnlTestCase
36 {
37 private static Object[][] TESTS = { { "name", Boolean.TRUE }, { "foo", Boolean.TRUE },
38 { "name[i]", Boolean.FALSE }, { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.FALSE },
39 { "name.foo.bar", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE }, { "name.( foo )", Boolean.FALSE } };
40
41
42
43
44
45 @Parameters
46 public static Collection<Object[]> data()
47 {
48 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
49 for ( int i = 0; i < TESTS.length; i++ )
50 {
51 Object[] tmp = new Object[6];
52 tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
53 tmp[1] = null;
54 tmp[2] = TESTS[i][0];
55 tmp[3] = TESTS[i][1];
56
57 data.add( tmp );
58 }
59 return data;
60 }
61
62
63
64
65
66 public SimplePropertyTreeTest( String name, Object root, String expressionString, Object expectedResult,
67 Object setValue, Object expectedAfterSetResult )
68 {
69 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
70 }
71
72
73
74
75
76 @Before
77 @Override
78 public void runTest()
79 throws Exception
80 {
81 assertTrue( Ognl.isSimpleProperty( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
82 }
83 }