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.CorrectedObject;
23 import org.junit.Before;
24 import org.junit.runner.RunWith;
25 import org.junit.runners.Parameterized;
26 import org.junit.runners.Parameterized.Parameters;
27
28 import java.math.BigDecimal;
29 import java.util.ArrayList;
30 import java.util.Collection;
31
32 @RunWith(value = Parameterized.class)
33 public class ClassMethodTest
34 extends OgnlTestCase
35 {
36
37 private static CorrectedObject CORRECTED = new CorrectedObject();
38
39 private static Object[][] TESTS = {
40
41 { CORRECTED, "getClass().getName()", CORRECTED.getClass().getName() },
42 { CORRECTED, "getClass().getInterfaces()", CORRECTED.getClass().getInterfaces() },
43 { CORRECTED, "getClass().getInterfaces().length", new Integer( CORRECTED.getClass().getInterfaces().length ) },
44 { null, "@System@class.getInterfaces()", System.class.getInterfaces() },
45 { null, "@Class@class.getName()", Class.class.getName() },
46 { null, "@java.awt.image.ImageObserver@class.getName()", java.awt.image.ImageObserver.class.getName() }, };
47
48
49
50
51
52 @Parameters
53 public static Collection<Object[]> data()
54 {
55 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
56 for ( int i = 0; i < TESTS.length; i++ )
57 {
58 Object[] tmp = new Object[6];
59 tmp[0] = TESTS[i][1];
60 tmp[1] = TESTS[i][0];
61 tmp[2] = TESTS[i][1];
62 tmp[3] = TESTS[i][2];
63 tmp[4] = null;
64 tmp[5] = null;
65
66 data.add( tmp );
67 }
68 return data;
69 }
70
71
72
73
74
75 public ClassMethodTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
76 Object expectedAfterSetResult )
77 {
78 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
79 }
80
81 @Before
82 @Override
83 public void setUp()
84 {
85 super.setUp();
86 _context.put( "x", "1" );
87 _context.put( "y", new BigDecimal( 1 ) );
88 }
89 }