Author: julien(a)jboss.com
Date: 2007-02-26 11:01:10 -0500 (Mon, 26 Feb 2007)
New Revision: 6403
Added:
trunk/faces/src/main/org/jboss/portal/test/
trunk/faces/src/main/org/jboss/portal/test/faces/
trunk/faces/src/main/org/jboss/portal/test/faces/el/
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
Modified:
trunk/faces/build.xml
trunk/faces/src/main/org/jboss/portal/faces/el/PropertyValue.java
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java
trunk/format/build.xml
Log:
adding AbstractBeanDecorator test case + fix bug
Modified: trunk/faces/build.xml
===================================================================
--- trunk/faces/build.xml 2007-02-26 15:27:15 UTC (rev 6402)
+++ trunk/faces/build.xml 2007-02-26 16:01:10 UTC (rev 6403)
@@ -94,6 +94,7 @@
<path refid="el.el.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="oswego.concurrent.classpath"/>
+ <path refid="junit.junit.classpath"/>
</path>
<!-- Configure modules -->
@@ -164,6 +165,10 @@
</jar>
</target>
+ <!-- generates artifacts used for tests, requires output to be previously run
-->
+ <target name="package-tests" depends="init">
+ </target>
+
<!-- ================================================================== -->
<!-- Cleaning -->
<!-- ================================================================== -->
@@ -210,4 +215,23 @@
<delete
file="${jboss.home}/server/${portal.deploy.dir}/portal-faces.war"/>
</target>
+ <target name="tests" depends="compile">
+ <execute-tests>
+ <x-sysproperty>
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
+-->
+ </x-sysproperty>
+ <x-test>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.faces.el.AbstractBeanDecoratorTestCase"/>
+ </x-test>
+ <x-classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement
location="${build.resources}/portal-format-lib-jar"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
</project>
Modified: trunk/faces/src/main/org/jboss/portal/faces/el/PropertyValue.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/PropertyValue.java 2007-02-26 15:27:15
UTC (rev 6402)
+++ trunk/faces/src/main/org/jboss/portal/faces/el/PropertyValue.java 2007-02-26 16:01:10
UTC (rev 6403)
@@ -41,4 +41,23 @@
{
return object;
}
+
+ public int hashCode()
+ {
+ return object == null ? 0 : object.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof PropertyValue)
+ {
+ PropertyValue that = (PropertyValue)obj;
+ return object == null ? that.object == null : object.equals(that.object);
+ }
+ return false;
+ }
}
Modified:
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java 2007-02-26
15:27:15 UTC (rev 6402)
+++
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java 2007-02-26
16:01:10 UTC (rev 6403)
@@ -75,7 +75,7 @@
return null;
}
- public boolean setValue(Object bean, Object propertyName, Object value) throws
IllegalArgumentException
+ public boolean setValue(Object bean, Object propertyName, Object propertyValue) throws
IllegalArgumentException
{
if (bean == null)
{
@@ -90,7 +90,7 @@
PropertyDecorator property = getProperty(propertyName);
if (property != null)
{
- property.setValue(bean, propertyName);
+ property.setValue(bean, propertyValue);
return true;
}
Added:
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java 2007-02-26
16:01:10 UTC (rev 6403)
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
+import org.jboss.portal.faces.el.decorator.PropertyDecorator;
+import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractBeanDecoratorTestCase extends TestCase
+{
+
+ private final Object _bean = new Object();
+ private final Object _propertyName = new Object();
+ private Object _propertyValue = new Value();
+
+ private static class Value
+ {
+ }
+
+ private final AbstractBeanDecorator decorator = new AbstractBeanDecorator()
+ {
+ protected PropertyDecorator getProperty(Object propertyName)
+ {
+ return propertyName == _propertyName ? new
AbstractPropertyDecorator(Value.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ return bean == _bean ? _propertyValue : null;
+ }
+ public boolean setValue(Object bean, Object value) throws
IllegalArgumentException
+ {
+ if (bean == _bean )
+ {
+ _propertyValue = value;
+ return true;
+ }
+ return false;
+ }
+ } : null;
+ }
+ };
+
+ public void testGetType()
+ {
+ try
+ {
+ decorator.getType(null, _propertyName);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ decorator.getType(_bean, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(Value.class, decorator.getType(_bean, _propertyName));
+ }
+
+ public void testGetValue()
+ {
+ try
+ {
+ decorator.getValue(_bean, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ decorator.getValue(null, _propertyName);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(null, decorator.getValue(_bean, new Object()));
+ assertEquals(new PropertyValue(_propertyValue), decorator.getValue(_bean,
_propertyName));
+ }
+
+ public void testSetValue()
+ {
+ try
+ {
+ decorator.setValue(null, _propertyName, new Object());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ decorator.setValue(_bean, null, new Object());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ Value expectedValue = new Value();
+ assertEquals(true, decorator.setValue(_bean, _propertyName, expectedValue));
+ assertEquals(expectedValue, _propertyValue);
+
+ //
+ assertEquals(true, decorator.setValue(_bean, _propertyName, null));
+ assertEquals(null, _propertyValue);
+ }
+}
Modified: trunk/format/build.xml
===================================================================
--- trunk/format/build.xml 2007-02-26 15:27:15 UTC (rev 6402)
+++ trunk/format/build.xml 2007-02-26 16:01:10 UTC (rev 6403)
@@ -189,8 +189,7 @@
</target>
- <!-- generates artifacts used for tests, requires output to be previously run
- -->
+ <!-- generates artifacts used for tests, requires output to be previously run
-->
<target name="package-tests" depends="init">
</target>