Author: nbubna
Date: Thu Feb 5 20:47:47 2009
New Revision: 741286
URL: http://svn.apache.org/viewvc?rev=741286&view=rev
Log:
VELOCITY-689 merge r741283 fix/test for ClassMap bug
Added:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java
(with props)
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java?rev=741286&r1=741285&r2=741286&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
Thu Feb 5 20:47:47 2009
@@ -133,16 +133,27 @@
Class [] interfaces = classToReflect.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
- if (Modifier.isPublic(interfaces[i].getModifiers()))
- {
- populateMethodCacheWith(methodCache, interfaces[i]);
- }
+ populateMethodCacheWithInterface(methodCache, interfaces[i]);
}
}
// return the already initialized cache
return methodCache;
}
+ /* recurses up interface heirarchy to get all super interfaces
(VELOCITY-689) */
+ private void populateMethodCacheWithInterface(MethodCache methodCache,
Class iface)
+ {
+ if (Modifier.isPublic(iface.getModifiers()))
+ {
+ populateMethodCacheWith(methodCache, iface);
+ }
+ Class[] supers = iface.getInterfaces();
+ for (int i=0; i < supers.length; i++)
+ {
+ populateMethodCacheWithInterface(methodCache, supers[i]);
+ }
+ }
+
private void populateMethodCacheWith(MethodCache methodCache, Class
classToReflect)
{
if (debugReflection && log.isDebugEnabled())
Added:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java?rev=741286&view=auto
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java
(added)
+++
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java
Thu Feb 5 20:47:47 2009
@@ -0,0 +1,76 @@
+package org.apache.velocity.test.issues;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * This class tests VELOCITY-689.
+ */
+public class Velocity689TestCase extends BaseTestCase
+{
+ public Velocity689TestCase(String name)
+ {
+ super(name);
+ //DEBUG = true;
+ }
+
+ public void setUpContext(VelocityContext ctx)
+ {
+ ctx.put("foo", new Foo());
+ }
+
+ public void testIt()
+ {
+ String template = "$foo.baz, $foo.bar";
+ assertEvalEquals("baz, bar", template);
+ }
+
+ public static interface HasMethod
+ {
+ String getBar();
+ }
+
+ public static interface HasOtherMethod extends HasMethod
+ {
+ String getBaz();
+ }
+
+ public static interface NoMethod extends HasOtherMethod
+ {
+ // nada!
+ }
+
+ private static class Foo implements NoMethod
+ {
+ public String getBar()
+ {
+ return "bar";
+ }
+
+ public String getBaz()
+ {
+ return "baz";
+ }
+ }
+
+}
Propchange:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity689TestCase.java
------------------------------------------------------------------------------
svn:executable = *