@Test(expected = IllegalStateException.class)
 public void testNoDomainProviderAvailableForType_shouldThrowIllegalArgumentException()
     throws Exception {
   DefaultOsgiUtilsService defaultOsgiUtilsService = new DefaultOsgiUtilsService();
   defaultOsgiUtilsService.setBundleContext(bundleContextMock);
   ConnectorRegistrationManagerImpl connectorRegistrationManagerImpl =
       new ConnectorRegistrationManagerImpl();
   connectorRegistrationManagerImpl.setBundleContext(bundleContextMock);
   connectorRegistrationManagerImpl.setServiceUtils(defaultOsgiUtilsService);
   ConnectorInstanceFactory connectorInstanceFactoryMock = mock(ConnectorInstanceFactory.class);
   Dictionary<String, Object> props = new Hashtable<String, Object>();
   props.put("connector", "a");
   props.put("domain", "a");
   registerService(connectorInstanceFactoryMock, props, ConnectorInstanceFactory.class);
   DomainProvider domainProviderMock = mock(DomainProvider.class);
   when(domainProviderMock.getDomainInterface())
       .thenAnswer(
           new Answer<Class<? extends Domain>>() {
             @Override
             public Class<? extends Domain> answer(InvocationOnMock invocation) throws Throwable {
               return NullDomainImpl.class;
             }
           });
   Dictionary<String, Object> propsDomainProvider = new Hashtable<String, Object>();
   propsDomainProvider.put("domain", "a");
   registerService(domainProviderMock, propsDomainProvider, DomainProvider.class);
   ConnectorId connectorId = new ConnectorId("a", "a", "a");
   connectorRegistrationManagerImpl.updateRegistration(
       connectorId,
       new ConnectorDescription(new HashMap<String, String>(), new HashMap<String, Object>()));
 }
 @Test
 public void testRegisterConnectorWithSameNameAfterRemoved_shouldNotFail() throws Exception {
   DefaultOsgiUtilsService defaultOsgiUtilsService = new DefaultOsgiUtilsService();
   defaultOsgiUtilsService.setBundleContext(bundleContextMock);
   ConnectorRegistrationManagerImpl connectorRegistrationManagerImpl =
       new ConnectorRegistrationManagerImpl();
   connectorRegistrationManagerImpl.setBundleContext(bundleContextMock);
   connectorRegistrationManagerImpl.setServiceUtils(defaultOsgiUtilsService);
   ConnectorInstanceFactory connectorInstanceFactoryMock = mock(ConnectorInstanceFactory.class);
   Connector connectorMock = mock(Connector.class);
   when(connectorInstanceFactoryMock.createNewInstance(anyString())).thenReturn(connectorMock);
   Dictionary<String, Object> props = new Hashtable<String, Object>();
   props.put("connector", "a");
   props.put("domain", "a");
   registerService(connectorInstanceFactoryMock, props, ConnectorInstanceFactory.class);
   DomainProvider domainProviderMock = mock(DomainProvider.class);
   when(domainProviderMock.getDomainInterface())
       .thenAnswer(
           new Answer<Class<? extends Domain>>() {
             @Override
             public Class<? extends Domain> answer(InvocationOnMock invocation) throws Throwable {
               return NullDomainImpl.class;
             }
           });
   Dictionary<String, Object> propsDomainProvider = new Hashtable<String, Object>();
   propsDomainProvider.put("domain", "a");
   registerService(domainProviderMock, propsDomainProvider, DomainProvider.class);
   ConnectorId connectorId = new ConnectorId("a", "a", "a");
   connectorRegistrationManagerImpl.updateRegistration(
       connectorId,
       new ConnectorDescription(new HashMap<String, String>(), new HashMap<String, Object>()));
   connectorRegistrationManagerImpl.remove(connectorId);
   connectorRegistrationManagerImpl.updateRegistration(
       new ConnectorId("a", "a", "a"),
       new ConnectorDescription(new HashMap<String, String>(), new HashMap<String, Object>()));
 }
コード例 #3
0
ファイル: Activator.java プロジェクト: rolandbair/openengsb
 @Override
 public void start(BundleContext context) throws Exception {
   DefaultOsgiUtilsService osgiServiceUtils = new DefaultOsgiUtilsService();
   osgiServiceUtils.setBundleContext(context);
   OpenEngSBCoreServices.setOsgiServiceUtils(osgiServiceUtils);
 }