2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.dom.api;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 public class DOMExceptionsTest {
22 private static final String TEST_MESSAGE = "TestMessage";
23 private static final String TEST_LISTS = "test-lists";
24 private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
25 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
26 private static final YangInstanceIdentifier TEST_YI_ID = YangInstanceIdentifier.create(
27 new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
28 private static final DOMDataTreeIdentifier TEST_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
31 @Test(expected = DOMDataTreeInaccessibleException.class)
32 public void testDomDataTreeInaccessibleException() throws Exception {
33 final DOMDataTreeInaccessibleException testExc = new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE);
34 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
35 assertNotNull(testExc.getTreeIdentifier());
36 assertEquals(TEST_TREE, testExc.getTreeIdentifier());
38 throw new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE, new Throwable());
41 @Test(expected = DOMDataTreeListeningException.class)
42 public void testDomDataTreeListeningException() throws Exception {
43 final DOMDataTreeListeningException testExc = new DOMDataTreeListeningException(TEST_MESSAGE);
44 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
46 throw new DOMDataTreeListeningException(TEST_MESSAGE, new Throwable());
49 @Test(expected = DOMDataTreeLoopException.class)
50 public void testDomDataTreeLoopException() throws Exception {
51 final DOMDataTreeLoopException testExc = new DOMDataTreeLoopException(TEST_MESSAGE);
52 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
54 throw new DOMDataTreeLoopException(TEST_MESSAGE, new Throwable());
57 @Test(expected = DOMDataTreeProducerBusyException.class)
58 public void testDomDataTreeProducerBusyException() throws Exception {
59 final DOMDataTreeProducerBusyException testExc = new DOMDataTreeProducerBusyException(TEST_MESSAGE);
60 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
62 throw new DOMDataTreeProducerBusyException(TEST_MESSAGE, new Throwable());
65 @Test(expected = DOMDataTreeProducerException.class)
66 public void testDOMDataTreeProducerException() throws Exception {
67 final DOMDataTreeProducerException testExc = new DOMDataTreeProducerException(TEST_MESSAGE);
68 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
70 throw new DOMDataTreeProducerException(TEST_MESSAGE, new Throwable());
73 @Test(expected = DOMDataTreeShardingConflictException.class)
74 public void testDOMDataTreeShardingConflictException() throws Exception {
75 final DOMDataTreeShardingConflictException testExc = new DOMDataTreeShardingConflictException(TEST_MESSAGE);
76 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
78 throw new DOMDataTreeShardingConflictException(TEST_MESSAGE, new Throwable());
81 @Test(expected = DOMNotificationRejectedException.class)
82 public void testDomNotificationRejectedException() throws Exception {
83 final DOMNotificationRejectedException testExc = new DOMNotificationRejectedException(TEST_MESSAGE);
84 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
86 throw new DOMNotificationRejectedException(TEST_MESSAGE, new Throwable());
89 @Test(expected = DOMRpcImplementationNotAvailableException.class)
90 public void testDomRpcImplementationNotAvailableException() throws Exception {
91 final DOMRpcImplementationNotAvailableException dompcImplementationNotAvailableException
92 = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
93 assertTrue(dompcImplementationNotAvailableException.getMessage().contains(TEST_MESSAGE));
95 throw new DOMRpcImplementationNotAvailableException(new Throwable(), TEST_MESSAGE, new Object());