import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import org.junit.Test;
-import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
public class InMemoryDOMDataStoreFactoryTest {
@Test
- public void createTest() throws Exception {
+ public void basicTest() throws Exception {
final String testStoreName = "TestStore";
- final DOMSchemaService domSchemaService = Mockito.mock(DOMSchemaService.class);
- Mockito.doReturn(null).when(domSchemaService).registerSchemaContextListener(any(SchemaContextListener.class));
+ final DOMSchemaService domSchemaService = mock(DOMSchemaService.class);
+ doReturn(null).when(domSchemaService).registerSchemaContextListener(any(SchemaContextListener.class));
final InMemoryDOMDataStore inMemoryDOMDataStore =
InMemoryDOMDataStoreFactory.create(testStoreName, domSchemaService);
assertNotNull(inMemoryDOMDataStore);
assertEquals(testStoreName, inMemoryDOMDataStore.getIdentifier());
+
+ final DOMDataTreeChangeListener domDataTreeChangeListener = mock(DOMDataTreeChangeListener.class);
+ doReturn("testListener").when(domDataTreeChangeListener).toString();
+ doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any());
+ inMemoryDOMDataStore.onGlobalContextUpdated(TestModel.createTestContext());
+ inMemoryDOMDataStore.registerTreeChangeListener(YangInstanceIdentifier.EMPTY, domDataTreeChangeListener);
+
+ final AutoCloseable autoCloseable = mock(AutoCloseable.class);
+ doNothing().when(autoCloseable).close();
+ inMemoryDOMDataStore.setCloseable(autoCloseable);
+ inMemoryDOMDataStore.close();
+ verify(autoCloseable).close();
}
}
\ No newline at end of file