X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fconnect%2Fdom%2FDOMRpcServiceTestBugfix560.java;h=81171349d739d75cf4f1e12e5317618896565fa9;hp=1e93c59434c64ac291774fa34bd6fce7b798e4ac;hb=12fcdfe39aa26dcba7fd3bb4d4c68e3d02e65c51;hpb=2727bea09c83646b6cbd2ef9672d0b7f6cf3b22f diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java index 1e93c59434..81171349d7 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java @@ -10,44 +10,46 @@ package org.opendaylight.controller.sal.binding.test.connect.dom; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + +import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; -import java.util.Set; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.md.sal.binding.api.MountPoint; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; -import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance; -import org.opendaylight.controller.sal.binding.api.mount.MountProviderService; +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseOutput; 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.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.TopLevelListKey; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; +import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; +import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; +import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; /** * Test case for reported bug 560 @@ -71,7 +73,7 @@ public class DOMRpcServiceTestBugfix560 { private BindingTestContext testContext; private DOMMountPointService domMountPointService; - private MountProviderService bindingMountPointService; + private MountPointService bindingMountPointService; private SchemaContext schemaContext; /** @@ -80,25 +82,22 @@ public class DOMRpcServiceTestBugfix560 { @Before public void setUp() throws Exception { final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory(); - testFactory.setExecutor(MoreExecutors.sameThreadExecutor()); + testFactory.setExecutor(MoreExecutors.newDirectExecutorService()); testFactory.setStartWithParsedSchema(true); testContext = testFactory.getTestContext(); testContext.start(); domMountPointService = testContext.getDomMountProviderService(); - bindingMountPointService = testContext.getBindingMountProviderService(); + bindingMountPointService = testContext.getBindingMountPointService(); assertNotNull(domMountPointService); - final YangContextParser parser = new YangParserImpl(); - final InputStream moduleStream = BindingReflections.getModuleInfo( - OpendaylightTestRpcServiceService.class) - .getModuleSourceStream(); + final YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class); + assertNotNull(moduleInfo); - assertNotNull(moduleStream); - final List rpcModels = Collections.singletonList(moduleStream); - final Set modules = parser.parseYangModelsFromStreams(rpcModels); - final SchemaContext mountSchemaContext = parser.resolveSchemaContext(modules); - schemaContext = mountSchemaContext; + schemaContext = YangParserTestUtils.parseYangSources(StatementParserMode.DEFAULT_MODE, null, + YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create( + moduleInfo.getName().getLocalName(), moduleInfo.getName().getRevision()), + moduleInfo.getYangTextByteSource())); } private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier( @@ -107,19 +106,18 @@ public class DOMRpcServiceTestBugfix560 { .builder().node(Top.QNAME) .node(TopLevelList.QNAME) .nodeWithKey(TopLevelList.QNAME, TLL_NAME_QNAME, mount) - .toInstance(); + .build(); } private static InstanceIdentifier createBATllIdentifier( final String mount) { return InstanceIdentifier.builder(Top.class) - .child(TopLevelList.class, new TopLevelListKey(mount)).toInstance(); + .child(TopLevelList.class, new TopLevelListKey(mount)).build(); } @Test public void test() throws ExecutionException, InterruptedException { - // FIXME: This is made to only make sure instance identifier codec - // for path is instantiated. + // FIXME: This is made to only make sure instance identifier codec for path is instantiated. domMountPointService .createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() { @@ -135,15 +133,18 @@ public class DOMRpcServiceTestBugfix560 { return Futures.immediateCheckedFuture(result); } }).register(); - final MountProviderInstance mountInstance = bindingMountPointService - .getMountPoint(BA_MOUNT_ID); - assertNotNull(mountInstance); - final OpendaylightTestRpcServiceService rpcService = mountInstance + + final Optional mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID); + assertTrue(mountInstance.isPresent()); + + final Optional rpcRegistry = mountInstance.get().getService(RpcConsumerRegistry.class); + assertTrue(rpcRegistry.isPresent()); + final OpendaylightTestRpcServiceService rpcService = rpcRegistry.get() .getRpcService(OpendaylightTestRpcServiceService.class); assertNotNull(rpcService); try { - final Future> result = rpcService + final ListenableFuture> result = rpcService .rockTheHouse(new RockTheHouseInputBuilder().build()); assertTrue(result.get().isSuccessful()); } catch (final IllegalStateException ex) { @@ -155,7 +156,7 @@ public class DOMRpcServiceTestBugfix560 { * @throws java.lang.Exception */ @After - public void teardown() throws Exception { + public void teardown() { testContext.close(); } }