1 /*
2 * $Id: ContextVariableTest.java 1188000 2011-10-23 23:10:24Z mcucchiara $
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 */
20 package org.apache.commons.ognl.test;
21
22 import org.apache.commons.ognl.test.objects.Simple;
23 import org.junit.runner.RunWith;
24 import org.junit.runners.Parameterized;
25 import org.junit.runners.Parameterized.Parameters;
26
27 import java.util.ArrayList;
28 import java.util.Collection;
29
30 @RunWith(value = Parameterized.class)
31 public class ContextVariableTest
32 extends OgnlTestCase
33 {
34
35 private static Object ROOT = new Simple();
36
37 private static Object[][] TESTS = {
38 // Naming and referring to names
39 { "#root", ROOT }, // Special root reference
40 { "#this", ROOT }, // Special this reference
41 { "#f=5, #s=6, #f + #s", new Integer( 11 ) }, { "#six=(#five=5, 6), #five + #six", new Integer( 11 ) }, };
42
43 /*
44 * =================================================================== Public static methods
45 * ===================================================================
46 */
47 @Parameters
48 public static Collection<Object[]> data()
49 {
50 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
51 for ( int i = 0; i < TESTS.length; i++ )
52 {
53 Object[] tmp = new Object[6];
54 tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
55 tmp[1] = ROOT;
56 tmp[2] = TESTS[i][0];
57 tmp[3] = TESTS[i][1];
58 tmp[4] = null;
59 tmp[5] = null;
60
61 data.add( tmp );
62 }
63 return data;
64 }
65
66 /*
67 * =================================================================== Constructors
68 * ===================================================================
69 */
70 public ContextVariableTest( String name, Object root, String expressionString, Object expectedResult,
71 Object setValue, Object expectedAfterSetResult )
72 {
73 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
74 }
75 }