You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sean Qiu (JIRA)" <ji...@apache.org> on 2007/06/13 03:41:26 UTC
[jira] Commented: (HARMONY-3400) [classlib][luni] Add testcase for
ObjectInputStream's resolveObject(Object) function
[ https://issues.apache.org/jira/browse/HARMONY-3400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504085 ]
Sean Qiu commented on HARMONY-3400:
-----------------------------------
Thanks, Richard.
Verified by Sean at revision r518898
> [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
> Assignee: Richard Liang
> Attachments: Harmony-3400.diff
>
>
> 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 {
> super(in);
> enableResolveObject(true);
> }
>
> 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);
> oos.writeObject(original);
> oos.flush();
> oos.close();
> // Read the object from memory
> byte[] bytes = baos.toByteArray();
> ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
> ObjectInputStreamWithResolveObject ois =
> new ObjectInputStreamWithResolveObject(bais);
> Integer actual = (Integer) ois.readObject();
> ois.close();
> // 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.