commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils BasicDynaBeanTestCase.java
Date Thu, 19 Dec 2002 19:26:59 GMT


On Thu, 19 Dec 2002, robert burrell donkin wrote:

> Date: Thu, 19 Dec 2002 18:59:00 +0000
> From: robert burrell donkin <robertburrelldonkin@blueyonder.co.uk>
> Reply-To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> Subject: Re: cvs commit:
>     jakarta-commons/beanutils/src/test/org/apache/commons/beanutils
>     BasicDynaBeanTestCase.java
>
> hi craig
>
> i'm on java 1.3 and seem to be getting an exception when i run the
> beanutils test cases:
>
>       [java] 1)
> testSerialization(org.apache.commons.beanutils.BasicDynaBeanTestCase)junit.
> framework.AssertionFailedError: Exception during deserialization:
> java.lang.ClassNotFoundException: boolean
>       [java]     at
> org.apache.commons.beanutils.BasicDynaBeanTestCase.testSerialization
> (BasicDynaBeanTestCase.java:713)
>       [java]
>
> any ideas?

There might be two different issues here.

I made a mistake with the commit referred to below, and only ran the one
test case (the "test.basic.dynabean" target) for the classes I was
modifying, and not realizing that the tests for WrapDynaBean would inherit
the new testing.  This caused a failure in the "test.wrap.dynabean"
target.  I just checked in a patch for that.

If you do a fresh checkout and build and still have the problem, we might
indeed have a 1.3 versus 1.4 issue (I build everything with 1.4).  Are you
still encountering this after picking up the change I just committed?

>
> - robert

Craig

