1 package com.atlassian.plugins.rest.common.error.jersey;
2
3 import com.atlassian.plugins.rest.common.Status;
4 import junit.framework.TestCase;
5
6 import javax.ws.rs.WebApplicationException;
7 import javax.ws.rs.core.Response;
8
9
10
11
12 public class TestThrowableExceptionMapper extends TestCase
13 {
14 public void testSomeThrowable()
15 {
16 ThrowableExceptionMapper mapper = new ThrowableExceptionMapper();
17 RuntimeException e = new RuntimeException("foo");
18 Response res = mapper.toResponse(e);
19 assertEquals(res.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
20 assertEquals("foo", ((Status)res.getEntity()).getMessage());
21 }
22 public void testWebApplicationException()
23 {
24 ThrowableExceptionMapper mapper = new ThrowableExceptionMapper();
25 WebApplicationException e = new WebApplicationException(444);
26 Response res = mapper.toResponse(e);
27 assertEquals(res.getStatus(), 444);
28 }
29 }