001 /* 002 * $Id: GenericsTest.java 1104080 2011-05-17 09:22:09Z mcucchiara $ 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 package org.apache.commons.ognl.test; 021 022 import java.util.ArrayList; 023 import java.util.Collection; 024 025 import org.apache.commons.ognl.test.objects.BaseGeneric; 026 import org.apache.commons.ognl.test.objects.GameGeneric; 027 import org.apache.commons.ognl.test.objects.GameGenericObject; 028 import org.apache.commons.ognl.test.objects.GenericRoot; 029 import org.junit.runner.RunWith; 030 import org.junit.runners.Parameterized; 031 import org.junit.runners.Parameterized.Parameters; 032 033 /** 034 * Tests java >= 1.5 generics support in ognl. 035 */ 036 @RunWith(value = Parameterized.class) 037 public class GenericsTest 038 extends OgnlTestCase 039 { 040 static GenericRoot ROOT = new GenericRoot(); 041 042 static BaseGeneric<GameGenericObject, Long> GENERIC = new GameGeneric(); 043 044 static Object[][] TESTS = { 045 /* { ROOT, "cracker.param", null, new Integer(2), new Integer(2)}, */ 046 { GENERIC, "ids", null, new Long[] { 1l, 101l }, new Long[] { 1l, 101l } }, 047 /* { GENERIC, "ids", new Long[] {1l, 101l}, new String[] {"2", "34"}, new Long[]{2l, 34l}}, */ 048 }; 049 050 @Parameters 051 public static Collection<Object[]> data() 052 { 053 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length); 054 for ( int i = 0; i < TESTS.length; i++ ) 055 { 056 Object[] tmp = new Object[6]; 057 tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")"; 058 tmp[1] = TESTS[i][0]; 059 tmp[2] = TESTS[i][1]; 060 tmp[3] = TESTS[i][2]; 061 tmp[4] = TESTS[i][3]; 062 tmp[5] = TESTS[i][4]; 063 064 data.add( tmp ); 065 } 066 return data; 067 } 068 069 public GenericsTest( String name, Object root, String expressionString, Object expectedResult, Object setValue, 070 Object expectedAfterSetResult ) 071 { 072 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult ); 073 } 074 }