Fix up release old producers to avoid memory leak
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / test / java / org / opendaylight / mdsal / dom / store / inmemory / InMemoryDOMDataTreeShardTest.java
index 181043d2af85b2bb2586f7e61249f5a3c8ff3d8c..28488bcba706f3c8901a95778b7b15fa6fc3dd35 100644 (file)
@@ -29,7 +29,6 @@ import org.junit.Test;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.dom.spi.shard.ReadableWriteableDOMDataTreeShard;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -48,9 +47,11 @@ public class InMemoryDOMDataTreeShardTest {
                 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
                         YangInstanceIdentifier.of(QName.create("", "Test")));
 
-        final ReadableWriteableDOMDataTreeShard domDataTreeShard = mock(ReadableWriteableDOMDataTreeShard.class);
+        final InMemoryDOMDataTreeShard domDataTreeShard = mock(InMemoryDOMDataTreeShard.class);
         doReturn("testReadableWriteableDOMDataTreeShard").when(domDataTreeShard).toString();
         doReturn(DOM_DATA_TREE_SHARD_PRODUCER).when(domDataTreeShard).createProducer(any());
+        doReturn(domDataTreeShard).when(DOM_DATA_TREE_SHARD_PRODUCER).getParentShard();
+        doNothing().when(DOM_DATA_TREE_SHARD_PRODUCER).close();
 
         assertFalse(inMemoryDOMDataTreeShard.getChildShards().containsValue(domDataTreeShard));
         inMemoryDOMDataTreeShard.onChildAttached(DOM_DATA_TREE_IDENTIFIER, domDataTreeShard);
@@ -63,7 +64,7 @@ public class InMemoryDOMDataTreeShardTest {
         final InMemoryDOMDataTreeShardProducer mockProducer = mock(InMemoryDOMDataTreeShardProducer.class);
         doReturn(prefixes).when(mockProducer).getPrefixes();
         doReturn(inMemoryDOMDataTreeShard.createModificationFactory(prefixes))
-            .when(mockProducer).getModificationFactory();
+                .when(mockProducer).getModificationFactory();
 
         inMemoryDOMDataTreeShard.onGlobalContextUpdated(createTestContext());
         inMemoryDOMDataTreeShard.createTransaction("", mockProducer, mock(CursorAwareDataTreeSnapshot.class));