package org.opendaylight.controller.md.sal.binding.compat;
import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
private NotificationInvoker(final NotificationListener listener) {
delegate = listener;
final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
- for(final Class<?> iface : listener.getClass().getInterfaces()) {
+ for(final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
+ Class<?> iface = ifaceToken.getRawType();
if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked")
final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
package org.opendaylight.controller.md.sal.binding.impl;
import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
- for(final Class<?> iface : implClz.getInterfaces()) {
+ for(final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
+ Class<?> iface = ifaceToken.getRawType();
if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked")
final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
import com.google.common.collect.ImmutableList;
final CountDownLatch latch = new CountDownLatch(1);
final TwoLevelListChanged testData = createTestData();
- final NotifTestListener testNotifListener = new NotifTestListener(latch);
+ final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch);
final ListenerRegistration<NotificationListener> 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 {
+
+ public NotifTestListenerChild(final CountDownLatch latch) {
+ super(latch);
+ }
+ }
private static class NotifTestListener implements OpendaylightMdsalListTestListener {
private List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
private CountDownLatch latch;