View Javadoc

1   /*
2    * $Id: GenericsTest.java 1104080 2011-05-17 09:22:09Z 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 java.util.ArrayList;
23  import java.util.Collection;
24  
25  import org.apache.commons.ognl.test.objects.BaseGeneric;
26  import org.apache.commons.ognl.test.objects.GameGeneric;
27  import org.apache.commons.ognl.test.objects.GameGenericObject;
28  import org.apache.commons.ognl.test.objects.GenericRoot;
29  import org.junit.runner.RunWith;
30  import org.junit.runners.Parameterized;
31  import org.junit.runners.Parameterized.Parameters;
32  
33  /**
34   * Tests java >= 1.5 generics support in ognl.
35   */
36  @RunWith(value = Parameterized.class)
37  public class GenericsTest
38      extends OgnlTestCase
39  {
40      static GenericRoot ROOT = new GenericRoot();
41  
42      static BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric();
43  
44      static Object[][] TESTS = {
45      /* { ROOT, "cracker.param", null, new Integer(2), new Integer(2)}, */
46      { GENERIC, "ids", null, new Long[] { 1l, 101l }, new Long[] { 1l, 101l } },
47      /* { GENERIC, "ids", new Long[] {1l, 101l}, new String[] {"2", "34"}, new Long[]{2l, 34l}}, */
48      };
49  
50      @Parameters
51      public static Collection<Object[]> data()
52      {
53          Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
54          for ( int i = 0; i < TESTS.length; i++ )
55          {
56              Object[] tmp = new Object[6];
57              tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
58              tmp[1] = TESTS[i][0];
59              tmp[2] = TESTS[i][1];
60              tmp[3] = TESTS[i][2];
61              tmp[4] = TESTS[i][3];
62              tmp[5] = TESTS[i][4];
63  
64              data.add( tmp );
65          }
66          return data;
67      }
68  
69      public GenericsTest( String name, Object root, String expressionString, Object expectedResult, Object setValue,
70                           Object expectedAfterSetResult )
71      {
72          super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult );
73      }
74  }