X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmodification%2FAbstractModificationTest.java;h=5d7d842298e419fe13d94198b9b751d080944b69;hb=4b59df006c79ffb8119152e5a8bc6aadd276c031;hp=efaca5d4f6f3d583aec500b683909b8c28d245b8;hpb=f78020d87663c8d9db1e4e33939f7b8b703703f8;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java index efaca5d4f6..5d7d842298 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java @@ -5,40 +5,53 @@ * 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.cluster.datastore.modification; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import java.util.Optional; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; +import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; public abstract class AbstractModificationTest { + private static EffectiveModelContext TEST_SCHEMA_CONTEXT; + + protected InMemoryDOMDataStore store; + + @BeforeClass + public static void beforeClass() { + TEST_SCHEMA_CONTEXT = TestModel.createTestContext(); + } + + @AfterClass + public static void afterClass() { + TEST_SCHEMA_CONTEXT = null; + } + + @Before + public void setUp() { + store = new InMemoryDOMDataStore("test", MoreExecutors.newDirectExecutorService()); + store.onModelContextUpdated(TEST_SCHEMA_CONTEXT); + } + + protected void commitTransaction(final DOMStoreWriteTransaction transaction) { + DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); + cohort.preCommit(); + cohort.commit(); + } - protected InMemoryDOMDataStore store; - - @Before - public void setUp(){ - store = new InMemoryDOMDataStore("test", MoreExecutors.sameThreadExecutor()); - store.onGlobalContextUpdated(TestModel.createTestContext()); - } - - protected void commitTransaction(DOMStoreWriteTransaction transaction){ - DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); - cohort.preCommit(); - cohort.commit(); - } - - protected Optional> readData(InstanceIdentifier path) throws Exception{ - DOMStoreReadTransaction transaction = store.newReadOnlyTransaction(); - ListenableFuture>> future = transaction.read(path); - return future.get(); - } + protected Optional> readData(final YangInstanceIdentifier path) throws Exception { + DOMStoreReadTransaction transaction = store.newReadOnlyTransaction(); + ListenableFuture>> future = transaction.read(path); + return future.get(); + } }