1 package org.opendaylight.controller.northbound.commons.exception;
3 import javax.ws.rs.core.Response;
5 import org.junit.Assert;
8 public class CommonsNorthboundExceptionTest {
11 public void testMethodNotAllowed() {
12 MethodNotAllowed mna = new MethodNotAllowed();
13 Assert.assertTrue(mna.getStatusCode() == 405);
14 Assert.assertTrue(mna.getReasonPhrase().equals("Method Not Allowed"));
15 Assert.assertTrue(mna.getFamily().equals(
16 Response.Status.Family.CLIENT_ERROR));
20 public void testInternalServerErrorException() {
22 throw new InternalServerErrorException("Internal Server Exception");
23 } catch (InternalServerErrorException e) {
24 Assert.assertTrue(e.getResponse().getEntity()
25 .equals("Internal Server Exception"));
30 public void testMethodNotAllowedException() {
32 throw new MethodNotAllowedException("Method Not Allowed Exception");
33 } catch (MethodNotAllowedException e) {
34 Assert.assertTrue(e.getResponse().getEntity()
35 .equals("Method Not Allowed Exception"));
40 public void testNotAcceptableException() {
42 throw new NotAcceptableException("Not Acceptable Exception");
43 } catch (NotAcceptableException e) {
44 Assert.assertTrue(e.getResponse().getEntity()
45 .equals("Not Acceptable Exception"));
50 public void testResourceConflictException() {
52 throw new ResourceConflictException("Resource Conflict Exception");
53 } catch (ResourceConflictException e) {
54 Assert.assertTrue(e.getResponse().getEntity()
55 .equals("Resource Conflict Exception"));
60 public void testResourceForbiddenException() {
62 throw new ResourceForbiddenException("Resource Forbidden Exception");
63 } catch (ResourceForbiddenException e) {
64 Assert.assertTrue(e.getResponse().getEntity()
65 .equals("Resource Forbidden Exception"));
70 public void testResourceGoneException() {
72 throw new ResourceGoneException("Resource Gone Exception");
73 } catch (ResourceGoneException e) {
74 Assert.assertTrue(e.getResponse().getEntity()
75 .equals("Resource Gone Exception"));
80 public void testResourceNotFoundException() {
82 throw new ResourceNotFoundException("Resource Not Found Exception");
83 } catch (ResourceNotFoundException e) {
84 Assert.assertTrue(e.getResponse().getEntity()
85 .equals("Resource Not Found Exception"));
90 public void testServiceUnavailableException() {
92 throw new ServiceUnavailableException(
93 "Service Unavailable Exception");
94 } catch (ServiceUnavailableException e) {
95 Assert.assertTrue(e.getResponse().getEntity()
96 .equals("Service Unavailable Exception"));
101 public void testUnauthorizedException() {
103 throw new UnauthorizedException("Unauthorized Exception");
104 } catch (UnauthorizedException e) {
105 Assert.assertTrue(e.getResponse().getEntity()
106 .equals("Unauthorized Exception"));
111 public void testUnsupportedMediaTypeException() {
113 throw new UnsupportedMediaTypeException(
114 "Unsupported Media Type Exception");
115 } catch (UnsupportedMediaTypeException e) {
116 Assert.assertTrue(e.getResponse().getEntity()
117 .equals("Unsupported Media Type Exception"));