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=cce41da2d72df1fb5625667fa0c5af8e330752ef;hp=4b10353caab032c4b1a5569af4c475e6b26ffd2e;hb=aaea3e9a92ae9d6fac04c4a065db4b35cbca9ed0;hpb=20a32e6459fd1e27e7669bf1ebc7742b96787b94 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 4b10353caa..cce41da2d7 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 @@ -12,14 +12,11 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.common.base.Optional; -import com.google.common.io.ByteSource; 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.IOException; -import java.io.InputStream; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -34,17 +31,17 @@ import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; 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.YangModuleInfo; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -55,7 +52,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; /** - * Test case for reported bug 560 + * Test case for reported bug 560. * * @author Lukas Sedlak * @see BA_MOUNT_ID = createBATllIdentifier(TLL_NAME); - private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID = createBITllIdentifier(TLL_NAME); + private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID = + createBITllIdentifier(TLL_NAME); private BindingTestContext testContext; private DOMMountPointService domMountPointService; private MountPointService bindingMountPointService; private SchemaContext schemaContext; - /** - * @throws java.lang.Exception - */ @Before public void setUp() throws Exception { final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory(); @@ -98,14 +93,9 @@ public class DOMRpcServiceTestBugfix560 { assertNotNull(moduleInfo); schemaContext = YangParserTestUtils.parseYangSources(StatementParserMode.DEFAULT_MODE, null, - YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create(moduleInfo.getName(), - Revision.ofNullable(moduleInfo.getRevision())), new ByteSource() { - - @Override - public InputStream openStream() throws IOException { - return moduleInfo.getModuleSourceStream(); - } - })); + YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create( + moduleInfo.getName().getLocalName(), moduleInfo.getName().getRevision()), + moduleInfo.getYangTextByteSource())); } private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier( @@ -126,21 +116,19 @@ public class DOMRpcServiceTestBugfix560 { @Test public void test() throws ExecutionException, InterruptedException { // 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() { - - @Override - public ListenerRegistration registerRpcListener(final T arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public CheckedFuture invokeRpc(final SchemaPath arg0, final NormalizedNode arg1) { - final DOMRpcResult result = new DefaultDOMRpcResult((NormalizedNode) null); - return Futures.immediateCheckedFuture(result); - } - }).register(); + domMountPointService.createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() { + @Override + public ListenerRegistration registerRpcListener(final T arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public CheckedFuture invokeRpc(final SchemaPath arg0, + final NormalizedNode arg1) { + return Futures.immediateCheckedFuture(new DefaultDOMRpcResult((NormalizedNode) null)); + } + }).register(); final Optional mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID); assertTrue(mountInstance.isPresent()); @@ -152,7 +140,7 @@ public class DOMRpcServiceTestBugfix560 { assertNotNull(rpcService); try { - final Future> result = rpcService + final ListenableFuture> result = rpcService .rockTheHouse(new RockTheHouseInputBuilder().build()); assertTrue(result.get().isSuccessful()); } catch (final IllegalStateException ex) { @@ -160,11 +148,8 @@ public class DOMRpcServiceTestBugfix560 { } } - /** - * @throws java.lang.Exception - */ @After - public void teardown() throws Exception { + public void teardown() { testContext.close(); } }