Author: julien(a)jboss.com
Date: 2007-02-26 11:27:46 -0500 (Mon, 26 Feb 2007)
New Revision: 6406
Added:
trunk/faces/src/main/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/Value.java
Modified:
trunk/faces/build.xml
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java
Log:
added test case for SimpleDynamicBean
Modified: trunk/faces/build.xml
===================================================================
--- trunk/faces/build.xml 2007-02-26 16:13:20 UTC (rev 6405)
+++ trunk/faces/build.xml 2007-02-26 16:27:46 UTC (rev 6406)
@@ -226,6 +226,7 @@
<x-test>
<test todir="${test.reports}"
name="org.jboss.portal.test.faces.el.AbstractBeanDecoratorTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.faces.el.AbstractDynamicBeanTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.faces.el.SimpleDynamicBeanTestCase"/>
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
Modified:
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java 2007-02-26
16:13:20 UTC (rev 6405)
+++
trunk/faces/src/main/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java 2007-02-26
16:27:46 UTC (rev 6406)
@@ -30,7 +30,7 @@
{
/** . */
- private Class type;
+ private final Class type;
public AbstractPropertyDecorator(Class type)
{
@@ -41,7 +41,7 @@
this.type = type;
}
- public Class getType(Object bean) throws IllegalArgumentException
+ public final Class getType(Object bean) throws IllegalArgumentException
{
return type;
}
Added:
trunk/faces/src/main/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java 2007-02-26
16:27:46 UTC (rev 6406)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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.faces.el.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractDynamicProperty implements DynamicProperty
+{
+
+ /** . */
+ private Class type;
+
+ public AbstractDynamicProperty(Class type)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ }
+
+ public final Class getType() throws IllegalArgumentException
+ {
+ return type;
+ }
+
+ public boolean setValue(Object value) throws IllegalArgumentException
+ {
+ return false;
+ }
+}
Modified:
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java 2007-02-26
16:13:20 UTC (rev 6405)
+++
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java 2007-02-26
16:27:46 UTC (rev 6406)
@@ -39,7 +39,6 @@
private Object _propertyName;
private Object _propertyValue;
-
protected void setUp() throws Exception
{
_bean = new Object();
@@ -55,10 +54,6 @@
_propertyValue = null;
}
- private static class Value
- {
- }
-
private final AbstractBeanDecorator decorator = new AbstractBeanDecorator()
{
protected PropertyDecorator getProperty(Object propertyName)
Modified:
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java 2007-02-26
16:13:20 UTC (rev 6405)
+++
trunk/faces/src/main/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java 2007-02-26
16:27:46 UTC (rev 6406)
@@ -24,6 +24,7 @@
import junit.framework.TestCase;
import org.jboss.portal.faces.el.dynamic.AbstractDynamicBean;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -33,7 +34,7 @@
{
/** . */
- private final AbstractDynamicBean bean = new AbstractDynamicBean();
+ private final DynamicBean bean = new AbstractDynamicBean();
/** . */
private final Object propertyName = new Object();
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java 2007-02-26
16:27:46 UTC (rev 6406)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * 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.dynamic.SimpleDynamicBean;
+import org.jboss.portal.faces.el.dynamic.DynamicProperty;
+import org.jboss.portal.faces.el.dynamic.AbstractDynamicProperty;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleDynamicBeanTestCase extends TestCase
+{
+
+ private DynamicBean _bean;
+ private Object _propertyName;
+ private Object _propertyValue;
+
+ protected void setUp() throws Exception
+ {
+ _propertyName = new Object();
+ _propertyValue = new Value();
+ _bean = new SimpleDynamicBean()
+ {
+ protected DynamicProperty getProperty(Object propertyName)
+ {
+ if (_propertyName == propertyName)
+ {
+ return new AbstractDynamicProperty(Value.class)
+ {
+ public Object getValue() throws IllegalArgumentException
+ {
+ return _propertyValue;
+ }
+ public boolean setValue(Object value) throws IllegalArgumentException
+ {
+ _propertyValue = value;
+ return true;
+ }
+ };
+ }
+ return null;
+ }
+ };
+ }
+
+ protected void tearDown() throws Exception
+ {
+ _bean = null;
+ }
+
+ public void testGetType()
+ {
+ assertEquals(Value.class, _bean.getType(_propertyName));
+ }
+
+ public void testGetValue()
+ {
+ assertEquals(new PropertyValue(_propertyValue), _bean.getValue(_propertyName));
+ }
+
+ public void testSetValue()
+ {
+ Value expectedValue = new Value();
+ assertTrue(_bean.setValue(_propertyName, expectedValue));
+ assertEquals(expectedValue, _propertyValue);
+
+ //
+ assertTrue(_bean.setValue(_propertyName, null));
+ assertEquals(null, _propertyValue);
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/test/faces/el/Value.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/test/faces/el/Value.java
(rev 0)
+++ trunk/faces/src/main/org/jboss/portal/test/faces/el/Value.java 2007-02-26 16:27:46 UTC
(rev 6406)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Value
+{
+}