Search in sources :

Example 1 with BizExceptionNoDefaultConstructor

use of org.apache.dubbo.common.serialize.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(org.apache.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInput(org.apache.dubbo.common.serialize.ObjectInput) BizExceptionNoDefaultConstructor(org.apache.dubbo.common.serialize.model.BizExceptionNoDefaultConstructor) Test(org.junit.jupiter.api.Test)

Example 2 with BizExceptionNoDefaultConstructor

use of org.apache.dubbo.common.serialize.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(org.apache.dubbo.common.serialize.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInput(org.apache.dubbo.common.serialize.ObjectInput) BizExceptionNoDefaultConstructor(org.apache.dubbo.common.serialize.model.BizExceptionNoDefaultConstructor) 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 BizExceptionNoDefaultConstructor (org.apache.dubbo.common.serialize.model.BizExceptionNoDefaultConstructor)2 Test (org.junit.jupiter.api.Test)2