MusicAuthenticationException.java-junits
[music.git] / music-core / src / test / java / org / onap / music / exceptions / MusicDeadlockExceptionTest.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  * Copyright (c) 2019 IBM Intellectual Property
6  * ===================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22
23 package org.onap.music.exceptions;
24
25 import static org.junit.Assert.assertEquals;
26
27 import org.junit.Test;
28
29 public class MusicDeadlockExceptionTest {
30         
31         private String owner = "tester";
32         private String keyspace = "testing";
33         private String table = "lockq";
34         private String key = "test";
35
36          @Test
37             public void TestException1() {
38                 String s1 = "Value1";
39                 String s2 = "value2";
40                 try {
41                     if (!s1.equalsIgnoreCase(s2)) {
42                         throw new MusicDeadlockException();
43                     }
44                 } catch (MusicDeadlockException mde) {
45                     assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
46                 }
47
48             }
49          
50          @Test
51             public void TestException6() {
52                 String s1 = "Value1";
53                 String s2 = "value2";
54                 try {
55                     if (!s1.equalsIgnoreCase(s2)) {
56                         throw new MusicDeadlockException("org.onap.music.exceptions.MusicDeadlockException");
57                     }
58                 } catch (MusicDeadlockException mde) {
59                     assertEquals(mde.getMessage(),"org.onap.music.exceptions.MusicDeadlockException");
60                 }
61
62             }
63
64             @Test
65             public void TestException2() {
66                 String s1 = "Value1";
67                 String s2 = "value2";
68                 try {
69                     if (!s1.equalsIgnoreCase(s2)) {
70                         throw new MusicDeadlockException("MusicDeadlockException Exception occured..");
71                     }
72                 } catch (MusicDeadlockException mde) {
73                     assertEquals(mde.getMessage(), "MusicDeadlockException Exception occured..");
74                 }
75
76             }
77
78             @Test
79             public void TestException3() {
80                 String s1 = "Value1";
81                 String s2 = "value2";
82                 try {
83                     if (!s1.equalsIgnoreCase(s2)) {
84                         throw new MusicDeadlockException(new Throwable());
85                     }
86                 } catch (MusicDeadlockException mve) {
87                     assertEquals("org.onap.music.exceptions.MusicDeadlockException", mve.getClass().getName());
88                 }
89
90             }
91
92             @Test
93             public void TestException4() {
94                 String message = "Exception occured";
95                 String s1 = "Value1";
96                 String s2 = "value2";
97                 try {
98                     if (!s1.equalsIgnoreCase(s2)) {
99                         throw new MusicDeadlockException(message, new Throwable());
100                     }
101                 } catch (MusicDeadlockException mde) {
102                     assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
103                 }
104
105             }
106
107             @Test
108             public void TestException5() {
109                 String message = "Exception occured";
110                 boolean enableSuppression = true;
111                 boolean writableStackTrace = false;
112                 String s1 = "Value1";
113                 String s2 = "value2";
114                 try {
115                     if (!s1.equalsIgnoreCase(s2)) {
116                         throw new MusicDeadlockException(message, new Throwable(), enableSuppression,
117                                 writableStackTrace);
118                     }
119                 } catch (MusicDeadlockException mde) {
120                     assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
121                 }
122
123             }
124             
125             @Test
126             public void TestSetValues()
127             {
128                 MusicDeadlockException mde=new MusicDeadlockException();
129                 mde.setValues(owner,keyspace,table,key);
130                 assertEquals("tester",mde.getOwner());
131                 assertEquals("testing",mde.getKeyspace());
132                 assertEquals("lockq",mde.getTable());
133                 assertEquals("test",mde.getKey());
134             }
135 }