com.alibaba.dubbo.common.serialize.ObjectOutput Java Examples

The following examples show how to use com.alibaba.dubbo.common.serialize.ObjectOutput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastJsonSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_MediaContent_badStream() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(mediaContent);
    objectOutput.flushBuffer();

    byte[] byteArray = byteArrayOutputStream.toByteArray();
    for (int i = 0; i < byteArray.length; i++) {
        if(i%3 == 0) {
            byteArray[i] = (byte)~byteArray[i];
        }
    }
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    
    try {
        ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
        @SuppressWarnings("unused") // local variable, convenient for debug
        Object read = deserialize.readObject();
        fail();
    } catch (JSONException expected) {
        System.out.println(expected);
    }
}
 
Example #2
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_floatArray_withType() throws Exception {
    float[] data = new float[]{37F, -3.14F, 123456.7F};

    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals(data, (float[]) deserialize.readObject(float[].class), 0.0001F);

    try {
        deserialize.readObject(float[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #3
Source File: FastJsonSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_MediaContent_badStream() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(mediaContent);
    objectOutput.flushBuffer();

    byte[] byteArray = byteArrayOutputStream.toByteArray();
    for (int i = 0; i < byteArray.length; i++) {
        if(i%3 == 0) {
            byteArray[i] = (byte)~byteArray[i];
        }
    }
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    
    try {
        ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
        @SuppressWarnings("unused") // local variable, convenient for debug
        Object read = deserialize.readObject();
        fail();
    } catch (JSONException expected) {
        System.out.println(expected);
    }
}
 
Example #4
Source File: Hessian2SerializationTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_longArray_withType() throws Exception {
    long[] data = new long[] { 234, 0, -1};
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals(data, (long[]) deserialize.readObject());

    try {
        deserialize.readObject(long[].class);
        fail();
    } 
    catch (ArrayIndexOutOfBoundsException e) {} 
    // NOTE: Hessian2抛出了ArrayIndexOutOfBoundsException 而不是 IOException!!
    // 容忍这个问题!!
}
 
Example #5
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_doubleArray_withType() throws Exception {
    double[] data = new double[] { 37D, -3.14D, 123456.7D };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (double[]) deserialize.readObject(double[].class), 0.0001);
    
    try {
        deserialize.readObject(double[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #6
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_MediaContent_badStream() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(mediaContent);
    objectOutput.flushBuffer();

    byte[] byteArray = byteArrayOutputStream.toByteArray();
    for (int i = 0; i < byteArray.length; i++) {
        if(i%3 == 0) {
            byteArray[i] = (byte)~byteArray[i];
        }
    }
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    
    try {
        ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
        @SuppressWarnings("unused") // local variable, convenient for debug
        Object read = deserialize.readObject();
        fail();
    } catch (IOException expected) {
        System.out.println(expected);
    }
}
 
Example #7
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Long() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeLong(123L);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals(123L, deserialize.readLong());

    try {
        deserialize.readLong();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #8
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_UtfString() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeUTF("123中华人民共和国");
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals("123中华人民共和国", deserialize.readUTF());

    try {
        deserialize.readUTF();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #9
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
<T> void assertObjectWithType(T data, Class<T> clazz) throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals(data, (T) deserialize.readObject(clazz));

    try {
        deserialize.readObject(clazz);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #10
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Long() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeLong(123L);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals(123L, deserialize.readLong());

    try {
        deserialize.readLong();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #11
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_longArray_withType() throws Exception {
    long[] data = new long[] { 234, 0, -1};
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (long[]) deserialize.readObject(long[].class));
    
    try {
        deserialize.readObject(long[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #12
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_floatArray() throws Exception {
    float[] data = new float[] { 37F, -3.14F, 123456.7F };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F);
    
    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #13
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Byte() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeByte((byte) 123);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals((byte) 123, deserialize.readByte());

    try {
        deserialize.readByte();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #14
Source File: DubboCodec.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Override
protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException {
    RpcInvocation inv = (RpcInvocation) data;

    out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION));
    out.writeUTF(inv.getAttachment(Constants.PATH_KEY));
    out.writeUTF(inv.getAttachment(Constants.VERSION_KEY));

    out.writeUTF(inv.getMethodName());

    // NOTICE modified by lishen
    // TODO
    if (getSerialization(channel) instanceof OptimizedSerialization && !containComplexArguments(inv)) {
        out.writeInt(inv.getParameterTypes().length);
    } else {
        out.writeInt(-1);
        out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes()));
    }

    Object[] args = inv.getArguments();
    if (args != null)
        for (int i = 0; i < args.length; i++){
            out.writeObject(encodeInvocationArgument(channel, inv, i));
        }
    out.writeObject(inv.getAttachments());
}
 
Example #15
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_boolArray_withType() throws Exception {
    boolean[] data = new boolean[]{true, false, true};

    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject(boolean[].class)));

    try {
        deserialize.readObject(boolean[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #16
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bytes() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBytes("123中华人民共和国".getBytes());
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());

    try {
        deserialize.readBytes();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #17
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
<T> void assertObject(T data) throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals(data, (T) deserialize.readObject());

    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #18
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bool() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBool(false);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertFalse(deserialize.readBool());

    try {
        deserialize.readBool();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #19
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_doubleArray() throws Exception {
    double[] data = new double[] { 37D, -3.14D, 123456.7D };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (double[]) deserialize.readObject(), 0.0001);
    
    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #20
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Short() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeShort((short) 123);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals((short) 123, deserialize.readShort());

    try {
        deserialize.readShort();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #21
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Short() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeShort((short) 123);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals((short) 123, deserialize.readShort());

    try {
        deserialize.readShort();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #22
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test(timeout=3000)
public void test_LoopReference() throws Exception {
    Map<String, Object> map= new HashMap<String, Object>();
    map.put("k1", "v1");
    map.put("self", map);
    

    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(map);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    @SuppressWarnings("unchecked")
    Map<String, Object> output = (Map<String, Object>) deserialize.readObject();
    
    assertEquals("v1", output.get("k1"));
    assertSame(output, output.get("self"));
}
 
Example #23
Source File: AbstractSerializationTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_intArray_withType() throws Exception {
    int[] data = new int[] { 234, 0, -1};
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertArrayEquals(data, (int[]) deserialize.readObject(int[].class));

    try {
        deserialize.readObject(int[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #24
Source File: AbstractSerializationTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_floatArray_withType() throws Exception {
    float[] data = new float[] { 37F, -3.14F, 123456.7F };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (float[]) deserialize.readObject(float[].class), 0.0001F);
    
    try {
        deserialize.readObject(float[].class);
        fail();
    } catch (IOException expected) {
    }
}
 
Example #25
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_Bool() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBool(false);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertFalse(deserialize.readBool());

    try {
        deserialize.readBool();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #26
Source File: AbstractSerializationTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_floatArray() throws Exception {
    float[] data = new float[] { 37F, -3.14F, 123456.7F };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F);
    
    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
Example #27
Source File: Hessian2SerializationTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_floatArray_withType() throws Exception {
    float[] data = new float[] { 37F, -3.14F, 123456.7F };
    
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();
    
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    
    assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F);
    
    try {
        deserialize.readObject(float[].class);
        fail();
    } 
    catch (ArrayIndexOutOfBoundsException e) {} 
    // NOTE: Hessian2抛出了ArrayIndexOutOfBoundsException 而不是 IOException!!
    // 容忍这个问题!!
}
 
Example #28
Source File: DubboCodec.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data) throws IOException {
    Result result = (Result) data;

    Throwable th = result.getException();
    if (th == null) {
        Object ret = result.getValue();
        if (ret == null) {
            out.writeByte(RESPONSE_NULL_VALUE);
        } else {
            out.writeByte(RESPONSE_VALUE);
            out.writeObject(ret);
        }
    } else {
        out.writeByte(RESPONSE_WITH_EXCEPTION);
        out.writeObject(th);
    }
}
 
Example #29
Source File: DubboCodec.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data, String version) throws IOException {
    Result result = (Result) data;
    // currently, the version value in Response records the version of Request
    boolean attach = Version.isSupportResponseAttatchment(version);
    Throwable th = result.getException();
    if (th == null) {
        Object ret = result.getValue();
        if (ret == null) {
            out.writeByte(attach ? RESPONSE_NULL_VALUE_WITH_ATTACHMENTS : RESPONSE_NULL_VALUE);
        } else {
            out.writeByte(attach ? RESPONSE_VALUE_WITH_ATTACHMENTS : RESPONSE_VALUE);
            out.writeObject(ret);
        }
    } else {
        out.writeByte(attach ? RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS : RESPONSE_WITH_EXCEPTION);
        out.writeObject(th);
    }

    if (attach) {
        // returns current version of Response to consumer side.
        result.getAttachments().put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
        out.writeObject(result.getAttachments());
    }
}
 
Example #30
Source File: AbstractSerializationTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_URL_mutable_withType() throws Exception {
    URL data = URL.valueOf("dubbo://admin:[email protected]:20880/context/path?version=1.0.0&application=morgan&noValue");

    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(data);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    URL actual = (URL) deserialize.readObject(URL.class);
    assertEquals(data, actual);
    assertEquals(data.getParameters(), actual.getParameters());

    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}