@Test public void httpStatusCodeAndReasonPhraseAppearInException() { // 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(404, exception.getHttpStatusCode()); assertEquals("Not Found", exception.getHttpReasonPhrase()); }
@Test public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExceptions() { // Arrange ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); UniformInterfaceException rootCause = new UniformInterfaceException(response); ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException(rootCause)); ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); // Act ServiceException exception = ServiceExceptionFactory.process("actual", new ServiceException(wrappingException)); // Assert assertEquals(503, exception.getHttpStatusCode()); assertEquals("underlying", exception.getServiceName()); }