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;
22 public class DOMExceptionsTest {
23 private static final String TEST_MESSAGE = "TestMessage";
24 private static final String TEST_LISTS = "test-lists";
25 private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
26 "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"));
27 private static final YangInstanceIdentifier TEST_YI_ID = YangInstanceIdentifier.create(
28 new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
29 private static final DOMDataTreeIdentifier TEST_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
32 @Test(expected = DOMDataTreeInaccessibleException.class)
33 public void testDomDataTreeInaccessibleException() throws Exception {
34 final DOMDataTreeInaccessibleException testExc = new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE);
35 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
36 assertNotNull(testExc.getTreeIdentifier());
37 assertEquals(TEST_TREE, testExc.getTreeIdentifier());
39 throw new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE, new Throwable());
42 @Test(expected = DOMDataTreeListeningException.class)
43 public void testDomDataTreeListeningException() throws Exception {
44 final DOMDataTreeListeningException testExc = new DOMDataTreeListeningException(TEST_MESSAGE);
45 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
47 throw new DOMDataTreeListeningException(TEST_MESSAGE, new Throwable());
50 @Test(expected = DOMDataTreeLoopException.class)
51 public void testDomDataTreeLoopException() throws Exception {
52 final DOMDataTreeLoopException testExc = new DOMDataTreeLoopException(TEST_MESSAGE);
53 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
55 throw new DOMDataTreeLoopException(TEST_MESSAGE, new Throwable());
58 @Test(expected = DOMDataTreeProducerBusyException.class)
59 public void testDomDataTreeProducerBusyException() throws Exception {
60 final DOMDataTreeProducerBusyException testExc = new DOMDataTreeProducerBusyException(TEST_MESSAGE);
61 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
63 throw new DOMDataTreeProducerBusyException(TEST_MESSAGE, new Throwable());
66 @Test(expected = DOMDataTreeProducerException.class)
67 public void testDOMDataTreeProducerException() throws Exception {
68 final DOMDataTreeProducerException testExc = new DOMDataTreeProducerException(TEST_MESSAGE);
69 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
71 throw new DOMDataTreeProducerException(TEST_MESSAGE, new Throwable());
74 @Test(expected = DOMDataTreeShardingConflictException.class)
75 public void testDOMDataTreeShardingConflictException() throws Exception {
76 final DOMDataTreeShardingConflictException testExc = new DOMDataTreeShardingConflictException(TEST_MESSAGE);
77 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
79 throw new DOMDataTreeShardingConflictException(TEST_MESSAGE, new Throwable());
82 @Test(expected = DOMNotificationRejectedException.class)
83 public void testDomNotificationRejectedException() throws Exception {
84 final DOMNotificationRejectedException testExc = new DOMNotificationRejectedException(TEST_MESSAGE);
85 assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
87 throw new DOMNotificationRejectedException(TEST_MESSAGE, new Throwable());
90 @Test(expected = DOMRpcImplementationNotAvailableException.class)
91 public void testDomRpcImplementationNotAvailableException() throws Exception {
92 final DOMRpcImplementationNotAvailableException dompcImplementationNotAvailableException
93 = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
94 assertTrue(dompcImplementationNotAvailableException.getMessage().contains(TEST_MESSAGE));
96 throw new DOMRpcImplementationNotAvailableException(new Throwable(), TEST_MESSAGE, new Object());