2 * ============LICENSE_START==========================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music.exceptions;
25 import static org.junit.Assert.assertEquals;
27 import org.junit.Test;
29 public class MusicDeadlockExceptionTest {
31 private String owner = "tester";
32 private String keyspace = "testing";
33 private String table = "lockq";
34 private String key = "test";
37 public void TestException1() {
41 if (!s1.equalsIgnoreCase(s2)) {
42 throw new MusicDeadlockException();
44 } catch (MusicDeadlockException mde) {
45 assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
51 public void TestException2() {
55 if (!s1.equalsIgnoreCase(s2)) {
56 throw new MusicDeadlockException("MusicDeadlockException Exception occured..");
58 } catch (MusicDeadlockException mde) {
59 assertEquals(mde.getMessage(), "MusicDeadlockException Exception occured..");
65 public void TestException3() {
69 if (!s1.equalsIgnoreCase(s2)) {
70 throw new MusicDeadlockException(new Throwable());
72 } catch (MusicDeadlockException mve) {
73 assertEquals("org.onap.music.exceptions.MusicDeadlockException", mve.getClass().getName());
79 public void TestException4() {
80 String message = "Exception occured";
84 if (!s1.equalsIgnoreCase(s2)) {
85 throw new MusicDeadlockException(message, new Throwable());
87 } catch (MusicDeadlockException mde) {
88 assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
94 public void TestException5() {
95 String message = "Exception occured";
96 boolean enableSuppression = true;
97 boolean writableStackTrace = false;
101 if (!s1.equalsIgnoreCase(s2)) {
102 throw new MusicDeadlockException(message, new Throwable(), enableSuppression,
105 } catch (MusicDeadlockException mde) {
106 assertEquals("org.onap.music.exceptions.MusicDeadlockException", mde.getClass().getName());
112 public void TestSetValues()
114 MusicDeadlockException mde=new MusicDeadlockException();
115 mde.setValues(owner,keyspace,table,key);
116 assertEquals("tester",mde.getOwner());
117 assertEquals("testing",mde.getKeyspace());
118 assertEquals("lockq",mde.getTable());
119 assertEquals("test",mde.getKey());