>
> On Wednesday, December 18, 2002, at 06:20 AM, craigmcc@apache.org wrote:
>
> > craigmcc    2002/12/17 22:20:41
> >
> >   Modified:    beanutils/src/java/org/apache/commons/beanutils
> >                         BasicDynaBean.java BasicDynaClass.java
> >                beanutils/src/test/org/apache/commons/beanutils
> >                         BasicDynaBeanTestCase.java
> >   Log:
> >   Make BasicDynaBean and BasicDynaClass implement Serializable, including
> > a
> >   JUnit test case method that ensures successful operation.  Based on a
> >   suggested patch included in the bug report (but with a slightly altered
> >   technique).
> >
> >   PR: Bugzilla #15067
> >   Submitted by:	Peter Rossbach <pr at webapp.de> and Roman Stumm
> >
> >   Revision  Changes    Path
> >   1.7       +10 -5     jakarta-
> > commons/beanutils/src/java/org/apache/commons/beanutils/BasicDynaBean.java
> >
> >   Index: BasicDynaBean.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-
> > commons/beanutils/src/java/org/apache/commons/beanutils/BasicDynaBean.java,
> > v
> >   retrieving revision 1.6
> >   retrieving revision 1.7
> >   diff -u -r1.6 -r1.7
> >   --- BasicDynaBean.java	25 Oct 2002 00:15:50 -0000	1.6
> >   +++ BasicDynaBean.java	18 Dec 2002 06:20:40 -0000	1.7
> >   @@ -63,6 +63,7 @@
> >    package org.apache.commons.beanutils;
> >
> >
> >   +import java.io.Serializable;
> >    import java.lang.reflect.Array;
> >    import java.util.HashMap;
> >    import java.util.List;
> >   @@ -76,11 +77,15 @@
> >     * <p><strong>IMPLEMENTATION NOTE</strong> - Instances of this
class
> > that are
> >     * accessed from multiple threads simultaneously need to be
> > synchronized.</p>
> >     *
> >   + * <p><strong>IMPLEMENTATION NOTE</strong> - Instances of this
class
> > can be
> >   + * successfully serialized and deserialized <strong>ONLY</strong>
if
> > all
> >   + * property values are <code>Serializable</code>.</p>
> >   + *
> >     * @author Craig McClanahan
> >     * @version $Revision$ $Date$
> >     */
> >
> >   -public class BasicDynaBean implements DynaBean {
> >   +public class BasicDynaBean implements DynaBean, Serializable {
> >
> >
> >        // ----------------------------------------------------------
> > Constructors
> >
> >
> >
> >   1.7       +12 -6     jakarta-
> > commons/beanutils/src/java/org/apache/commons/beanutils/BasicDynaClass.java
> >
> >   Index: BasicDynaClass.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-
> > commons/beanutils/src/java/org/apache/commons/beanutils/BasicDynaClass.java,
> > v
> >   retrieving revision 1.6
> >   retrieving revision 1.7
> >   diff -u -r1.6 -r1.7
> >   --- BasicDynaClass.java	23 Jan 2002 22:35:58 -0000	1.6
> >   +++ BasicDynaClass.java	18 Dec 2002 06:20:40 -0000	1.7
> >   @@ -63,6 +63,7 @@
> >    package org.apache.commons.beanutils;
> >
> >
> >   +import java.io.Serializable;
> >    import java.lang.reflect.Constructor;
> >    import java.lang.reflect.InvocationTargetException;
> >    import java.util.HashMap;
> >   @@ -80,7 +81,7 @@
> >     * @version $Revision$ $Date$
> >     */
> >
> >   -public class BasicDynaClass implements DynaClass {
> >   +public class BasicDynaClass implements DynaClass, Serializable {
> >
> >
> >        // -----------------------------------------------------------
> > Constructors
> >   @@ -138,7 +139,7 @@
> >         * The constructor of the <code>dynaBeanClass</code> that we
will
> > use
> >         * for creating new instances.
> >         */
> >   -    protected Constructor constructor = null;
> >   +    protected transient Constructor constructor = null;
> >
> >
> >        /**
> >   @@ -248,6 +249,11 @@
> >                throws IllegalAccessException, InstantiationException {
> >
> >            try {
> >   +            // Refind the constructor after a deserialization (if
> > needed)
> >   +            if (constructor == null) {
> >   +                setDynaBeanClass(this.dynaBeanClass);
> >   +            }
> >   +            // Invoke the constructor to create a new bean instance
> >                return ((DynaBean)
> > constructor.newInstance(constructorValues));
> >            } catch (InvocationTargetException e) {
> >                throw new InstantiationException
> >
> >
> >
> >   1.7       +83 -4     jakarta-
> > commons/beanutils/src/test/org/apache/commons/beanutils/BasicDynaBeanTestCase.
> > java
> >
> >   Index: BasicDynaBeanTestCase.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-
> > commons/beanutils/src/test/org/apache/commons/beanutils/BasicDynaBeanTestCase.
> > java,v
> >   retrieving revision 1.6
> >   retrieving revision 1.7
> >   diff -u -r1.6 -r1.7
> >   --- BasicDynaBeanTestCase.java	25 Oct 2002 00:27:42 -0000	1.6
> >   +++ BasicDynaBeanTestCase.java	18 Dec 2002 06:20:41 -0000	1.7
> >   @@ -63,6 +63,11 @@
> >    package org.apache.commons.beanutils;
> >
> >
> >   +import java.io.ByteArrayInputStream;
> >   +import java.io.ByteArrayOutputStream;
> >   +import java.io.ObjectInputStream;
> >   +import java.io.ObjectOutputStream;
> >   +
> >    import java.util.ArrayList;
> >    import java.util.HashMap;
> >    import java.util.List;
> >   @@ -676,6 +681,80 @@
> >            } catch (Throwable t) {
> >                fail("Exception: " + t);
> >            }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >   +     * Test serialization and deserialization.
> >   +     */
> >   +    public void testSerialization() {
> >   +
> >   +        // Serialize the test bean
> >   +        ByteArrayOutputStream baos = new ByteArrayOutputStream();
> >   +        try {
> >   +            ObjectOutputStream oos = new ObjectOutputStream(baos);
> >   +            oos.writeObject(bean);
> >   +            oos.flush();
> >   +            oos.close();
> >   +        } catch (Exception e) {
> >   +            fail("Exception during serialization: " + e);
> >   +        }
> >   +
> >   +        // Deserialize the test bean
> >   +        try {
> >   +            bean = null;
> >   +            ByteArrayInputStream bais =
> >   +                new ByteArrayInputStream(baos.toByteArray());
> >   +            ObjectInputStream ois = new ObjectInputStream(bais);
> >   +            bean = (DynaBean) ois.readObject();
> >   +            bais.close();
> >   +        } catch (Exception e) {
> >   +            fail("Exception during deserialization: " + e);
> >   +        }
> >   +
> >   +        // Confirm property values
> >   +        testGetDescriptorArguments();
> >   +        testGetDescriptorBoolean();
> >   +        testGetDescriptorDouble();
> >   +        testGetDescriptorFloat();
> >   +        testGetDescriptorInt();
> >   +        testGetDescriptorLong();
> >   +        testGetDescriptorSecond();
> >   +        testGetDescriptorShort();
> >   +        testGetDescriptorString();
> >   +        testGetDescriptors();
> >   +        testGetIndexedArguments();
> >   +        testGetIndexedValues();
> >   +        testGetMappedArguments();
> >   +        testGetMappedValues();
> >   +        testGetSimpleArguments();
> >   +        testGetSimpleBoolean();
> >   +        testGetSimpleDouble();
> >   +        testGetSimpleFloat();
> >   +        testGetSimpleInt();
> >   +        testGetSimpleLong();
> >   +        testGetSimpleShort();
> >   +        testGetSimpleString();
> >   +        testMappedContains();
> >   +        testMappedRemove();
> >   +
> >   +        // Ensure that we can create a new instance of the same
> > DynaClass
> >   +        try {
> >   +            bean = bean.getDynaClass().newInstance();
> >   +        } catch (Exception e) {
> >   +            fail("Exception creating new instance: " + e);
> >   +        }
> >   +        testGetDescriptorArguments();
> >   +        testGetDescriptorBoolean();
> >   +        testGetDescriptorDouble();
> >   +        testGetDescriptorFloat();
> >   +        testGetDescriptorInt();
> >   +        testGetDescriptorLong();
> >   +        testGetDescriptorSecond();
> >   +        testGetDescriptorShort();
> >   +        testGetDescriptorString();
> >   +        testGetDescriptors();
> >
> >        }
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> > org>
> > For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> > org>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
>
>


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


Mime
View raw message