2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.util;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import com.google.common.collect.ImmutableSet;
14 import java.util.EventListener;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
19 public class ListenerRegistryTest {
20 private TestEventListener testEventListener;
21 private ExtendedTestEventListener extendedTestEventListener;
22 private ListenerRegistry<TestEventListener> registry;
26 testEventListener = new TestEventListener() {};
27 extendedTestEventListener = new ExtendedTestEventListener() {};
28 registry = ListenerRegistry.create();
32 public void testCreateNewInstance() {
33 assertNotNull("Intance of listener registry should not be null.", registry);
37 public void tetGetListenersMethod() {
38 assertEquals("Listener registry should have any listeners.", ImmutableSet.of(), registry.getRegistrations());
42 public void testRegisterMethod() {
43 final ListenerRegistration<ExtendedTestEventListener> listenerRegistration = registry.register(
44 extendedTestEventListener);
45 assertEquals("Listeners should be the same.", extendedTestEventListener, listenerRegistration.getInstance());
48 interface TestEventListener extends EventListener {
52 interface ExtendedTestEventListener extends TestEventListener {