X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FAbstractDataChangeListenerTest.java;h=3be301a32f5292a0e98f3d6d80dfb1bf518aab16;hp=76a9354d1aea79cde305b087a830687b75d91889;hb=db89afdefb3cfa4454dfdc6008e1d54d3ede66fb;hpb=5bcd1acc0d6407ff27365e3dce7810589eae2a2d diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java index 76a9354d1a..3be301a32f 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java @@ -13,11 +13,11 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; @@ -36,8 +36,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.util.concurrent.MoreExecutors; - public abstract class AbstractDataChangeListenerTest { protected static final YangInstanceIdentifier TOP_LEVEL = YangInstanceIdentifier @@ -53,29 +51,35 @@ public abstract class AbstractDataChangeListenerTest { @Before public final void setup() throws Exception { - YangModuleInfo moduleInfo = BindingReflections + final YangModuleInfo moduleInfo = BindingReflections .getModuleInfo(TwoLevelList.class); - ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); + final ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); context.registerModuleInfo(moduleInfo); - schemaContext = context.tryToCreateSchemaContext().get(); + this.schemaContext = context.tryToCreateSchemaContext().get(); - dclExecutorService = new TestDCLExecutorService( + this.dclExecutorService = new TestDCLExecutorService( SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL" )); - datastore = new InMemoryDOMDataStore("TEST", - MoreExecutors.sameThreadExecutor(), dclExecutorService ); - datastore.onGlobalContextUpdated(schemaContext); + this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService); + this.datastore.onGlobalContextUpdated(this.schemaContext); } @After public void tearDown() { - if( dclExecutorService != null ) { - dclExecutorService.shutdownNow(); + if( this.dclExecutorService != null ) { + this.dclExecutorService.shutdownNow(); } } + /** + * Create a new test task. The task will operate on the backed database, + * and will use the proper background executor service. + * + * @return Test task initialized to clean up {@value #TOP_LEVEL} and its + * children. + */ public final DatastoreTestTask newTestTask() { - return new DatastoreTestTask(datastore, dclExecutorService).cleanup(DatastoreTestTask + return new DatastoreTestTask(this.datastore, this.dclExecutorService).cleanup(DatastoreTestTask .simpleDelete(TOP_LEVEL)); } @@ -109,26 +113,26 @@ public abstract class AbstractDataChangeListenerTest { } protected static void assertContains(final Collection set, final K... values) { - for (K key : values) { + for (final K key : values) { Assert.assertTrue(set.contains(key)); } } protected static void assertNotContains(final Collection set, final K... values) { - for (K key : values) { + for (final K key : values) { Assert.assertFalse(set.contains(key)); } } protected static void assertContains(final Map map, final K... values) { - for (K key : values) { + for (final K key : values) { Assert.assertTrue(map.containsKey(key)); } } protected static void assertNotContains(final Map map, final K... values) { - for (K key : values) { + for (final K key : values) { Assert.assertFalse(map.containsKey(key)); } } @@ -155,8 +159,8 @@ public abstract class AbstractDataChangeListenerTest { public static final WriteTransactionCustomizer writeOneTopMultipleNested( final String topName, final String... nestedName) { - CollectionNodeBuilder nestedMapBuilder = nestedMap(); - for (String nestedItem : nestedName) { + final CollectionNodeBuilder nestedMapBuilder = nestedMap(); + for (final String nestedItem : nestedName) { nestedMapBuilder.addChild(nestedList(nestedItem).build()); }