@Test public void shouldRecogniseAsApplicationContextService() { ServiceReference serviceReference = mock(ServiceReference.class); when(serviceReference.getBundle()).thenReturn(new MockBundle("mock-bundle")); when(serviceReference.getProperty(ApplicationContextServiceReferenceUtils.SERVICE_NAME)).thenReturn("mock-bundle"); when(serviceReference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[]{"abcd", ApplicationContext.class.getName(), "xyz"}); assertTrue(ApplicationContextServiceReferenceUtils.isValid(serviceReference)); }
public static boolean isValid(ServiceReference serviceReference) { String[] objectClasses = (String[]) serviceReference.getProperty(Constants.OBJECTCLASS); if (objectClasses.length == 0) { return false; } if (!asList(objectClasses).contains(ApplicationContext.class.getName())) { return false; } String serviceName = (String) serviceReference.getProperty(SERVICE_NAME); return nullSafeSymbolicName(serviceReference.getBundle()).equals(serviceName); }
ApplicationContextServiceReferenceUtils { public static boolean isValid(ServiceReference serviceReference) { String[] objectClasses = (String[]) serviceReference.getProperty(Constants.OBJECTCLASS); if (objectClasses.length == 0) { return false; } if (!asList(objectClasses).contains(ApplicationContext.class.getName())) { return false; } String serviceName = (String) serviceReference.getProperty(SERVICE_NAME); return nullSafeSymbolicName(serviceReference.getBundle()).equals(serviceName); } }
ApplicationContextServiceReferenceUtils { public static boolean isValid(ServiceReference serviceReference) { String[] objectClasses = (String[]) serviceReference.getProperty(Constants.OBJECTCLASS); if (objectClasses.length == 0) { return false; } if (!asList(objectClasses).contains(ApplicationContext.class.getName())) { return false; } String serviceName = (String) serviceReference.getProperty(SERVICE_NAME); return nullSafeSymbolicName(serviceReference.getBundle()).equals(serviceName); } private  ApplicationContextServiceReferenceUtils(); }
ApplicationContextServiceReferenceUtils { public static boolean isValid(ServiceReference serviceReference) { String[] objectClasses = (String[]) serviceReference.getProperty(Constants.OBJECTCLASS); if (objectClasses.length == 0) { return false; } if (!asList(objectClasses).contains(ApplicationContext.class.getName())) { return false; } String serviceName = (String) serviceReference.getProperty(SERVICE_NAME); return nullSafeSymbolicName(serviceReference.getBundle()).equals(serviceName); } private  ApplicationContextServiceReferenceUtils(); static boolean isValid(ServiceReference serviceReference); static boolean isNotValid(ServiceReference serviceReference); }
ApplicationContextServiceReferenceUtils { public static boolean isValid(ServiceReference serviceReference) { String[] objectClasses = (String[]) serviceReference.getProperty(Constants.OBJECTCLASS); if (objectClasses.length == 0) { return false; } if (!asList(objectClasses).contains(ApplicationContext.class.getName())) { return false; } String serviceName = (String) serviceReference.getProperty(SERVICE_NAME); return nullSafeSymbolicName(serviceReference.getBundle()).equals(serviceName); } private  ApplicationContextServiceReferenceUtils(); static boolean isValid(ServiceReference serviceReference); static boolean isNotValid(ServiceReference serviceReference); static final String SERVICE_NAME; }