commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r553357 - in /jakarta/commons/proper/beanutils/trunk/src: java/org/apache/commons/beanutils/ test/org/apache/commons/beanutils/bugs/ test/org/apache/commons/beanutils/bugs/other/
Date Thu, 05 Jul 2007 01:10:26 GMT
Author: niallp
Date: Wed Jul  4 18:10:25 2007
New Revision: 553357

URL: http://svn.apache.org/viewvc?view=rev&rev=553357
Log:
Fix for BEANUTILS-61 - PropertyUtilsBean isReadable() and isWriteable() methods do not work
correctly for WrapDynaBean - thanks to Brian Ewins

Added:
    jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
  (with props)
    jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
  (with props)
Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java?view=diff&rev=553357&r1=553356&r2=553357
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BeanUtilsBean.java
Wed Jul  4 18:10:25 2007
@@ -253,7 +253,10 @@
                 ((DynaBean) orig).getDynaClass().getDynaProperties();
             for (int i = 0; i < origDescriptors.length; i++) {
                 String name = origDescriptors[i].getName();
-                if (getPropertyUtils().isWriteable(dest, name)) {
+                // Need to check isReadable() for WrapDynaBean
+                // (see Jira issue# BEANUTILS-61)
+                if (getPropertyUtils().isReadable(orig, name) &&
+                    getPropertyUtils().isWriteable(dest, name)) {
                     Object value = ((DynaBean) orig).get(name);
                     copyProperty(dest, name, value);
                 }

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&rev=553357&r1=553356&r2=553357
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java
Wed Jul  4 18:10:25 2007
@@ -241,12 +241,9 @@
                 ((DynaBean) orig).getDynaClass().getDynaProperties();
             for (int i = 0; i < origDescriptors.length; i++) {
                 String name = origDescriptors[i].getName();
-                if (dest instanceof DynaBean) {
-                    if (isWriteable(dest, name)) {
-                        Object value = ((DynaBean) orig).get(name);
-                        ((DynaBean) dest).set(name, value);
-                    }
-                } else /* if (dest is a standard JavaBean) */ {
+                // Need to check isReadable() for WrapDynaBean
+                // (see Jira issue# BEANUTILS-61)
+                if (isReadable(orig, name)) {
                     if (isWriteable(dest, name)) {
                         Object value = ((DynaBean) orig).get(name);
                         setSimpleProperty(dest, name, value);
@@ -1333,6 +1330,12 @@
                     bean.getClass() + "'");
         }
 
+        // Treat WrapDynaBean as special case - may be a write-only property
+        // (see Jira issue# BEANUTILS-61)
+        if (bean instanceof WrapDynaBean) {
+            bean = ((WrapDynaBean)bean).getInstance();
+        }
+
         // Return the requested result
         if (bean instanceof DynaBean) {
             // All DynaBean properties are readable
@@ -1390,6 +1393,12 @@
         if (name == null) {
             throw new IllegalArgumentException("No name specified for bean class '" +
                     bean.getClass() + "'");
+        }
+
+        // Treat WrapDynaBean as special case - may be a read-only property
+        // (see Jira issue# BEANUTILS-61)
+        if (bean instanceof WrapDynaBean) {
+            bean = ((WrapDynaBean)bean).getInstance();
         }
 
         // Return the requested result

Added: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java?view=auto&rev=553357
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
(added)
+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
Wed Jul  4 18:10:25 2007
@@ -0,0 +1,466 @@
+/*
+ * 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.
+ */
+package org.apache.commons.beanutils.bugs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.beanutils.WrapDynaBean;
+import org.apache.commons.beanutils.bugs.other.Jira61BeanFactory;
+import org.apache.commons.beanutils.bugs.other.Jira61BeanFactory.TestBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Test case for Jira issue# BEANUTILS-61.
+ * <p />
+ * See https://issues.apache.org/jira/browse/BEANUTILS-61
+ * <p />
+ *
+ * {@link WrapDynaBean} is a secial case for the PropertyUtils's
+ * isReadable() and isWriteable() methods - since the bean being
+ * wrapped may have read-only or write-only properties (unlike
+ * regular DynaBeans.
+ *
+ * @version $Revision$ $Date$
+ */
+public class Jira61TestCase extends TestCase {
+
+    private Log log = LogFactory.getLog(Jira61TestCase.class);
+    private Jira61BeanFactory.TestBean testBean;
+    private WrapDynaBean wrapDynaBean;
+
+    /**
+     * Create a test case with the specified name.
+     *
+     * @param name The name of the test
+     */
+    public Jira61TestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * Run the Test.
+     *
+     * @param args Arguments
+     */
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+    /**
+     * Create a test suite for this test.
+     *
+     * @return a test suite
+     */
+    public static Test suite() {
+        return (new TestSuite(Jira61TestCase.class));
+    }
+
+    /**
+     * Set up.
+     *
+     * @throws java.lang.Exception
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        testBean = Jira61BeanFactory.createBean();
+        PropertyUtils.getPropertyDescriptor(testBean, "mappedReadOnly");
+        PropertyUtils.getPropertyDescriptor(testBean, "mappedWriteOnly");
+        wrapDynaBean = new WrapDynaBean(testBean);
+    }
+
+    /**
+     * Tear Down.
+     *
+     * @throws java.lang.Exception
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Test {@link PropertyUtils#isReadable(Object, String)}
+     * for simple properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isReadable() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "simpleReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleReadOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isReadable(bean, \"simpleReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "simpleWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleWriteOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isReadable(bean, \"simpleWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#isWriteable(Object, String)}
+     * for simple properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "simpleReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleReadOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isWriteable(bean, \"simpleReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "simpleWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleWriteOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isWriteable(bean, \"simpleWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#isReadable(Object, String)}
+     * for indexed properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isReadable_Indexed() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "indexedReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedReadOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isReadable(bean, \"indexedReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "indexedWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedWriteOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isReadable(bean, \"indexedWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#isReadable(Object, String)}
+     * for mapped properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isReadable_Mapped() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "mappedReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedReadOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isReadable(bean, \"mappedReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isReadable(wrapDynaBean, "mappedWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedWriteOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isReadable(bean, \"mappedWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#isWriteable(Object, String)}
+     * for indexed properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable_Indexed() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "indexedReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedReadOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isWriteable(bean, \"indexedReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "indexedWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedWriteOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isWriteable(bean, \"indexedWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#isWriteable(Object, String)}
+     * for mapped properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable_Mapped() {
+        boolean result = false;
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "mappedReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedReadOnly Threw exception: " + t);
+        }
+        assertFalse("PropertyUtils.isWriteable(bean, \"mappedReadOnly\") returned " + result,
result);
+
+        try {
+            result = PropertyUtils.isWriteable(wrapDynaBean, "mappedWriteOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedWriteOnly Threw exception: " + t);
+        }
+        assertTrue("PropertyUtils.isWriteable(bean, \"mappedWriteOnly\") returned " + result,
result);
+    }
+
+    /**
+     * Test {@link PropertyUtils#getProperty(Object, String)}
+     * for simple properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_getProperty() {
+        boolean threwIllegalArgumentException = false;
+        Object result = null;
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "simpleReadOnly");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleWriteOnly Threw exception: " + t);
+        }
+        assertEquals("simpleReadOnly", testBean.getSimpleReadOnly(), result);
+
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "simpleWriteOnly");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleWriteOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException but returned '" + result + "'", threwIllegalArgumentException);
+    }
+
+    /**
+     * Test {@link PropertyUtils#setProperty(Object, String, Object)}
+     * for simple properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_setProperty() {
+        boolean threwIllegalArgumentException = false;
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "simpleReadOnly", "READONLY-SIMPLE-BAR");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleReadOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException", threwIllegalArgumentException);
+
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "simpleWriteOnly", "SIMPLE-BAR");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("simpleWriteOnly Threw exception: " + t);
+        }
+        assertEquals("simpleWriteOnly", testBean.getSimpleReadOnly(), "SIMPLE-BAR");
+    }
+
+    /**
+     * Test {@link PropertyUtils#getProperty(Object, String)}
+     * for indexed properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Indexed() {
+        boolean threwIllegalArgumentException = false;
+        Object result = null;
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "indexedReadOnly[0]");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedReadOnly Threw exception: " + t);
+        }
+        assertEquals("indexedReadOnly", testBean.getIndexedReadOnly(0), result);
+
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "indexedWriteOnly[0]");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedWriteOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException but returned '" + result + "'", threwIllegalArgumentException);
+    }
+
+    /**
+     * Test {@link PropertyUtils#setProperty(Object, String, Object)}
+     * for indexed properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Indexed() {
+        boolean threwIllegalArgumentException = false;
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "indexedReadOnly[0]", "READONLY-INDEXED-BAR");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedReadOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException", threwIllegalArgumentException);
+
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "indexedWriteOnly[0]", "INDEXED-BAR");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("indexedWriteOnly Threw exception: " + t);
+        }
+        assertEquals("indexedWriteOnly", testBean.getIndexedReadOnly(0), "INDEXED-BAR");
+    }
+
+    /**
+     * Test {@link PropertyUtils#getProperty(Object, String)}
+     * for mapped properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Mapped() {
+        boolean threwIllegalArgumentException = false;
+        Object result = null;
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "mappedReadOnly(foo-key)");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedReadOnly Threw exception: " + t);
+        }
+        assertEquals("mappedReadOnly", testBean.getMappedReadOnly("foo-key"), result);
+
+        try {
+            result = PropertyUtils.getProperty(wrapDynaBean, "mappedWriteOnly(foo-key)");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedWriteOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException but returned '" + result + "'", threwIllegalArgumentException);
+    }
+
+    /**
+     * Test {@link PropertyUtils#setProperty(Object, String, Object)}
+     * for mapped properties.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Mapped() {
+        boolean threwIllegalArgumentException = false;
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "mappedReadOnly(foo-key)", "READONLY-MAPPED-BAR");
+        } catch (IllegalArgumentException ex) {
+            threwIllegalArgumentException = true; // expected result
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedReadOnly Threw exception: " + t);
+        }
+        assertTrue("Expected IllegalArgumentException", threwIllegalArgumentException);
+
+        try {
+            PropertyUtils.setProperty(wrapDynaBean, "mappedWriteOnly(foo-key)", "MAPPED-BAR");
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("mappedWriteOnly Threw exception: " + t);
+        }
+        assertEquals("mappedWriteOnly", testBean.getMappedReadOnly("foo-key"), "MAPPED-BAR");
+    }
+
+    /**
+     * Test {@link PropertyUtils#copyProperties(Object, Object)}
+     * to a read-only WrapDynaBean property.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_copyProperties_to_WrapDynaBean() {
+        String value = "copied simpleReadOnly";
+        Map source = new HashMap();
+        source.put("simpleReadOnly", value);
+        try {
+            PropertyUtils.copyProperties(wrapDynaBean, source);
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("copyProperties Threw exception: " + t);
+        }
+        assertFalse("Target value='" + value + "'", value.equals(testBean.getSimpleReadOnly()));
+    }
+
+    /**
+     * Test {@link PropertyUtils#copyProperties(Object, Object)}
+     * to a read-only WrapDynaBean property.
+     */
+    public void testIssue_BEANUTILS_61_PropertyUtils_copyProperties_from_WrapDynaBean() {
+        String value = "ORIG TARGET VALUE";
+        TestBean targetBean = Jira61BeanFactory.createBean();
+        targetBean.setSimpleWriteOnly(value);
+        try {
+            PropertyUtils.copyProperties(targetBean, wrapDynaBean);
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("copyProperties Threw exception: " + t);
+        }
+        assertTrue("Target value='" + targetBean.getSimpleReadOnly() + "'", value.equals(targetBean.getSimpleReadOnly()));
+    }
+
+    /**
+     * Test {@link BeanUtils#copyProperties(Object, Object)}
+     * to a read-only WrapDynaBean property.
+     */
+    public void testIssue_BEANUTILS_61_BeanUtils_copyProperties_to_WrapDynaBean() {
+        String value = "copied simpleReadOnly";
+        Map source = new HashMap();
+        source.put("simpleReadOnly", value);
+        try {
+            BeanUtils.copyProperties(wrapDynaBean, source);
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("copyProperties Threw exception: " + t);
+        }
+        assertFalse("Target value='" + value + "'", value.equals(testBean.getSimpleReadOnly()));
+    }
+
+    /**
+     * Test {@link BeanUtils#copyProperties(Object, Object)}
+     * to a read-only WrapDynaBean property.
+     */
+    public void testIssue_BEANUTILS_61_BeanUtils_copyProperties_from_WrapDynaBean() {
+        String value = "ORIG TARGET VALUE";
+        TestBean targetBean = Jira61BeanFactory.createBean();
+        targetBean.setSimpleWriteOnly(value);
+        try {
+            BeanUtils.copyProperties(targetBean, wrapDynaBean);
+        } catch (Throwable t) {
+            log.error("ERROR " + t, t);
+            fail("copyProperties Threw exception: " + t);
+        }
+        assertTrue("Target value='" + targetBean.getSimpleReadOnly() + "'", value.equals(targetBean.getSimpleReadOnly()));
+    }
+}

Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/Jira61TestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java?view=auto&rev=553357
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
(added)
+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
Wed Jul  4 18:10:25 2007
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+package org.apache.commons.beanutils.bugs.other;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.beanutils.bugs.Jira61TestCase;
+
+/**
+ * Factory which creates beans for {@link Jira61TestCase}.
+ *
+ * @version $Revision$ $Date$
+ */
+public class Jira61BeanFactory {
+
+    /**
+     * Factory method which creates a new {@link TestBean}.
+     *
+     * @return a new {@link TestBean}.
+     */
+    public static TestBean createBean() {
+        return new TestBean();
+    }
+
+    /**
+     * Test Bean 
+     */
+    public static class TestBean {
+
+        private String[] indexed = new String[] {"one", "two", "three"};
+        private String simple = "FOO";
+        private Map mapped = new HashMap();
+
+        /** Default Constructor */
+        public TestBean() {
+            mapped.put("foo-key", "foo-value");
+            mapped.put("bar-key", "bar-value");
+        }
+
+        /**
+         * Return simpleReadOnly
+         *
+         * @return the simple value
+         */
+        public String getSimpleReadOnly() {
+            return simple;
+        }
+
+        /**
+         * Set simpleWriteOnly
+         *
+         * @param simple simple value
+         */
+        public void setSimpleWriteOnly(String simple) {
+            this.simple = simple;
+        }
+
+        /**
+         * Return indexed property.
+         * 
+         * @param index The index
+         * @return The indexed value
+         */
+        public String getIndexedReadOnly(int index) {
+            return indexed[index];
+        }
+
+        /**
+         * Set indexed property.
+         * 
+         * @param index The index
+         * @param value The indexed value
+         */
+        public void setIndexedWriteOnly(int index, String value) {
+            this.indexed[index] = value;
+        }
+
+        /**
+         * Return mapped property.
+         * 
+         * @param key The mapped key
+         * @return The mapped value
+         */
+        public String getMappedReadOnly(String key) {
+            return (String)mapped.get(key);
+        }
+
+        /**
+         * Set mapped property.
+         * 
+         * @param key The mapped key
+         * @param value The mapped value
+         */
+        public void setMappedWriteOnly(String key, String value) {
+            mapped.put(key, value);
+        }
+
+    }
+
+}

Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/bugs/other/Jira61BeanFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message