X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2FClientBackedDataStoreTest.java;h=d7d774d699b3d791d59fd8d17b3d484e90feaa6d;hp=24a58759673f134b6c24f0f020a7f2f0a09caa2d;hb=c11dae56ca449d754db98fb8de194594c84d1f24;hpb=28e9832cc97a345d5ceb69262784e5c8fef77e37 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java index 24a5875967..d7d774d699 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.cluster.databroker; -import java.lang.reflect.Field; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -20,7 +19,6 @@ import org.opendaylight.controller.cluster.access.concepts.FrontendType; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientHandle; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction; @@ -69,13 +67,8 @@ public class ClientBackedDataStoreTest { Mockito.when(actorContext.getSchemaContext()).thenReturn(schemaContext); Mockito.when(actorContext.getDatastoreContext()).thenReturn(DatastoreContext.newBuilder().build()); - - final Field transactionIdField = AbstractClientHandle.class.getDeclaredField("transactionId"); - transactionIdField.setAccessible(true); - - // set transaction ids to mocked objects - transactionIdField.set(clientTransaction, TRANSACTION_IDENTIFIER); - transactionIdField.set(clientSnapshot, TRANSACTION_IDENTIFIER); + Mockito.when(clientTransaction.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER); + Mockito.when(clientSnapshot.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER); Mockito.when(clientActor.getIdentifier()).thenReturn(CLIENT_IDENTIFIER); Mockito.when(clientActor.createTransaction()).thenReturn(clientTransaction); @@ -85,7 +78,7 @@ public class ClientBackedDataStoreTest { @Test public void testCreateTransactionChain() throws Exception { - try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( + try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( actorContext, UNKNOWN_ID, clientActor)) { final DOMStoreTransactionChain txChain = clientBackedDataStore.createTransactionChain(); Assert.assertNotNull(txChain); @@ -95,7 +88,7 @@ public class ClientBackedDataStoreTest { @Test public void testNewReadOnlyTransaction() throws Exception { - try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( + try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( actorContext, UNKNOWN_ID, clientActor)) { final DOMStoreReadTransaction tx = clientBackedDataStore.newReadOnlyTransaction(); Assert.assertNotNull(tx); @@ -105,7 +98,7 @@ public class ClientBackedDataStoreTest { @Test public void testNewWriteOnlyTransaction() throws Exception { - try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( + try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( actorContext, UNKNOWN_ID, clientActor)) { final DOMStoreWriteTransaction tx = clientBackedDataStore.newWriteOnlyTransaction(); Assert.assertNotNull(tx); @@ -115,11 +108,11 @@ public class ClientBackedDataStoreTest { @Test public void testNewReadWriteTransaction() throws Exception { - try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( + try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( actorContext, UNKNOWN_ID, clientActor)) { final DOMStoreReadWriteTransaction tx = clientBackedDataStore.newReadWriteTransaction(); Assert.assertNotNull(tx); Mockito.verify(clientActor, Mockito.times(1)).createTransaction(); } } -} \ No newline at end of file +}