@Test public void testDeserialize() throws Exception { Exception ex = new Exception("test exception"); SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl(); try { pb.deSerialize(); Assert.fail("deSerialze should throw YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass()); } pb.init(ex); Assert.assertEquals(ex.toString(), pb.deSerialize().toString()); }
private void mergeLocalToBuilder() { if (this.resource != null && !((LocalResourcePBImpl)this.resource).getProto() .equals(builder.getResource())) { builder.setResource(convertToProtoFormat(this.resource)); } if (this.localPath != null && !((URLPBImpl)this.localPath).getProto() .equals(builder.getLocalPath())) { builder.setLocalPath(convertToProtoFormat(this.localPath)); } if (this.exception != null && !((SerializedExceptionPBImpl)this.exception).getProto() .equals(builder.getException())) { builder.setException(convertToProtoFormat(this.exception)); } }
@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(); }
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); }