Add junit coverage to PoolException class
[appc.git] / appc-common / src / test / java / org / onap / appc / pool / PoolExceptionTest.java
1 /*-\r
2 * ============LICENSE_START=======================================================\r
3 * ONAP : APPC\r
4 * ================================================================================\r
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
6 * =============================================================================\r
7 * Licensed under the Apache License, Version 2.0 (the "License");\r
8 * you may not use this file except in compliance with the License.\r
9 * You may obtain a copy of the License at\r
10 *\r
11 *      http://www.apache.org/licenses/LICENSE-2.0\r
12 *\r
13 * Unless required by applicable law or agreed to in writing, software\r
14 * distributed under the License is distributed on an "AS IS" BASIS,\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 * See the License for the specific language governing permissions and\r
17 * limitations under the License.\r
18 * ============LICENSE_END=========================================================\r
19 */\r
20 package org.onap.appc.pool;\r
21 \r
22 import org.junit.Assert;\r
23 \r
24 import org.junit.Test;\r
25 \r
26 public class PoolExceptionTest {\r
27 \r
28     @Test\r
29     public void testPoolException() {\r
30         PoolException poolException = new PoolException();\r
31         Assert.assertTrue(poolException.getCause() == null);\r
32         Assert.assertTrue(poolException.getMessage() == null);\r
33     }\r
34 \r
35     @Test\r
36     public void testPoolExceptionString() {\r
37         String message = "test message";\r
38         PoolException poolException = new PoolException(message);\r
39         Assert.assertEquals(message, poolException.getMessage());\r
40         Assert.assertEquals(message, poolException.getLocalizedMessage());\r
41     }\r
42 \r
43     @Test\r
44     public void testPoolExceptionThrowable() {\r
45         String tMessage = "throwable message";\r
46         Throwable throwable = new Throwable(tMessage);\r
47         PoolException poolException = new PoolException(throwable);\r
48         Assert.assertEquals(throwable, poolException.getCause());\r
49     }\r
50 \r
51     @Test\r
52     public void testPoolExceptionStringThrowable() {\r
53         String message = "my test message";\r
54         String tMessage = "throwable message";\r
55         Throwable throwable = new Throwable(tMessage);\r
56         PoolException poolException = new PoolException(message, throwable);\r
57         Assert.assertEquals(throwable, poolException.getCause());\r
58         Assert.assertTrue(poolException.getMessage().contains(message));\r
59         Assert.assertEquals(message, poolException.getLocalizedMessage());\r
60     }\r
61 \r
62     @Test\r
63     public void testPoolExceptionStringThrowableBooleanBoolean() {\r
64         String message = "my test message";\r
65         String tMessage = "throwable message";\r
66         Throwable throwable = new Throwable(tMessage);\r
67         PoolException poolException = new PoolException(message, throwable, true, true);\r
68         Assert.assertEquals(throwable, poolException.getCause());\r
69         Assert.assertTrue(poolException.getMessage().contains(message));\r
70         Assert.assertEquals(message, poolException.getLocalizedMessage());\r
71     }\r
72 \r
73 }\r