package org.opendaylight.controller.md.sal.dom.store.impl;
import static org.junit.Assert.assertNotNull;
-
+import com.google.common.base.Throwables;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.ExecutionException;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.MoreExecutors;
-
public class SchemaUpdateForTransactionTest {
private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(Top.QNAME);
@Before
public void setupStore() {
- domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor(),
- MoreExecutors.sameThreadExecutor());
+ this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
loadSchemas(RockTheHouseInput.class);
}
public void loadSchemas(final Class<?>... classes) {
YangModuleInfo moduleInfo;
try {
- ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- for (Class<?> clz : classes) {
+ final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
+ for (final Class<?> clz : classes) {
moduleInfo = BindingReflections.getModuleInfo(clz);
context.registerModuleInfo(moduleInfo);
}
- schemaContext = context.tryToCreateSchemaContext().get();
- domStore.onGlobalContextUpdated(schemaContext);
- } catch (Exception e) {
+ this.schemaContext = context.tryToCreateSchemaContext().get();
+ this.domStore.onGlobalContextUpdated(this.schemaContext);
+ } catch (final Exception e) {
Throwables.propagateIfPossible(e);
}
}
@Test
public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
- assertNotNull(domStore);
+ assertNotNull(this.domStore);
// We allocate transaction, initial schema context does not
// contain Lists model
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+ final DOMStoreReadWriteTransaction writeTx = this.domStore.newReadWriteTransaction();
assertNotNull(writeTx);
// we trigger schema context update to contain Lists model