You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/21 01:19:53 UTC
svn commit: r687502 - in /velocity/engine/trunk/src:
java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
test/org/apache/velocity/test/issues/Velocity544TestCase.java
Author: nbubna
Date: Wed Aug 20 16:19:52 2008
New Revision: 687502
URL: http://svn.apache.org/viewvc?rev=687502&view=rev
Log:
VELOCITY-544 fix and test, thanks to Jarkko Viinamaki
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java (with props)
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java?rev=687502&r1=687501&r2=687502&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java Wed Aug 20 16:19:52 2008
@@ -96,12 +96,13 @@
setMethod(getIntrospector().getMethod(clazz, sb.toString(), params));
}
-
+
if (isAlive())
{
- if (getMethod().getReturnType() != Boolean.TYPE)
+ if( getMethod().getReturnType() != Boolean.TYPE &&
+ getMethod().getReturnType() != Boolean.class )
{
- setMethod(null); // That case is rare but not unknown
+ setMethod(null);
}
}
}
Added: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java?rev=687502&view=auto
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java (added)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java Wed Aug 20 16:19:52 2008
@@ -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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.velocity.test.BaseEvalTestCase;
+
+/**
+ * @see https://issues.apache.org/jira/browse/VELOCITY-544
+ */
+public class Velocity544TestCase
+ extends BaseEvalTestCase
+{
+ public Velocity544TestCase(final String name)
+ throws Exception
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(Velocity544TestCase.class);
+ }
+
+ public void testBooleanPropertyExecutor()
+ throws Exception
+ {
+ context.put("foobarTrue", new Foobar(true));
+ context.put("foobarFalse", new Foobar(false));
+
+ String template = "$foobarTrue.True $foobarFalse.True $foobarTrue.TrueObject $foobarFalse.TrueObject";
+
+ String result = evaluate(template);
+
+ super.assertEquals("true false true false", result);
+ }
+
+ public static class Foobar
+ {
+ private boolean value;
+
+ public Foobar(boolean value)
+ {
+ this.value = value;
+ }
+
+ public boolean isTrue()
+ {
+ return(value);
+ }
+
+ public Boolean isTrueObject()
+ {
+ return(new Boolean(value));
+ }
+ }
+}
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java
------------------------------------------------------------------------------
svn:keywords = Revision
Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity544TestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain