harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3400) [classlib][luni] Add testcase for ObjectInputStream's resolveObject(Object) function
Date Thu, 15 Mar 2007 07:57:09 GMT
[classlib][luni] Add testcase for ObjectInputStream's resolveObject(Object) function

                 Key: HARMONY-3400
                 URL: https://issues.apache.org/jira/browse/HARMONY-3400
             Project: Harmony
          Issue Type: Improvement
          Components: Classlib
         Environment: ubuntu
            Reporter: Sean Qiu

Add missing test case for java.io.ObjectInputStream#resolveObject(Object)
Exist testcase only test the subclass' resolveObject rather than testing the super one.

--------- Add test in ObjectInputStreamTest.java---------------------

    static class ObjectInputStreamWithResolveObject extends ObjectInputStream {
        public ObjectInputStreamWithResolveObject(InputStream in) throws IOException {
        protected Object resolveObject(Object obj) throws IOException {
            if(obj instanceof Integer){
                obj = new Integer(1000);
            return super.resolveObject(obj);
     * @tests java.io.ObjectInputStream#resolveObject(Object)
    public void test_resolveObjectLjava_lang_Object() throws Exception {
        // Write an Integer object into memory
        Integer original = new Integer(10);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);

        // Read the object from memory
        byte[] bytes = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        ObjectInputStreamWithResolveObject ois = 
            new ObjectInputStreamWithResolveObject(bais);
        Integer actual = (Integer) ois.readObject();

        // object should be resolved from 10 to 1000 
        assertEquals(new Integer(1000), actual);

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message