You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by he...@apache.org on 2006/09/06 16:09:42 UTC
svn commit: r440719 -
/jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
Author: henning
Date: Wed Sep 6 07:09:42 2006
New Revision: 440719
URL: http://svn.apache.org/viewvc?view=rev&rev=440719
Log:
add some explicit tests for the Uberspector to find out its behaviour in corner cases...
Added:
jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java (with props)
Added: jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java?view=auto&rev=440719
==============================================================================
--- jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java (added)
+++ jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java Wed Sep 6 07:09:42 2006
@@ -0,0 +1,94 @@
+package org.apache.velocity.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.velocity.runtime.RuntimeInstance;
+import org.apache.velocity.util.introspection.Uberspect;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class UberspectorTestCase
+ extends BaseTestCase
+{
+ private RuntimeInstance ri;
+
+ public UberspectorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(UberspectorTestCase.class);
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ ri = new RuntimeInstance();
+ ri.init();
+ }
+
+ public void testEmptyProperties()
+ throws Exception
+ {
+ Uberspect u = ri.getUberspect();
+ Map map = new HashMap();
+
+ // Don't screw up on empty propeties. That should map to get(Object) and put(Object, Object) on a Map
+ assertNotNull(u.getPropertyGet(map, "", null));
+ assertNotNull(u.getPropertySet(map, "", Object.class, null));
+ }
+
+ public void testNullProperties()
+ throws Exception
+ {
+ Uberspect u = ri.getUberspect();
+ Map map = new HashMap();
+
+ // Don't screw up on null propeties. That should map to get(Object) and put(Object, Object) on a Map, too?
+ assertNotNull(u.getPropertyGet(map, null, null));
+ assertNotNull(u.getPropertySet(map, null, Object.class, null));
+ }
+
+ /*
+
+ public void testMapGetSet()
+ throws Exception
+ {
+ Uberspect u = ri.getUberspect();
+ Map map = new HashMap();
+
+ VelPropertyGet getter = u.getPropertyGet(map, "", null);
+ VelPropertySet setter = u.getPropertySet(map, "", Object.class, null);
+
+ assertNotNull("Got a null getter", getter);
+ assertNotNull("Got a null setter", setter);
+
+ assertEquals("Got wrong getter", "foo", getter.getMethodName());
+ assertEquals("Got wrong setter", "bar", setter.getMethodName());
+ }
+ */
+}
+
+
+
+
Propchange: jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org