@Before public void setUp() throws Exception { testDelegate = new ThriftSerializationDelegate(); testDelegate.prepare(null); }
@Test public void testThriftInstance() throws Exception { ErrorInfo errorInfo = new ErrorInfo(); errorInfo.set_error("error"); errorInfo.set_error_time_secs(1); errorInfo.set_host("host"); errorInfo.set_port(1); byte[] serialized = new ThriftSerializationDelegate().serialize(errorInfo); ErrorInfo errorInfo2 = testDelegate.deserialize(serialized, ErrorInfo.class); assertEquals(errorInfo, errorInfo2); serialized = testDelegate.serialize(errorInfo); errorInfo2 = new ThriftSerializationDelegate().deserialize(serialized, ErrorInfo.class); assertEquals(errorInfo, errorInfo2); }
@Test public void testDeserialize_readingFromDefault() throws Exception { GlobalStreamId id = new GlobalStreamId("A", "B"); byte[] serialized = new ThriftSerializationDelegate().serialize(id); GlobalStreamId id2 = testDelegate.deserialize(serialized, GlobalStreamId.class); assertEquals(id2.get_componentId(), id.get_componentId()); assertEquals(id2.get_streamId(), id.get_streamId()); } }