Search in sources :

Example 1 with BizExceptionNoDefaultConstructor

use of com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor in project dubbo by alibaba.

the class AbstractSerializationTest method test_BizExceptionNoDefaultConstructor.

@Test
public void test_BizExceptionNoDefaultConstructor() throws Exception {
    BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello");
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(e);
    objectOutput.flushBuffer();
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    Object read = deserialize.readObject();
    assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage());
}
Also used : ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInput(com.alibaba.dubbo.common.serialize.ObjectInput) BizExceptionNoDefaultConstructor(com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor) Test(org.junit.Test)

Example 2 with BizExceptionNoDefaultConstructor

use of com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor in project dubbo by alibaba.

the class AbstractSerializationTest method test_BizExceptionNoDefaultConstructor_WithType.

@Test
public void test_BizExceptionNoDefaultConstructor_WithType() throws Exception {
    BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello");
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(e);
    objectOutput.flushBuffer();
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
    Object read = deserialize.readObject(BizExceptionNoDefaultConstructor.class);
    assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage());
}
Also used : ObjectOutput(com.alibaba.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInput(com.alibaba.dubbo.common.serialize.ObjectInput) BizExceptionNoDefaultConstructor(com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor) Test(org.junit.Test)

Aggregations

BizExceptionNoDefaultConstructor (com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor)2 ObjectInput (com.alibaba.dubbo.common.serialize.ObjectInput)2 ObjectOutput (com.alibaba.dubbo.common.serialize.ObjectOutput)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Test (org.junit.Test)2