@Test public void dollarFormatAtom() throws Exception { MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>(); queryParameters.putSingle("$format", "xml"); when(exceptionMapper.uriInfo.getQueryParameters()).thenReturn(queryParameters); Response response = exceptionMapper.toResponse(new Exception("text")); assertNotNull(response); String contentTypeHeader = response.getHeaderString(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE); assertEquals("application/xml", contentTypeHeader); String errorMessage = StringHelper.inputStreamToString((InputStream) response.getEntity()); assertXpathExists("/a:error/a:code", errorMessage); assertXpathEvaluatesTo("text", "/a:error/a:message", errorMessage); }
@Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } return RestUtil.convertResponse(response); }
ODataExceptionMapperImpl implements ExceptionMapper<Exception> { @Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } return RestUtil.convertResponse(response); } }
ODataExceptionMapperImpl implements ExceptionMapper<Exception> { @Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } return RestUtil.convertResponse(response); }  }
ODataExceptionMapperImpl implements ExceptionMapper<Exception> { @Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } return RestUtil.convertResponse(response); }  @Override Response toResponse(final Exception exception); }
ODataExceptionMapperImpl implements ExceptionMapper<Exception> { @Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } return RestUtil.convertResponse(response); }  @Override Response toResponse(final Exception exception);  }