unitests: Remove extending TestCase from unitest classes.
[controller.git] / opendaylight / northbound / commons / src / test / java / org / opendaylight / controller / northbound / commons / exception / CommonsNorthboundExceptionTest.java
1 package org.opendaylight.controller.northbound.commons.exception;
2
3 import javax.ws.rs.core.Response;
4
5 import org.junit.Assert;
6 import org.junit.Test;
7
8 public class CommonsNorthboundExceptionTest {
9
10     @Test
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));
17     }
18
19     @Test
20     public void testInternalServerErrorException() {
21         try {
22             throw new InternalServerErrorException("Internal Server Exception");
23         } catch (InternalServerErrorException e) {
24             Assert.assertTrue(e.getResponse().getEntity()
25                     .equals("Internal Server Exception"));
26         }
27     }
28
29     @Test
30     public void testMethodNotAllowedException() {
31         try {
32             throw new MethodNotAllowedException("Method Not Allowed Exception");
33         } catch (MethodNotAllowedException e) {
34             Assert.assertTrue(e.getResponse().getEntity()
35                     .equals("Method Not Allowed Exception"));
36         }
37     }
38
39     @Test
40     public void testNotAcceptableException() {
41         try {
42             throw new NotAcceptableException("Not Acceptable Exception");
43         } catch (NotAcceptableException e) {
44             Assert.assertTrue(e.getResponse().getEntity()
45                     .equals("Not Acceptable Exception"));
46         }
47     }
48
49     @Test
50     public void testResourceConflictException() {
51         try {
52             throw new ResourceConflictException("Resource Conflict Exception");
53         } catch (ResourceConflictException e) {
54             Assert.assertTrue(e.getResponse().getEntity()
55                     .equals("Resource Conflict Exception"));
56         }
57     }
58
59     @Test
60     public void testResourceForbiddenException() {
61         try {
62             throw new ResourceForbiddenException("Resource Forbidden Exception");
63         } catch (ResourceForbiddenException e) {
64             Assert.assertTrue(e.getResponse().getEntity()
65                     .equals("Resource Forbidden Exception"));
66         }
67     }
68
69     @Test
70     public void testResourceGoneException() {
71         try {
72             throw new ResourceGoneException("Resource Gone Exception");
73         } catch (ResourceGoneException e) {
74             Assert.assertTrue(e.getResponse().getEntity()
75                     .equals("Resource Gone Exception"));
76         }
77     }
78
79     @Test
80     public void testResourceNotFoundException() {
81         try {
82             throw new ResourceNotFoundException("Resource Not Found Exception");
83         } catch (ResourceNotFoundException e) {
84             Assert.assertTrue(e.getResponse().getEntity()
85                     .equals("Resource Not Found Exception"));
86         }
87     }
88
89     @Test
90     public void testServiceUnavailableException() {
91         try {
92             throw new ServiceUnavailableException(
93                     "Service Unavailable Exception");
94         } catch (ServiceUnavailableException e) {
95             Assert.assertTrue(e.getResponse().getEntity()
96                     .equals("Service Unavailable Exception"));
97         }
98     }
99
100     @Test
101     public void testUnauthorizedException() {
102         try {
103             throw new UnauthorizedException("Unauthorized Exception");
104         } catch (UnauthorizedException e) {
105             Assert.assertTrue(e.getResponse().getEntity()
106                     .equals("Unauthorized Exception"));
107         }
108     }
109
110     @Test
111     public void testUnsupportedMediaTypeException() {
112         try {
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"));
118         }
119     }
120
121 }