2 * Copyright (c) 2013 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.controller.config.manager.impl.util;
10 import static org.junit.Assert.assertEquals;
12 import java.util.HashSet;
15 import javax.management.MXBean;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
19 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingScheduledThreadPoolServiceInterface;
20 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
21 import org.opendaylight.controller.config.spi.Module;
22 import org.opendaylight.yangtools.concepts.Identifiable;
24 import com.google.common.collect.Sets;
26 public class InterfacesHelperTest {
32 interface SuperBMXBean {
36 interface SuperC extends SuperA, SuperBMXBean {
40 class SuperClass implements SuperC {
49 abstract class SubClass extends SuperClass implements SubA, Module {
54 public void testGetAllInterfaces() {
55 Set<Class<?>> expected = Sets.<Class<?>> newHashSet(SuperA.class, SuperBMXBean.class, SuperC.class,
56 SubA.class, Identifiable.class, Module.class);
57 assertEquals(expected,
58 InterfacesHelper.getAllInterfaces(SubClass.class));
62 public void testGetMXInterfaces() {
63 Set<Class<?>> expected = Sets.<Class<?>> newHashSet(SuperBMXBean.class, SubA.class);
64 assertEquals(expected, InterfacesHelper.getMXInterfaces(SubClass.class));
68 public void testGetAllAbstractServiceInterfaceClasses(){
69 Class<? extends AbstractServiceInterface> clazz = TestingScheduledThreadPoolServiceInterface.class;
70 Set<Class<? extends AbstractServiceInterface>> input = new HashSet<>();
72 Set<Class<? extends AbstractServiceInterface>> result = InterfacesHelper.getAllAbstractServiceInterfaceClasses(input);
74 Set<Class<?>> expected = Sets.newHashSet((Class<?>) TestingScheduledThreadPoolServiceInterface.class,
75 TestingThreadPoolServiceInterface.class
77 assertEquals(expected, result);