X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FBindingNormalizedCodecTest.java;h=567c1768978be59168fcb538dfc39e9c98cbb055;hb=1e50fbad8d8605b73d5b2be8f5ae30b437b33780;hp=aef168ddf0881a7d0ecb84d0c9eac497b0dc9aef;hpb=383553dbada5e4c3078133c81a42d05990031992;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java index aef168ddf0..567c176897 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingNormalizedCodecTest.java @@ -25,6 +25,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest; +import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; +import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService; @@ -34,8 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -70,47 +70,44 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { this.context = context; final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault())); final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(streamWriter); - codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry, true); + this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry, true); } @Test public void testComplexAugmentationSerialization() { - codec.onGlobalContextUpdated(context); - final PathArgument lastArg = codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument(); + this.codec.onGlobalContextUpdated(this.context); + final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument(); assertTrue(lastArg instanceof AugmentationIdentifier); } @Test public void testLeafOnlyAugmentationSerialization() { - codec.onGlobalContextUpdated(context); - final PathArgument leafOnlyLastArg = codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument(); + this.codec.onGlobalContextUpdated(this.context); + final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument(); assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier); assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME)); } @Test public void testToYangInstanceIdentifierBlocking() { - codec.onGlobalContextUpdated(new EmptySchemaContext()); + this.codec.onGlobalContextUpdated(new EmptySchemaContext()); final CountDownLatch done = new CountDownLatch(1); final AtomicReference yangId = new AtomicReference<>(); final AtomicReference error = new AtomicReference<>(); - new Thread() { - @Override - public void run() { - try { - yangId.set(codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST)); - } catch(RuntimeException e) { - error.set(e); - } finally { - done.countDown(); - } + new Thread(() -> { + try { + yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST)); + } catch(final RuntimeException e) { + error.set(e); + } finally { + done.countDown(); } - }.start(); + }).start(); Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - codec.onGlobalContextUpdated(context); + this.codec.onGlobalContextUpdated(this.context); assertEquals("toYangInstanceIdentifierBlocking completed", true, Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS)); @@ -128,7 +125,7 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { @Test public void testGetRpcMethodToSchemaPathBlocking() { - codec.onGlobalContextUpdated(new EmptySchemaContext()); + this.codec.onGlobalContextUpdated(new EmptySchemaContext()); testGetRpcMethodToSchemaPath(); } @@ -136,21 +133,18 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { final CountDownLatch done = new CountDownLatch(1); final AtomicReference> retMap = new AtomicReference<>(); final AtomicReference error = new AtomicReference<>(); - new Thread() { - @Override - public void run() { - try { - retMap.set(codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class)); - } catch(RuntimeException e) { - error.set(e); - } finally { - done.countDown(); - } + new Thread(() -> { + try { + retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class)); + } catch(final RuntimeException e) { + error.set(e); + } finally { + done.countDown(); } - }.start(); + }).start(); Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); - codec.onGlobalContextUpdated(context); + this.codec.onGlobalContextUpdated(this.context); assertEquals("getRpcMethodToSchemaPath completed", true, Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS)); @@ -158,7 +152,7 @@ public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest { throw error.get(); } - for(Method method: retMap.get().keySet()) { + for(final Method method: retMap.get().keySet()) { if(method.getName().equals("rockTheHouse")) { return; }