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:
035: public class OperatorTest extends OgnlTestCase {
036: private static Object[][] TESTS = {
037: { null, "\"one\" > \"two\"", Boolean.FALSE },
038: { null, "\"one\" >= \"two\"", Boolean.FALSE },
039: { null, "\"one\" < \"two\"", Boolean.TRUE },
040: { null, "\"one\" <= \"two\"", Boolean.TRUE },
041: { null, "\"one\" == \"two\"", Boolean.FALSE },
042: { null, "\"o\" > \"o\"", Boolean.FALSE },
043: { null, "\"o\" gt \"o\"", Boolean.FALSE },
044: { null, "\"o\" >= \"o\"", Boolean.TRUE },
045: { null, "\"o\" gte \"o\"", Boolean.TRUE },
046: { null, "\"o\" < \"o\"", Boolean.FALSE },
047: { null, "\"o\" lt \"o\"", Boolean.FALSE },
048: { null, "\"o\" <= \"o\"", Boolean.TRUE },
049: { null, "\"o\" lte \"o\"", Boolean.TRUE },
050: { null, "\"o\" == \"o\"", Boolean.TRUE },
051: { null, "\"o\" eq \"o\"", Boolean.TRUE }, };
052:
053: /*===================================================================
054: Public static methods
055: ===================================================================*/
056: public static TestSuite suite() {
057: TestSuite result = new TestSuite();
058:
059: for (int i = 0; i < TESTS.length; i++) {
060: if (TESTS[i].length == 3) {
061: result
062: .addTest(new OperatorTest((String) TESTS[i][1],
063: TESTS[i][0], (String) TESTS[i][1],
064: TESTS[i][2]));
065: } else {
066: if (TESTS[i].length == 4) {
067: result.addTest(new OperatorTest(
068: (String) TESTS[i][1], TESTS[i][0],
069: (String) TESTS[i][1], TESTS[i][2],
070: TESTS[i][3]));
071: } else {
072: if (TESTS[i].length == 5) {
073: result.addTest(new OperatorTest(
074: (String) TESTS[i][1], TESTS[i][0],
075: (String) TESTS[i][1], TESTS[i][2],
076: TESTS[i][3], TESTS[i][4]));
077: } else {
078: throw new RuntimeException(
079: "don't understand TEST format");
080: }
081: }
082: }
083: }
084: return result;
085: }
086:
087: /*===================================================================
088: Constructors
089: ===================================================================*/
090: public OperatorTest() {
091: super ();
092: }
093:
094: public OperatorTest(String name) {
095: super (name);
096: }
097:
098: public OperatorTest(String name, Object root,
099: String expressionString, Object expectedResult,
100: Object setValue, Object expectedAfterSetResult) {
101: super (name, root, expressionString, expectedResult, setValue,
102: expectedAfterSetResult);
103: }
104:
105: public OperatorTest(String name, Object root,
106: String expressionString, Object expectedResult,
107: Object setValue) {
108: super (name, root, expressionString, expectedResult, setValue);
109: }
110:
111: public OperatorTest(String name, Object root,
112: String expressionString, Object expectedResult) {
113: super(name, root, expressionString, expectedResult);
114: }
115: }
|