コード例 #1
0
  @Test
  public void socketTimeoutWillPassUpIfInsideClientHandlerException() {
    String expectedMessage = "connect timeout";
    SocketTimeoutException rootCause = new SocketTimeoutException(expectedMessage);
    ClientHandlerException wrappingException = new ClientHandlerException(rootCause);

    ServiceException exception =
        ServiceExceptionFactory.process("testing", new ServiceException(wrappingException));

    assertSame(ServiceTimeoutException.class, exception.getClass());
    assertEquals(expectedMessage, exception.getMessage());
    assertEquals("testing", exception.getServiceName());
  }
コード例 #2
0
  @Test
  public void serviceNameAndMessageAndCauseAppearInException() {
    // Arrange
    ClientResponse response =
        new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null);
    UniformInterfaceException cause = new UniformInterfaceException(response);

    // Act
    ServiceException exception =
        ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause));

    // Assert
    assertNotNull(exception);
    assertEquals("testing", exception.getServiceName());
    assertEquals("this is a test", exception.getMessage());
    assertEquals(cause, exception.getCause());
  }