BUG 1606 - A read is attempted on a WRITE_ONLY transaction
[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 org.junit.Assert;
14 import org.junit.Test;
15 import org.mockito.Mockito;
16 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
18 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
19 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22
23 public class TransactionChainProxyTest {
24     ActorContext actorContext = Mockito.mock(ActorContext.class);
25     SchemaContext schemaContext = Mockito.mock(SchemaContext.class);
26     @Test
27     public void testNewReadOnlyTransaction() throws Exception {
28
29      DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newReadOnlyTransaction();
30          Assert.assertTrue(dst instanceof DOMStoreReadTransaction);
31
32     }
33
34     @Test
35     public void testNewReadWriteTransaction() throws Exception {
36         DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newReadWriteTransaction();
37         Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
38
39     }
40
41     @Test
42     public void testNewWriteOnlyTransaction() throws Exception {
43         DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newWriteOnlyTransaction();
44         Assert.assertTrue(dst instanceof DOMStoreWriteTransaction);
45
46     }
47
48     @Test(expected=UnsupportedOperationException.class)
49     public void testClose() throws Exception {
50         new TransactionChainProxy(actorContext, schemaContext).close();
51     }
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.