Search in sources :

Example 1 with BizException

use of org.apache.dubbo.common.serialize.model.BizException in project dubbo by alibaba.

the class AbstractSerializationTest method test_BizException_WithType.

@Test
public void test_BizException_WithType() throws Exception {
    BizException e = new BizException("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(BizException.class);
    assertEquals("Hello", ((BizException) read).getMessage());
}
Also used : ObjectOutput(org.apache.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) BizException(org.apache.dubbo.common.serialize.model.BizException) ObjectInput(org.apache.dubbo.common.serialize.ObjectInput) Test(org.junit.jupiter.api.Test)

Example 2 with BizException

use of org.apache.dubbo.common.serialize.model.BizException in project dubbo by alibaba.

the class AbstractSerializationTest method test_BizException.

@Test
public void test_BizException() throws Exception {
    BizException e = new BizException("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", ((BizException) read).getMessage());
}
Also used : ObjectOutput(org.apache.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) BizException(org.apache.dubbo.common.serialize.model.BizException) ObjectInput(org.apache.dubbo.common.serialize.ObjectInput) Test(org.junit.jupiter.api.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 ObjectInput (org.apache.dubbo.common.serialize.ObjectInput)2 ObjectOutput (org.apache.dubbo.common.serialize.ObjectOutput)2 BizException (org.apache.dubbo.common.serialize.model.BizException)2 Test (org.junit.jupiter.api.Test)2