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 java.util.EventListener;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 public class ListenerRegistryTest {
19 private ExtendedTestEventListener extendedTestEventListener;
20 private ListenerRegistry<TestEventListener> registry;
24 extendedTestEventListener = new ExtendedTestEventListener() {};
25 registry = ListenerRegistry.create();
29 public void testCreateNewInstance() {
30 assertNotNull("Intance of listener registry should not be null.", registry);
34 public void testGetListenersMethod() {
35 assertEquals("Listener registry should not have any listeners.", 0, registry.streamListeners().count());
39 public void testRegisterMethod() {
40 final ListenerRegistration<ExtendedTestEventListener> listenerRegistration = registry.register(
41 extendedTestEventListener);
42 assertEquals("Listeners should be the same.", extendedTestEventListener, listenerRegistration.getInstance());
45 interface TestEventListener extends EventListener {
49 interface ExtendedTestEventListener extends TestEventListener {