Merge "Hotfix for resolving of remote yang schemas."
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / TransactionChainProxyTest.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  *  This program and the accompanying materials are made available under the
6  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  */
10
11 package org.opendaylight.controller.cluster.datastore;
12
13 import static org.mockito.Mockito.doReturn;
14
15 import org.junit.Assert;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mockito;
19 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
21 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
22 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
23 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25
26 public class TransactionChainProxyTest {
27     ActorContext actorContext = Mockito.mock(ActorContext.class);
28     SchemaContext schemaContext = Mockito.mock(SchemaContext.class);
29
30     @Before
31     public void setUp() {
32         doReturn(schemaContext).when(actorContext).getSchemaContext();
33     }
34
35     @SuppressWarnings("resource")
36     @Test
37     public void testNewReadOnlyTransaction() throws Exception {
38
39      DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadOnlyTransaction();
40          Assert.assertTrue(dst instanceof DOMStoreReadTransaction);
41
42     }
43
44     @SuppressWarnings("resource")
45     @Test
46     public void testNewReadWriteTransaction() throws Exception {
47         DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadWriteTransaction();
48         Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
49
50     }
51
52     @SuppressWarnings("resource")
53     @Test
54     public void testNewWriteOnlyTransaction() throws Exception {
55         DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newWriteOnlyTransaction();
56         Assert.assertTrue(dst instanceof DOMStoreWriteTransaction);
57
58     }
59
60     @Test(expected=UnsupportedOperationException.class)
61     public void testClose() throws Exception {
62         new TransactionChainProxy(actorContext).close();
63     }
64 }