001: //--------------------------------------------------------------------------
002: // Copyright (c) 2004, Drew Davidson and Luke Blanshard
003: // All rights reserved.
004: //
005: // Redistribution and use in source and binary forms, with or without
006: // modification, are permitted provided that the following conditions are
007: // met:
008: //
009: // Redistributions of source code must retain the above copyright notice,
010: // this list of conditions and the following disclaimer.
011: // Redistributions in binary form must reproduce the above copyright
012: // notice, this list of conditions and the following disclaimer in the
013: // documentation and/or other materials provided with the distribution.
014: // Neither the name of the Drew Davidson nor the names of its contributors
015: // may be used to endorse or promote products derived from this software
016: // without specific prior written permission.
017: //
018: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
019: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
020: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
021: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
022: // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
023: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
024: // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
025: // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
027: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
028: // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
029: // DAMAGE.
030: //--------------------------------------------------------------------------
031: package org.ognl.test;
032:
033: import junit.framework.TestSuite;
034: import org.ognl.test.objects.Root;
035:
036: public class InterfaceInheritanceTest extends OgnlTestCase {
037: private static Root ROOT = new Root();
038:
039: private static Object[][] TESTS = {
040: // Interface inheritence test
041: { ROOT, "myMap", ROOT.getMyMap() },
042: { ROOT, "myMap.test", ROOT },
043: { ROOT.getMyMap(), "list", ROOT.getList() },
044: { ROOT, "myMap.array[0]", new Integer(ROOT.getArray()[0]) },
045: { ROOT, "myMap.list[1]", ROOT.getList().get(1) },
046: { ROOT, "myMap[^]", new Integer(99) },
047: { ROOT, "myMap[$]", null },
048: {
049: ROOT.getMyMap(),
050: "array[$]",
051: new Integer(
052: ROOT.getArray()[ROOT.getArray().length - 1]) },
053: { ROOT, "[\"myMap\"]", ROOT.getMyMap() },
054: { ROOT, "myMap[null]", null },
055: { ROOT, "myMap[#x = null]", null },
056: { ROOT, "myMap.(null,test)", ROOT },
057: { ROOT, "myMap[null] = 25", new Integer(25) },
058: { ROOT, "myMap[null]", new Integer(25), new Integer(50),
059: new Integer(50) }, };
060:
061: /*===================================================================
062: Public static methods
063: ===================================================================*/
064: public static TestSuite suite() {
065: TestSuite result = new TestSuite();
066:
067: for (int i = 0; i < TESTS.length; i++) {
068: if (TESTS[i].length == 3) {
069: result.addTest(new InterfaceInheritanceTest(
070: (String) TESTS[i][1], TESTS[i][0],
071: (String) TESTS[i][1], TESTS[i][2]));
072: } else {
073: if (TESTS[i].length == 4) {
074: result.addTest(new InterfaceInheritanceTest(
075: (String) TESTS[i][1], TESTS[i][0],
076: (String) TESTS[i][1], TESTS[i][2],
077: TESTS[i][3]));
078: } else {
079: if (TESTS[i].length == 5) {
080: result.addTest(new InterfaceInheritanceTest(
081: (String) TESTS[i][1], TESTS[i][0],
082: (String) TESTS[i][1], TESTS[i][2],
083: TESTS[i][3], TESTS[i][4]));
084: } else {
085: throw new RuntimeException(
086: "don't understand TEST format");
087: }
088: }
089: }
090: }
091: return result;
092: }
093:
094: /*===================================================================
095: Constructors
096: ===================================================================*/
097: public InterfaceInheritanceTest() {
098: super ();
099: }
100:
101: public InterfaceInheritanceTest(String name) {
102: super (name);
103: }
104:
105: public InterfaceInheritanceTest(String name, Object root,
106: String expressionString, Object expectedResult,
107: Object setValue, Object expectedAfterSetResult) {
108: super (name, root, expressionString, expectedResult, setValue,
109: expectedAfterSetResult);
110: }
111:
112: public InterfaceInheritanceTest(String name, Object root,
113: String expressionString, Object expectedResult,
114: Object setValue) {
115: super (name, root, expressionString, expectedResult, setValue);
116: }
117:
118: public InterfaceInheritanceTest(String name, Object root,
119: String expressionString, Object expectedResult) {
120: super(name, root, expressionString, expectedResult);
121: }
122: }
|