You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2008/08/10 08:00:22 UTC
svn commit: r684410 [15/16] - in /ibatis/trunk/java/ibatis-3: ./
ibatis-3-core/src/main/java/org/apache/ibatis/ognl/
ibatis-3-core/src/test/java/org/apache/ibatis/ognl/
ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/
ibatis-3-core/src/test/...
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,119 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import java.util.*;
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.NoSuchPropertyException;
+import org.apache.ibatis.ognl.InappropriateExpressionException;
+import org.apache.ibatis.ognl.objects.Root;
+
+public class SetterTest extends OgnlTestCase
+{
+ private static Root ROOT = new Root();
+
+ private static Object[][] TESTS = {
+ // Setting values
+ { ROOT.getMap(), "newValue", null, new Integer(101) },
+ { ROOT, "settableList[0]", "foo", "quux" }, /* absolute indexes */
+ { ROOT, "settableList[0]", "quux" },
+ { ROOT, "settableList[2]", "baz", "quux" },
+ { ROOT, "settableList[2]", "quux" },
+ { ROOT, "settableList[$]", "quux", "oompa" }, /* special indexes */
+ { ROOT, "settableList[$]", "oompa" },
+ { ROOT, "settableList[^]", "quux", "oompa" },
+ { ROOT, "settableList[^]", "oompa" },
+ { ROOT, "settableList[|]", "bar", "oompa" },
+ { ROOT, "settableList[|]", "oompa" },
+ { ROOT, "map.newValue", new Integer(101), new Integer(555) },
+ { ROOT, "map", ROOT.getMap(), new HashMap(), NoSuchPropertyException.class },
+ { ROOT.getMap(), "newValue2 || put(\"newValue2\",987), newValue2", new Integer(987), new Integer(1002) },
+ { ROOT, "map.(someMissingKey || newValue)", new Integer(555), new Integer(666) },
+ { ROOT.getMap(), "newValue || someMissingKey", new Integer(666), new Integer(666) }, // no setting happens!
+ { ROOT, "map.(newValue && aKey)", null, new Integer(54321) },
+ { ROOT, "map.(someMissingKey && newValue)", null, null }, // again, no setting
+ { null, "0", new Integer(0), null, InappropriateExpressionException.class }, // illegal for setting, no property
+ { ROOT, "map[0]=\"map.newValue\", map[0](#this)", new Integer(666), new Integer(888) },
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ if (TESTS[i].length == 3) {
+ result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2]));
+ } else {
+ if (TESTS[i].length == 4) {
+ result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3]));
+ } else {
+ if (TESTS[i].length == 5) {
+ result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4]));
+ } else {
+ throw new RuntimeException("don't understand TEST format");
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public SetterTest()
+ {
+ super();
+ }
+
+ public SetterTest(String name)
+ {
+ super(name);
+ }
+
+ public SetterTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public SetterTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public SetterTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterWithConversionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterWithConversionTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterWithConversionTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SetterWithConversionTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,108 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.objects.Root;
+
+public class SetterWithConversionTest extends OgnlTestCase
+{
+ private static Root ROOT = new Root();
+
+ private static Object[][] TESTS = {
+ // Property set with conversion
+ { ROOT, "intValue", new Integer(0), new Double(6.5), new Integer(6) },
+ { ROOT, "intValue", new Integer(6), new Double(1025.87645), new Integer(1025) },
+ { ROOT, "intValue", new Integer(1025), "654", new Integer(654) },
+ { ROOT, "stringValue", null, new Integer(25), "25" },
+ { ROOT, "stringValue", "25", new Float(100.25), "100.25" },
+ { ROOT, "anotherStringValue", "foo", new Integer(0), "0" },
+ { ROOT, "anotherStringValue", "0", new Double(0.5), "0.5" },
+ { ROOT, "anotherIntValue", new Integer(123), "5", new Integer(5) },
+ { ROOT, "anotherIntValue", new Integer(5), new Double(100.25), new Integer(100) },
+ // { ROOT, "anotherIntValue", new Integer(100), new String[] { "55" }, new Integer(55)},
+ // { ROOT, "yetAnotherIntValue", new Integer(46), new String[] { "55" }, new Integer(55)},
+
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ if (TESTS[i].length == 3) {
+ result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2]));
+ } else {
+ if (TESTS[i].length == 4) {
+ result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3]));
+ } else {
+ if (TESTS[i].length == 5) {
+ result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4]));
+ } else {
+ throw new RuntimeException("don't understand TEST format");
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public SetterWithConversionTest()
+ {
+ super();
+ }
+
+ public SetterWithConversionTest(String name)
+ {
+ super(name);
+ }
+
+ public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ShortCircuitingExpressionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ShortCircuitingExpressionTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ShortCircuitingExpressionTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/ShortCircuitingExpressionTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,90 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.OgnlException;
+import org.apache.ibatis.ognl.NoSuchPropertyException;
+
+public class ShortCircuitingExpressionTest extends OgnlTestCase
+{
+ private static Object[][] TESTS = {
+ { "#root ? someProperty : 99", new Integer(99) },
+ { "#root ? 99 : someProperty", OgnlException.class },
+ { "(#x=99)? #x.someProperty : #x", NoSuchPropertyException.class },
+ { "#xyzzy.doubleValue()", NullPointerException.class },
+ { "#xyzzy && #xyzzy.doubleValue()", null },
+ { "(#x=99) && #x.doubleValue()", new Double(99) },
+ { "#xyzzy || 101", new Integer(101) },
+ { "99 || 101", new Integer(99) },
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ result.addTest(new ShortCircuitingExpressionTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String)TESTS[i][0], TESTS[i][1]));
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public ShortCircuitingExpressionTest()
+ {
+ super();
+ }
+
+ public ShortCircuitingExpressionTest(String name)
+ {
+ super(name);
+ }
+
+ public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimpleNavigationChainTreeTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimpleNavigationChainTreeTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimpleNavigationChainTreeTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimpleNavigationChainTreeTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,93 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.Ognl;
+
+public class SimpleNavigationChainTreeTest extends OgnlTestCase
+{
+ private static Object[][] TESTS = {
+ { "name", Boolean.TRUE },
+ { "name[i]", Boolean.FALSE },
+ { "name + foo", Boolean.FALSE },
+ { "name.foo", Boolean.TRUE }
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ result.addTest(new SimpleNavigationChainTreeTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String)TESTS[i][0], TESTS[i][1]));
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public SimpleNavigationChainTreeTest()
+ {
+ super();
+ }
+
+ public SimpleNavigationChainTreeTest(String name)
+ {
+ super(name);
+ }
+
+ public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ protected void runTest() throws Exception
+ {
+ assertTrue(Ognl.isSimpleNavigationChain(getExpression(), context) == ((Boolean)getExpectedResult()).booleanValue());
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimplePropertyTreeTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimplePropertyTreeTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimplePropertyTreeTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/SimplePropertyTreeTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,97 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.Ognl;
+
+public class SimplePropertyTreeTest extends OgnlTestCase
+{
+ private static Object[][] TESTS = {
+ { "name", Boolean.TRUE },
+ { "foo", Boolean.TRUE },
+ { "name[i]", Boolean.FALSE },
+ { "name + foo", Boolean.FALSE },
+ { "name.foo", Boolean.FALSE },
+ { "name.foo.bar", Boolean.FALSE },
+ { "name.{? foo }", Boolean.FALSE },
+ { "name.( foo )", Boolean.FALSE }
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ result.addTest(new SimplePropertyTreeTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String)TESTS[i][0], TESTS[i][1]));
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public SimplePropertyTreeTest()
+ {
+ super();
+ }
+
+ public SimplePropertyTreeTest(String name)
+ {
+ super(name);
+ }
+
+ public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ protected void runTest() throws Exception
+ {
+ assertTrue(Ognl.isSimpleProperty(getExpression(), context) == ((Boolean)getExpectedResult()).booleanValue());
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/StaticsAndConstructorsTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/StaticsAndConstructorsTest.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/StaticsAndConstructorsTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/StaticsAndConstructorsTest.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,97 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl;
+
+import junit.framework.TestSuite;
+import org.apache.ibatis.ognl.objects.Root;
+
+public class StaticsAndConstructorsTest extends OgnlTestCase
+{
+ private static Root ROOT = new Root();
+
+ private static Object[][] TESTS = {
+ { "@java.lang.Class@forName(\"java.lang.Object\")", Object.class },
+ { "@java.lang.Integer@MAX_VALUE", new Integer(Integer.MAX_VALUE) },
+ { "@@max(3,4)", new Integer(4) },
+ { "new java.lang.StringBuffer().append(55).toString()", "55" },
+ { "class", ROOT.getClass() },
+ { "@org.apache.ibatis.ognl.objects.Root@class", ROOT.getClass() },
+ { "class.getName()", ROOT.getClass().getName() },
+ { "@org.apache.ibatis.ognl.objects.Root@class.getName()", ROOT.getClass().getName() },
+ { "@org.apache.ibatis.ognl.objects.Root@class.name", ROOT.getClass().getName() },
+ { "class.getSuperclass()", ROOT.getClass().getSuperclass() },
+ { "class.superclass", ROOT.getClass().getSuperclass() },
+ { "class.name", ROOT.getClass().getName() },
+ { "getStaticInt()", new Integer(Root.getStaticInt()) },
+ { "@org.apache.ibatis.ognl.objects.Root@getStaticInt()", new Integer(Root.getStaticInt()) },
+ };
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static TestSuite suite()
+ {
+ TestSuite result = new TestSuite();
+
+ for (int i = 0; i < TESTS.length; i++) {
+ result.addTest(new StaticsAndConstructorsTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String)TESTS[i][0], TESTS[i][1]));
+ }
+ return result;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public StaticsAndConstructorsTest()
+ {
+ super();
+ }
+
+ public StaticsAndConstructorsTest(String name)
+ {
+ super(name);
+ }
+
+ public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult)
+ {
+ super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult);
+ }
+
+ public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue)
+ {
+ super(name, root, expressionString, expectedResult, setValue);
+ }
+
+ public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult)
+ {
+ super(name, root, expressionString, expectedResult);
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/BaseObjectIndexed.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/BaseObjectIndexed.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/BaseObjectIndexed.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/BaseObjectIndexed.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,76 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.util.*;
+
+public class BaseObjectIndexed extends Object
+{
+ private Map attributes = new HashMap();
+
+ public BaseObjectIndexed()
+ {
+ super();
+ }
+
+ public Map getAttributes()
+ {
+ return attributes;
+ }
+
+ public Object getAttribute(String name)
+ {
+ return attributes.get(name);
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ /* allow testing property name where types do not match */
+ public Object getOtherAttribute(String name)
+ {
+ return null;
+ }
+
+ public void setOtherAttribute(Object someObject, Object foo)
+ {
+ /* do nothing */
+ }
+
+
+ /* test whether get only is found */
+ public Object getSecondaryAttribute(Object name)
+ {
+ return attributes.get(name);
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean1.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean1.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean1.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean1.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,41 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class Bean1 extends Object
+{
+ private Bean2 bean2 = new Bean2();
+
+ public Bean2 getBean2()
+ {
+ return bean2;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean2.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean2.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean2.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean2.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,41 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class Bean2 extends Object
+{
+ private Bean3 bean3 = new Bean3();
+
+ public Bean3 getBean3()
+ {
+ return bean3;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean3.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean3.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean3.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Bean3.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,69 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.util.*;
+
+public class Bean3 extends Object
+{
+ private int value = 100;
+ private Map map;
+
+ {
+ map = new HashMap();
+ map.put("foo", "bar");
+ map.put("bar", "baz");
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ public void setValue(int value)
+ {
+ this.value = value;
+ }
+
+ public Object getIndexedValue(int index)
+ {
+ return null;
+ }
+
+ public void setIndexedValue(int index, Object value)
+ {
+ }
+
+ public Map getMap()
+ {
+ return map;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Component.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Component.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Component.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Component.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,85 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class Component extends Object
+{
+ private URLStorage toDisplay = new URLStorage();
+ private Page page = new Page();
+
+ public static class URLStorage extends Object
+ {
+ private String pictureUrl = "http://www.picturespace.com/pictures/100";
+
+ public String getPictureUrl()
+ {
+ return pictureUrl;
+ }
+
+ public void setPictureUrl(String value)
+ {
+ pictureUrl = value;
+ }
+ }
+
+ public static class Page extends Object
+ {
+ public Object createRelativeAsset(String value)
+ {
+ return "/toplevel/" + value;
+ }
+ }
+
+ public Component()
+ {
+ super();
+ }
+
+ public Page getPage()
+ {
+ return page;
+ }
+
+ public void setPage(Page value)
+ {
+ page = value;
+ }
+
+ public URLStorage getToDisplay()
+ {
+ return toDisplay;
+ }
+
+ public void setToDisplay(URLStorage value)
+ {
+ toDisplay = value;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/CorrectedObject.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/CorrectedObject.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/CorrectedObject.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/CorrectedObject.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,57 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class CorrectedObject extends Object
+{
+ public CorrectedObject()
+ {
+ super();
+ }
+
+ public void setStringValue(String value)
+ {
+ }
+
+ public String getStringValue()
+ {
+ return null;
+ }
+
+ public String getIndexedStringValue(String key)
+ {
+ return null;
+ }
+
+ public void setIndexedStringValue(String key, String value)
+ {
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Indexed.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Indexed.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Indexed.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Indexed.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,76 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class Indexed extends Object
+{
+ private String[] values = new String[] { "foo", "bar", "baz" };
+
+ public Indexed()
+ {
+ super();
+ }
+
+ public Indexed(String[] values)
+ {
+ super();
+ this.values = values;
+ }
+
+ /* Indexed property "values" */
+ public String[] getValues()
+ {
+ return values;
+ }
+
+ public void setValues(String[] value)
+ {
+ values = value;
+ }
+
+ /**
+ This method returns the string from the array and appends "xxx" to
+ distinguish the "get" method from the direct array access.
+ */
+ public String getValues(int index)
+ {
+ return values[index] + "xxx";
+ }
+
+ public void setValues(int index, String value)
+ {
+ if (value.endsWith("xxx")) {
+ values[index] = value.substring(0, value.length() - 3);
+ } else {
+ values[index] = value;
+ }
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMap.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMap.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMap.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMap.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,42 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.util.*;
+
+/**
+ This tests the interface inheritence test. This is a subinterface
+ of Map and therefore should inherit the Map property accessor.
+ */
+public interface MyMap extends Map
+{
+ public String getDescription();
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMapImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMapImpl.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMapImpl.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/MyMapImpl.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,118 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.util.*;
+
+/**
+ This tests the interface inheritence test. This test implements
+ MyMap->Map but extends Object, therefore should be coded using
+ MapPropertyAccessor instead of ObjectPropertyAccessor.
+ */
+public class MyMapImpl extends Object implements MyMap
+{
+ private Map map = new HashMap();
+
+ public void clear()
+ {
+ map.clear();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return map.containsKey(key);
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return map.containsValue(value);
+ }
+
+ public Set entrySet()
+ {
+ return map.entrySet();
+ }
+
+ public boolean equals(Object o)
+ {
+ return map.equals(o);
+ }
+
+ public Object get(Object key)
+ {
+ return map.get(key);
+ }
+
+ public int hashCode()
+ {
+ return map.hashCode();
+ }
+
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ public Set keySet()
+ {
+ return map.keySet();
+ }
+
+ public Object put(Object key, Object value)
+ {
+ return map.put(key, value);
+ }
+
+ public void putAll(Map t)
+ {
+ map.putAll(t);
+ }
+
+ public Object remove(Object key)
+ {
+ return map.remove(key);
+ }
+
+ public int size()
+ {
+ return map.size();
+ }
+
+ public Collection values()
+ {
+ return map.values();
+ }
+
+ public String getDescription()
+ {
+ return "MyMap implementation";
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/ObjectIndexed.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/ObjectIndexed.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/ObjectIndexed.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/ObjectIndexed.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,42 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class ObjectIndexed extends BaseObjectIndexed
+{
+ public ObjectIndexed()
+ {
+ super();
+ setAttribute("foo", "bar");
+ setAttribute("bar", "baz");
+ setAttribute("other", new OtherObjectIndexed());
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/OtherObjectIndexed.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/OtherObjectIndexed.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/OtherObjectIndexed.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/OtherObjectIndexed.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,41 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+public class OtherObjectIndexed extends BaseObjectIndexed
+{
+ public OtherObjectIndexed()
+ {
+ super();
+ setAttribute("foo", "bar");
+ setAttribute("bar", "baz");
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Root.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Root.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Root.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Root.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,196 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.util.*;
+import org.apache.ibatis.ognl.DynamicSubscript;
+
+public class Root extends Object
+{
+ public static final String SIZE_STRING = "size";
+ public static final int STATIC_INT = 23;
+
+ private int[] array = { 1, 2, 3, 4 };
+ private Map map = new HashMap(23);
+ private MyMap myMap = new MyMapImpl();
+ private List list = Arrays.asList(new Object[] { null, this, array });
+ private List settableList = new ArrayList(Arrays.asList(new Object[] { "foo", "bar", "baz" }));
+ private int index = 1;
+ private int intValue = 0;
+ private String stringValue;
+ private int yetAnotherIntValue = 46;
+ private boolean privateAccessorBooleanValue = true;
+ private int privateAccessorIntValue = 67;
+ private int privateAccessorIntValue2 = 67;
+ private int privateAccessorIntValue3 = 67;
+ public String anotherStringValue = "foo";
+ public int anotherIntValue = 123;
+ public int six = 6;
+
+ /*===================================================================
+ Public static methods
+ ===================================================================*/
+ public static int getStaticInt()
+ {
+ return STATIC_INT;
+ }
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public Root()
+ {
+ super();
+ }
+
+ /*===================================================================
+ Private methods
+ ===================================================================*/
+ {
+ map.put( "test", this );
+ map.put( "array", array );
+ map.put( "list", list );
+ map.put( "size", new Integer(5000) );
+ map.put( DynamicSubscript.first, new Integer(99) );
+
+ /* make myMap identical */
+ myMap.putAll( map );
+ }
+
+ private boolean isPrivateAccessorBooleanValue()
+ {
+ return privateAccessorBooleanValue;
+ }
+
+ private void setPrivateAccessorBooleanValue(boolean value)
+ {
+ privateAccessorBooleanValue = value;
+ }
+
+ private int getPrivateAccessorIntValue()
+ {
+ return privateAccessorIntValue;
+ }
+
+ private void setPrivateAccessorIntValue(int value)
+ {
+ privateAccessorIntValue = value;
+ }
+
+ /*===================================================================
+ Protected methods
+ ===================================================================*/
+ protected int getPrivateAccessorIntValue2()
+ {
+ return privateAccessorIntValue2;
+ }
+
+ protected void setPrivateAccessorIntValue2(int value)
+ {
+ privateAccessorIntValue2 = value;
+ }
+
+ /*===================================================================
+ Package protected methods
+ ===================================================================*/
+ int getPrivateAccessorIntValue3()
+ {
+ return privateAccessorIntValue3;
+ }
+
+ void setPrivateAccessorIntValue3(int value)
+ {
+ privateAccessorIntValue3 = value;
+ }
+
+ /*===================================================================
+ Public methods
+ ===================================================================*/
+ public int[] getArray()
+ {
+ return array;
+ }
+
+ public void setArray(int[] value)
+ {
+ array = value;
+ }
+
+ public Map getMap()
+ {
+ return map;
+ }
+
+ public MyMap getMyMap()
+ {
+ return myMap;
+ }
+
+ public List getList()
+ {
+ return list;
+ }
+
+ public List getSettableList()
+ {
+ return settableList;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public int getIntValue()
+ {
+ return intValue;
+ }
+
+ public void setIntValue(int value)
+ {
+ intValue = value;
+ }
+
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ public void setStringValue(String value)
+ {
+ stringValue = value;
+ }
+
+ public Object getNullObject()
+ {
+ return null;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Simple.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Simple.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Simple.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/objects/Simple.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,141 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.objects;
+
+import java.math.*;
+import org.apache.ibatis.ognl.OgnlTestCase;
+
+public class Simple extends Object
+{
+ private String stringValue;
+ private float floatValue;
+ private int intValue;
+ private boolean booleanValue;
+ private BigInteger bigIntValue = BigInteger.valueOf(0);
+ private BigDecimal bigDecValue = new BigDecimal(0.0);
+
+ public Simple()
+ {
+ super();
+ }
+
+ public Simple(Object[] values)
+ {
+ super();
+ }
+
+ public Simple(String stringValue, float floatValue, int intValue)
+ {
+ super();
+ this.stringValue = stringValue;
+ this.floatValue = floatValue;
+ this.intValue = intValue;
+ }
+
+ public void setValues(String stringValue, float floatValue, int intValue)
+ {
+ this.stringValue = stringValue;
+ this.floatValue = floatValue;
+ this.intValue = intValue;
+ }
+
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ public void setStringValue(String value)
+ {
+ stringValue = value;
+ }
+
+ public float getFloatValue()
+ {
+ return floatValue;
+ }
+
+ public void setFloatValue(float value)
+ {
+ floatValue = value;
+ }
+
+ public int getIntValue()
+ {
+ return intValue;
+ }
+
+ public void setIntValue(int value)
+ {
+ intValue = value;
+ }
+
+ public boolean getBooleanValue()
+ {
+ return booleanValue;
+ }
+
+ public void setBooleanValue(boolean value)
+ {
+ booleanValue = value;
+ }
+
+ public BigInteger getBigIntValue()
+ {
+ return bigIntValue;
+ }
+
+ public void setBigIntValue(BigInteger value)
+ {
+ bigIntValue = value;
+ }
+
+ public BigDecimal getBigDecValue()
+ {
+ return bigDecValue;
+ }
+
+ public void setBigDecValue(BigDecimal value)
+ {
+ bigDecValue = value;
+ }
+
+ public boolean equals(Object other)
+ {
+ boolean result = false;
+
+ if (other instanceof Simple) {
+ Simple os = (Simple)other;
+
+ result = OgnlTestCase.isEqual(os.getStringValue(), getStringValue()) && (os.getIntValue() == getIntValue());
+ }
+ return result;
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/ContextClassLoader.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/ContextClassLoader.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/ContextClassLoader.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/ContextClassLoader.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,59 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.util;
+
+import org.apache.ibatis.ognl.OgnlContext;
+
+public class ContextClassLoader extends ClassLoader
+{
+ private OgnlContext context;
+
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public ContextClassLoader(ClassLoader parentClassLoader, OgnlContext context)
+ {
+ super(parentClassLoader);
+ this.context = context;
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ protected Class findClass(String name) throws ClassNotFoundException
+ {
+ if ((context != null) && (context.getClassResolver() != null)) {
+ return context.getClassResolver().classForName(name, context);
+ }
+ return super.findClass(name);
+ }
+
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/EnhancedClassLoader.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/EnhancedClassLoader.java?rev=684410&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/EnhancedClassLoader.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/ognl/util/EnhancedClassLoader.java Sat Aug 9 23:00:18 2008
@@ -0,0 +1,50 @@
+//--------------------------------------------------------------------------
+// Copyright (c) 2004, Drew Davidson and Luke Blanshard
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the Drew Davidson nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+// DAMAGE.
+//--------------------------------------------------------------------------
+package org.apache.ibatis.ognl.util;
+
+public class EnhancedClassLoader extends ClassLoader
+{
+ /*===================================================================
+ Constructors
+ ===================================================================*/
+ public EnhancedClassLoader(ClassLoader parentClassLoader)
+ {
+ super(parentClassLoader);
+ }
+
+ /*===================================================================
+ Overridden methods
+ ===================================================================*/
+ public Class defineClass(String enhancedClassName, byte[] byteCode)
+ {
+ return defineClass(enhancedClassName, byteCode, 0, byteCode.length);
+ }
+}