BUG 1606 - A read is attempted on a WRITE_ONLY transaction 01/10201/1
authorBasheeruddin Ahmed <syedbahm@cisco.com>
Sat, 23 Aug 2014 02:03:02 +0000 (19:03 -0700)
committerBasheeruddin Ahmed <syedbahm@cisco.com>
Sat, 23 Aug 2014 02:03:02 +0000 (19:03 -0700)
Change-Id: I896d976ff387ecdc9ecfe6e4cb2ead75b15c15f5
Signed-off-by: Basheeruddin Ahmed <syedbahm@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java [new file with mode: 0644]

index c4ec760b40cd57d54579144f010b5e0f7425363e..76bbef713c350ad975c9dbb256bdef83bd1e4915 100644 (file)
@@ -36,13 +36,13 @@ public class TransactionChainProxy implements DOMStoreTransactionChain{
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
         return new TransactionProxy(actorContext,
-            TransactionProxy.TransactionType.WRITE_ONLY, schemaContext);
+            TransactionProxy.TransactionType.READ_WRITE, schemaContext);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
         return new TransactionProxy(actorContext,
-            TransactionProxy.TransactionType.READ_WRITE, schemaContext);
+            TransactionProxy.TransactionType.WRITE_ONLY, schemaContext);
     }
 
     @Override
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java
new file mode 100644 (file)
index 0000000..9b70397
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *
+ *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ *  This program and the accompanying materials are made available under the
+ *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ *  and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+
+package org.opendaylight.controller.cluster.datastore;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
+import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class TransactionChainProxyTest {
+    ActorContext actorContext = Mockito.mock(ActorContext.class);
+    SchemaContext schemaContext = Mockito.mock(SchemaContext.class);
+    @Test
+    public void testNewReadOnlyTransaction() throws Exception {
+
+     DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newReadOnlyTransaction();
+         Assert.assertTrue(dst instanceof DOMStoreReadTransaction);
+
+    }
+
+    @Test
+    public void testNewReadWriteTransaction() throws Exception {
+        DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newReadWriteTransaction();
+        Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
+
+    }
+
+    @Test
+    public void testNewWriteOnlyTransaction() throws Exception {
+        DOMStoreTransaction dst = new TransactionChainProxy(actorContext, schemaContext).newWriteOnlyTransaction();
+        Assert.assertTrue(dst instanceof DOMStoreWriteTransaction);
+
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testClose() throws Exception {
+        new TransactionChainProxy(actorContext, schemaContext).close();
+    }
+}