001 /* 002 * $Id: QuotingTest.java 1188000 2011-10-23 23:10:24Z 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 org.junit.Test; 023 import org.junit.runner.RunWith; 024 import org.junit.runners.Parameterized; 025 import org.junit.runners.Parameterized.Parameters; 026 027 import java.util.ArrayList; 028 import java.util.Collection; 029 030 @RunWith(value = Parameterized.class) 031 public class QuotingTest 032 extends OgnlTestCase 033 { 034 private static Object[][] TESTS = { 035 // Quoting 036 { null, "`c`", new Character( 'c' ) }, { null, "'s'", new Character( 's' ) }, { null, "'string'", "string" }, 037 { null, "\"string\"", "string" }, { null, "'' + 'bar'", "bar" }, 038 { null, "'yyyy\u539Add\u5EA6'", "yyyy\u539Add\u5EA6" } }; 039 040 /* 041 * =================================================================== Public static methods 042 * =================================================================== 043 */ 044 @Parameters 045 public static Collection<Object[]> data() 046 { 047 Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length); 048 for ( int i = 0; i < TESTS.length; i++ ) 049 { 050 Object[] tmp = new Object[6]; 051 tmp[0] = TESTS[i][1]; 052 tmp[1] = TESTS[i][0]; 053 tmp[2] = TESTS[i][1]; 054 055 switch ( TESTS[i].length ) 056 { 057 case 3: 058 tmp[3] = TESTS[i][2]; 059 break; 060 061 case 4: 062 tmp[3] = TESTS[i][2]; 063 tmp[4] = TESTS[i][3]; 064 break; 065 066 case 5: 067 tmp[3] = TESTS[i][2]; 068 tmp[4] = TESTS[i][3]; 069 tmp[5] = TESTS[i][4]; 070 break; 071 072 default: 073 throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length ); 074 } 075 076 data.add( tmp ); 077 } 078 return data; 079 } 080 081 /* 082 * =================================================================== Constructors 083 * =================================================================== 084 */ 085 public QuotingTest( String name, Object root, String expressionString, Object expectedResult, Object setValue, 086 Object expectedAfterSetResult ) 087 { 088 super( name, root, expressionString, expectedResult, setValue, expectedAfterSetResult ); 089 } 090 091 @Test 092 093 @Override 094 public void runTest() 095 throws Exception 096 { 097 super.runTest(); 098 } 099 }