*/
package org.opendaylight.controller.cluster.databroker;
-import java.lang.reflect.Field;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
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;
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);
@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);
@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);
@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);
@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
+}