X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Futil%2FInterfacesHelperTest.java;h=5656163cbef7a4ecfe2791cd1d52132db99ab9b0;hb=63129df122d3005453e60e8d79054d10d50ee348;hp=22ea528030931b5350cd79c0facc30d1c4ed73a5;hpb=213aae87ecaccb43f3d909e0455db43511ace381;p=controller.git diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java index 22ea528030..5656163cbe 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java @@ -8,45 +8,53 @@ package org.opendaylight.controller.config.manager.impl.util; import static org.junit.Assert.assertEquals; - +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import java.util.Collections; import java.util.HashSet; import java.util.Set; - import javax.management.MXBean; - import org.junit.Test; import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface; +import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation; import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingScheduledThreadPoolServiceInterface; import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface; import org.opendaylight.controller.config.spi.Module; import org.opendaylight.yangtools.concepts.Identifiable; -import com.google.common.collect.Sets; - public class InterfacesHelperTest { - interface SuperA { + public interface SuperA { } - interface SuperBMXBean { + public interface SuperBMXBean { } - interface SuperC extends SuperA, SuperBMXBean { + public interface SuperC extends SuperA, SuperBMXBean { } - class SuperClass implements SuperC { + public class SuperClass implements SuperC { } @MXBean - interface SubA { + public interface SubA { + + } + + @ServiceInterfaceAnnotation(value = "a", osgiRegistrationType = SuperA.class, namespace = "n", revision = "r", localName = "l") + public interface Service extends AbstractServiceInterface{} + @ServiceInterfaceAnnotation(value = "b", osgiRegistrationType = SuperC.class, namespace = "n", revision = "r", localName = "l") + public interface SubService extends Service{} + + public abstract class SubClass extends SuperClass implements SubA, Module { } - abstract class SubClass extends SuperClass implements SubA, Module { + public abstract class SubClassWithService implements SubService, Module { } @@ -58,6 +66,19 @@ public class InterfacesHelperTest { InterfacesHelper.getAllInterfaces(SubClass.class)); } + @Test + public void testGetServiceInterfaces() throws Exception { + assertEquals(Collections.>emptySet(), InterfacesHelper.getServiceInterfaces(SubClass.class)); + assertEquals(Sets.>newHashSet(Service.class, SubService.class), InterfacesHelper.getServiceInterfaces(SubClassWithService.class)); + } + + @Test + public void testGetOsgiRegistrationTypes() throws Exception { + assertEquals(Collections.>emptySet(), InterfacesHelper.getOsgiRegistrationTypes(SubClass.class)); + assertEquals(Sets.>newHashSet(SuperA.class, SuperC.class), + InterfacesHelper.getOsgiRegistrationTypes(SubClassWithService.class)); + } + @Test public void testGetMXInterfaces() { Set> expected = Sets.> newHashSet(SuperBMXBean.class, SubA.class); @@ -71,9 +92,9 @@ public class InterfacesHelperTest { input.add(clazz); Set> result = InterfacesHelper.getAllAbstractServiceInterfaceClasses(input); - Set> expected = Sets.newHashSet((Class) TestingScheduledThreadPoolServiceInterface.class, + Set> expected = ImmutableSet.of((Class) TestingScheduledThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class - ); + ); assertEquals(expected, result); }