X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2Ftest%2FBackwardsCompatibleNotificationBrokerTest.java;h=394a465af5deb5807766410bcdb4d106e0e85d8c;hp=6a8dc5fde960400ea07aa68e44b0a23375d6df30;hb=3ec97cd0a86ad1b79f6854dc6924eb7b06e359a3;hpb=a8e01610a247900873b41c92d3299f6e9091de37 diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java index 6a8dc5fde9..394a465af5 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java @@ -10,16 +10,16 @@ package org.opendaylight.controller.md.sal.binding.impl.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter; - import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter; import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener; @@ -30,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.NotificationListener; +@Deprecated public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificationBrokerTest { private NotificationProviderService notificationProviderService; @@ -38,12 +39,13 @@ public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificat public void initTest() { final NotificationService notificationService = getNotificationService(); final NotificationPublishService notificationPublishService = getNotificationPublishService(); - notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, notificationService); + notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, + notificationService); } - private TwoLevelListChanged createTestData() { + private static TwoLevelListChanged createTestData() { final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder(); - tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build())); + tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build())); return tb.build(); } @@ -52,27 +54,34 @@ public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificat final CountDownLatch latch = new CountDownLatch(1); final TwoLevelListChanged testData = createTestData(); - final NotifTestListener testNotifListener = new NotifTestListener(latch); + final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch); final ListenerRegistration listenerRegistration = notificationProviderService.registerNotificationListener(testNotifListener); notificationProviderService.publish(testData); - latch.await(); + latch.await(500L, TimeUnit.MILLISECONDS); assertTrue(testNotifListener.getReceivedNotifications().size() == 1); assertEquals(testData, testNotifListener.getReceivedNotifications().get(0)); listenerRegistration.close(); } + private static class NotifTestListenerChild extends NotifTestListener { + + NotifTestListenerChild(final CountDownLatch latch) { + super(latch); + } + } + private static class NotifTestListener implements OpendaylightMdsalListTestListener { - private List receivedNotifications = new ArrayList<>(); - private CountDownLatch latch; + private final List receivedNotifications = new ArrayList<>(); + private final CountDownLatch latch; - public NotifTestListener(CountDownLatch latch) { + NotifTestListener(final CountDownLatch latch) { this.latch = latch; } @Override - public void onTwoLevelListChanged(TwoLevelListChanged notification) { + public void onTwoLevelListChanged(final TwoLevelListChanged notification) { receivedNotifications.add(notification); latch.countDown(); } @@ -81,5 +90,4 @@ public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificat return receivedNotifications; } } - }