3 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
11 package org.opendaylight.controller.cluster.datastore;
13 import static org.mockito.Mockito.doReturn;
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;
26 public class TransactionChainProxyTest {
27 ActorContext actorContext = Mockito.mock(ActorContext.class);
28 SchemaContext schemaContext = Mockito.mock(SchemaContext.class);
32 doReturn(schemaContext).when(actorContext).getSchemaContext();
35 @SuppressWarnings("resource")
37 public void testNewReadOnlyTransaction() throws Exception {
39 DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadOnlyTransaction();
40 Assert.assertTrue(dst instanceof DOMStoreReadTransaction);
44 @SuppressWarnings("resource")
46 public void testNewReadWriteTransaction() throws Exception {
47 DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newReadWriteTransaction();
48 Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
52 @SuppressWarnings("resource")
54 public void testNewWriteOnlyTransaction() throws Exception {
55 DOMStoreTransaction dst = new TransactionChainProxy(actorContext).newWriteOnlyTransaction();
56 Assert.assertTrue(dst instanceof DOMStoreWriteTransaction);
60 @Test(expected=UnsupportedOperationException.class)
61 public void testClose() throws Exception {
62 new TransactionChainProxy(actorContext).close();