@Test public void testSerializedException() throws Exception { SerializedExceptionPBImpl orig = new SerializedExceptionPBImpl(); orig.init(new Exception("test exception")); SerializedExceptionProto proto = orig.getProto(); SerializedExceptionPBImpl deser = new SerializedExceptionPBImpl(proto); Assert.assertEquals(orig, deser); Assert.assertEquals(orig.getMessage(), deser.getMessage()); Assert.assertEquals(orig.getRemoteTrace(), deser.getRemoteTrace()); Assert.assertEquals(orig.getCause(), deser.getCause()); }
@Test public void testBeforeInit() throws Exception { SerializedExceptionProto defaultProto = SerializedExceptionProto.newBuilder().build(); SerializedExceptionPBImpl pb1 = new SerializedExceptionPBImpl(); Assert.assertNull(pb1.getCause()); SerializedExceptionPBImpl pb2 = new SerializedExceptionPBImpl(); Assert.assertEquals(defaultProto, pb2.getProto()); SerializedExceptionPBImpl pb3 = new SerializedExceptionPBImpl(); Assert.assertEquals(defaultProto.getTrace(), pb3.getRemoteTrace()); }
private SerializedExceptionPBImpl convertFromProtoFormat( SerializedExceptionProto p) { return new SerializedExceptionPBImpl(p); }
private SerializedExceptionProto convertToProtoFormat(SerializedException t) { return ((SerializedExceptionPBImpl) t).getProto(); }
public SerializedExceptionPBImpl(SerializedExceptionProto proto) { this.proto = proto; viaProto = true; }
public SerializedExceptionProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; }
private void maybeInitBuilder() { if (viaProto || builder == null) { builder = SerializedExceptionProto.newBuilder(proto); } viaProto = false; }
private SerializedExceptionPBImpl convertFromProtoFormat(SerializedExceptionProto p) { return new SerializedExceptionPBImpl(p); }
private SerializedExceptionProto convertToProtoFormat(SerializedException t) { return ((SerializedExceptionPBImpl)t).getProto(); }
@Test public void testSerializedExceptionPBImpl() throws Exception { validatePBImplRecord(SerializedExceptionPBImpl.class, SerializedExceptionProto.class); }