Package org.apache.hadoop.yarn.api.records.impl.pb

Examples of org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl


import org.junit.Test;

public class TestSerializedExceptionPBImpl {
  @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());
  }
View Full Code Here


  }

  @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());
  }
View Full Code Here

  @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());
  }
View Full Code Here

    return ((ContainerIdPBImpl) t).getProto();
  }

  private SerializedExceptionPBImpl convertFromProtoFormat(
      SerializedExceptionProto p) {
    return new SerializedExceptionPBImpl(p);
  }
View Full Code Here

    return ((ContainerIdPBImpl) t).getProto();
  }

  private SerializedExceptionPBImpl convertFromProtoFormat(
      SerializedExceptionProto p) {
    return new SerializedExceptionPBImpl(p);
  }
View Full Code Here

    return ((ContainerIdPBImpl) t).getProto();
  }

  private SerializedExceptionPBImpl convertFromProtoFormat(
      SerializedExceptionProto p) {
    return new SerializedExceptionPBImpl(p);
  }
View Full Code Here

  private ResourceStatusType convertFromProtoFormat(ResourceStatusTypeProto e) {
    return ResourceStatusType.valueOf(e.name());
  }

  private SerializedExceptionPBImpl convertFromProtoFormat(SerializedExceptionProto p) {
    return new SerializedExceptionPBImpl(p);
  }
View Full Code Here

  /**
   * Test SerializedExceptionPBImpl.
   */
  @Test
  public void testSerializedExceptionPBImpl() {
    SerializedExceptionPBImpl original = new SerializedExceptionPBImpl();
    original.init("testMessage");
    SerializedExceptionPBImpl copy = new SerializedExceptionPBImpl(
        original.getProto());
    assertEquals("testMessage", copy.getMessage());

    original = new SerializedExceptionPBImpl();
    original.init("testMessage", new Throwable(new Throwable("parent")));
    copy = new SerializedExceptionPBImpl(original.getProto());
    assertEquals("testMessage", copy.getMessage());
    assertEquals("parent", copy.getCause().getMessage());
    assertTrue( copy.getRemoteTrace().startsWith(
        "java.lang.Throwable: java.lang.Throwable: parent"));

  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.