Add junit coverage to PoolException class 65/42065/2
authorMei Su <ms6523@att.com>
Tue, 10 Apr 2018 20:56:16 +0000 (16:56 -0400)
committerTakamune Cho <tc012c@att.com>
Wed, 11 Apr 2018 14:58:25 +0000 (14:58 +0000)
Introduce junit-tests for PoolException class

Issue-ID: APPC-845
Change-Id: Id33a660decb77b0fe8662d29bd7676efd08d8e4b
Signed-off-by: Mei Su <ms6523@att.com>
appc-common/src/test/java/org/onap/appc/pool/PoolExceptionTest.java [new file with mode: 0644]

diff --git a/appc-common/src/test/java/org/onap/appc/pool/PoolExceptionTest.java b/appc-common/src/test/java/org/onap/appc/pool/PoolExceptionTest.java
new file mode 100644 (file)
index 0000000..34ecd85
--- /dev/null
@@ -0,0 +1,73 @@
+/*-\r
+* ============LICENSE_START=======================================================\r
+* ONAP : APPC\r
+* ================================================================================\r
+* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
+* =============================================================================\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+*      http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+* ============LICENSE_END=========================================================\r
+*/\r
+package org.onap.appc.pool;\r
+\r
+import org.junit.Assert;\r
+\r
+import org.junit.Test;\r
+\r
+public class PoolExceptionTest {\r
+\r
+    @Test\r
+    public void testPoolException() {\r
+        PoolException poolException = new PoolException();\r
+        Assert.assertTrue(poolException.getCause() == null);\r
+        Assert.assertTrue(poolException.getMessage() == null);\r
+    }\r
+\r
+    @Test\r
+    public void testPoolExceptionString() {\r
+        String message = "test message";\r
+        PoolException poolException = new PoolException(message);\r
+        Assert.assertEquals(message, poolException.getMessage());\r
+        Assert.assertEquals(message, poolException.getLocalizedMessage());\r
+    }\r
+\r
+    @Test\r
+    public void testPoolExceptionThrowable() {\r
+        String tMessage = "throwable message";\r
+        Throwable throwable = new Throwable(tMessage);\r
+        PoolException poolException = new PoolException(throwable);\r
+        Assert.assertEquals(throwable, poolException.getCause());\r
+    }\r
+\r
+    @Test\r
+    public void testPoolExceptionStringThrowable() {\r
+        String message = "my test message";\r
+        String tMessage = "throwable message";\r
+        Throwable throwable = new Throwable(tMessage);\r
+        PoolException poolException = new PoolException(message, throwable);\r
+        Assert.assertEquals(throwable, poolException.getCause());\r
+        Assert.assertTrue(poolException.getMessage().contains(message));\r
+        Assert.assertEquals(message, poolException.getLocalizedMessage());\r
+    }\r
+\r
+    @Test\r
+    public void testPoolExceptionStringThrowableBooleanBoolean() {\r
+        String message = "my test message";\r
+        String tMessage = "throwable message";\r
+        Throwable throwable = new Throwable(tMessage);\r
+        PoolException poolException = new PoolException(message, throwable, true, true);\r
+        Assert.assertEquals(throwable, poolException.getCause());\r
+        Assert.assertTrue(poolException.getMessage().contains(message));\r
+        Assert.assertEquals(message, poolException.getLocalizedMessage());\r
+    }\r
+\r
+}\r