* A registry of EventListeners, maintaining a set of registrations. This class is thread-safe.
*
* @param <T> Type of listeners this registry handles
+ * @deprecated Use {@link ObjectRegistry} instead
*/
+@Deprecated(since = "12.0.0", forRemoval = true)
public final class ListenerRegistry<T extends EventListener> implements Mutable {
private final Set<RegistrationImpl<? extends T>> listeners = ConcurrentHashMap.newKeySet();
private final String name;
import java.util.EventListener;
import org.junit.jupiter.api.Test;
+@Deprecated(since = "12.0.0", forRemoval = true)
class ListenerRegistryTest {
private final ExtendedTestEventListener extendedTestEventListener = new ExtendedTestEventListener() {};
private final ListenerRegistry<TestEventListener> registry = ListenerRegistry.create();
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.Test;
+
+class ObjectRegistryTest {
+ private final ObjectRegistry<TestEventListener> registry = ObjectRegistry.createSimple("testName");
+
+ @Test
+ void testCreateNewInstance() {
+ assertNotNull(registry, "Intance of listener registry should not be null.");
+ }
+
+ @Test
+ void testGetListenersMethod() {
+ assertEquals(0, registry.streamObjects().count(), "Listener registry should not have any listeners.");
+ }
+
+ @Test
+ void testRegisterMethod() {
+ final var extendedTestEventListener = new ExtendedTestEventListener() {
+ // Nothing else
+ };
+ final var listenerRegistration = registry.register(extendedTestEventListener);
+ assertEquals(extendedTestEventListener, listenerRegistration.getInstance(), "Listeners should be the same.");
+ }
+
+ interface TestEventListener {
+ // Nothing else
+ }
+
+ interface ExtendedTestEventListener extends TestEventListener {
+ // Nothing else
+ }
+}