X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FAbstractDataTreeChangeListenerTest.java;fp=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FAbstractDataTreeChangeListenerTest.java;h=0000000000000000000000000000000000000000;hb=2611e6a728e586ea34dd891f30a473bf54d6cbd8;hp=58db9d7dc30afc37ed7bfe86cd93629bf3ca10b1;hpb=aaea3e9a92ae9d6fac04c4a065db4b35cbca9ed0;p=controller.git diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java deleted file mode 100644 index 58db9d7dc3..0000000000 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataTreeChangeListenerTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import java.util.Collection; -import java.util.Map; -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.mdsal.binding.spec.reflect.BindingReflections; -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.util.concurrent.SpecialExecutors; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public abstract class AbstractDataTreeChangeListenerTest { - - protected static final YangInstanceIdentifier TOP_LEVEL = YangInstanceIdentifier - .of(Top.QNAME); - private static final QName NAME_QNAME = QName.create(Top.QNAME, "name"); - protected static final String FOO = "foo"; - protected static final String BAR = "bar"; - protected static final String BAZ = "baz"; - - private InMemoryDOMDataStore datastore; - private SchemaContext schemaContext; - private TestDCLExecutorService dclExecutorService; - - @Before - public final void setup() throws Exception { - final YangModuleInfo moduleInfo = BindingReflections - .getModuleInfo(TwoLevelList.class); - final ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); - context.registerModuleInfo(moduleInfo); - this.schemaContext = context.tryToCreateSchemaContext().get(); - - this.dclExecutorService = new TestDCLExecutorService( - SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL", - AbstractDataTreeChangeListenerTest.class)); - - this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService); - this.datastore.onGlobalContextUpdated(this.schemaContext); - } - - @After - public void tearDown() { - 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(this.datastore, this.dclExecutorService).cleanup(DatastoreTestTask - .simpleDelete(TOP_LEVEL)); - } - - - public static final YangInstanceIdentifier path(final String topName, - final String nestedName) { - return path(topName).node(NestedList.QNAME).node( - NodeIdentifierWithPredicates.of(NestedList.QNAME, NAME_QNAME, - nestedName)); - } - - public static final YangInstanceIdentifier path(final String topName) { - return TOP_LEVEL.node(TopLevelList.QNAME).node( - NodeIdentifierWithPredicates.of(TopLevelList.QNAME, - NAME_QNAME, topName)); - } - - protected static DataContainerNodeBuilder top() { - return Builders.containerBuilder().withNodeIdentifier( - new NodeIdentifier(Top.QNAME)); - } - - - - protected static void assertEmpty(final Collection set) { - Assert.assertTrue(set.isEmpty()); - } - - protected static void assertEmpty(final Map set) { - Assert.assertTrue(set.isEmpty()); - } - - protected static void assertContains(final Collection set, final K... values) { - for (final K key : values) { - Assert.assertTrue(set.contains(key)); - } - - } - - protected static void assertContains(final Map map, final K... values) { - for (final K key : values) { - Assert.assertTrue(map.containsKey(key)); - } - } - - protected static void assertNotContains(final Collection set, final K... values) { - for (final K key : values) { - Assert.assertFalse(set.contains(key)); - } - } - - protected static void assertNotContains(final Map map, final K... values) { - for (final K key : values) { - Assert.assertFalse(map.containsKey(key)); - } - } - - protected static CollectionNodeBuilder topLevelMap() { - return ImmutableNodes.mapNodeBuilder(TopLevelList.QNAME); - } - - protected static CollectionNodeBuilder nestedMap() { - return Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(NestedList.QNAME)); - } - - public static DataContainerNodeBuilder topLevelList( - final String key) { - return ImmutableNodes.mapEntryBuilder(TopLevelList.QNAME, NAME_QNAME, - key); - } - - public static DataContainerNodeBuilder nestedList( - final String key) { - return ImmutableNodes - .mapEntryBuilder(NestedList.QNAME, NAME_QNAME, key); - } - - public static final WriteTransactionCustomizer writeOneTopMultipleNested( - final String topName, final String... nestedName) { - final CollectionNodeBuilder nestedMapBuilder = nestedMap(); - for (final String nestedItem : nestedName) { - nestedMapBuilder.addChild(nestedList(nestedItem).build()); - } - - final ContainerNode data = top().addChild( - topLevelMap().addChild( - topLevelList(topName) - .addChild(nestedMapBuilder.build()).build()) - .build()).build(); - - return DatastoreTestTask.simpleWrite(TOP_LEVEL, data); - } - - public static final WriteTransactionCustomizer deleteNested(final String topName, - final String nestedName) { - return DatastoreTestTask.simpleDelete(path(topName, nestedName)); - } -}