/*
 * 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.io.input;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectOutputStream;

import junit.framework.TestCase;

/**
 * Tests the CountingInputStream.
 *
 * @version $Id$
 */
public class ClassLoaderObjectInputStreamTest extends TestCase {

    public ClassLoaderObjectInputStreamTest(final String name) {
        super(name);
    }

    /* Note: This test case tests the simplest functionality of
     * ObjectInputStream.  IF we really wanted to test ClassLoaderObjectInputStream
     * we would probably need to create a transient Class Loader. -TO
     */

    
    public void testExpected() throws Exception {

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);

        oos.writeObject( Boolean.FALSE );

        final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ClassLoaderObjectInputStream clois = 
            new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais);
        final Boolean result = (Boolean) clois.readObject();

        assertTrue( !result.booleanValue() );
        clois.close();
    }

    public void testResolveProxyClass() throws Exception {

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject( Boolean.FALSE );
        final InputStream bais = new ByteArrayInputStream(baos.toByteArray());

        final ClassLoaderObjectInputStream clois = 
            new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais);
        final String[] interfaces = new String[] { Comparable.class.getName() };
        final Class<?> result = clois.resolveProxyClass(interfaces);
        assertTrue("Assignable", Comparable.class.isAssignableFrom(result));
        clois.close();
    }
    
}

@@ -973,16 +973,45 @@
 tStream;
+%0Aimport java.io.Serializable;
 %0A%0Aimport
@@ -1503,24 +1503,25 @@
 public void 
+x
 testExpected
@@ -1697,39 +1697,2350 @@
     
-oos.writeObject( Boolean.FALSE 
+final Object input = Boolean.FALSE;%0A        oos.writeObject( input );%0A%0A        final InputStream bais = new ByteArrayInputStream(baos.toByteArray());%0A        final ClassLoaderObjectInputStream clois = %0A            new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais);%0A        final Object result = clois.readObject();%0A%0A        assertEquals(input, result );%0A        clois.close();%0A    %7D%0A%0A    public void xtestLong() throws Exception %7B%0A%0A        final ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A        final ObjectOutputStream oos = new ObjectOutputStream(baos);%0A%0A        final Object input = Long.valueOf(123);%0A        oos.writeObject(input);%0A%0A        final InputStream bais = new ByteArrayInputStream(baos.toByteArray());%0A        final ClassLoaderObjectInputStream clois = %0A            new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais);%0A        final Object result = clois.readObject();%0A%0A        assertEquals(input, result);%0A        clois.close();%0A    %7D%0A%0A    public void xtestPrimitiveLong() throws Exception %7B%0A%0A        final ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A        final ObjectOutputStream oos = new ObjectOutputStream(baos);%0A%0A        final long input = 12345L;%0A        oos.writeLong(input);%0A        oos.close();%0A%0A        final InputStream bais = new ByteArrayInputStream(baos.toByteArray());%0A        final ClassLoaderObjectInputStream clois = %0A            new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais);%0A        final long result = clois.readLong();%0A%0A        assertEquals(input, result);%0A        clois.close();%0A    %7D%0A%0A    private static class Test implements Serializable %7B%0A        private static final long serialVersionUID = 1L;%0A        private int i;%0A%0A        Test(int i) %7B%0A            this.i = i;%0A        %7D%0A        @Override%0A        public boolean equals(Object other) %7B%0A            return other instanceof Test & (this.i == ((Test)other).i);%0A        %7D%0A        @Override%0A        public int hashCode() %7B%0A            return super.hashCode();%0A        %7D%0A    %7D%0A    public void testString() throws Exception %7B%0A%0A        final ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A        final ObjectOutputStream oos = new ObjectOutputStream(baos);%0A%0A        final Object input = new Test(123);%0A        oos.writeObject(input);%0A        oos.close(
 );%0A%0A
@@ -4265,23 +4265,22 @@
   final 
-Boolean
+Object
  result 
@@ -4284,18 +4284,8 @@
 lt =
- (Boolean)
  clo
@@ -4320,37 +4320,28 @@
 sert
-True( !result.booleanValue() 
+Equals(input, result
 );%0A 
@@ -4381,24 +4381,25 @@
 public void 
+x
 testResolveP

Add some more tests