@Activate
    public void activate(ComponentContext context) {
        active = true;
        componentConfigService.registerProperties(getClass());
        providerService = providerRegistry.register(this);
        coreService.registerApplication(APP_NAME);
        cfgService.registerConfigFactory(factory);
        cfgService.addListener(cfgListener);
        controller.addDeviceListener(innerNodeListener);
        deviceService.addListener(deviceListener);
        scheduledTask = schedulePolling();
        scheduledReconnectionTask = scheduleConnectDevices();
        modified(context);
        log.info("Started");
    }
@Test
    public void activate() throws Exception {
        assertTrue("Provider should be registered", deviceRegistry.getProviders().contains(provider.id()));
        assertEquals("Incorrect device service", deviceService, provider.deviceService);
        assertEquals("Incorrect provider service", providerService, provider.providerService);
        assertTrue("Incorrect config factories", cfgFactories.contains(provider.factory));
        assertNotNull("Device listener should be added", deviceService.listener);
        assertFalse("Thread to connect device should be running",
                    provider.connectionExecutor.isShutdown() || provider.connectionExecutor.isTerminated());
        assertFalse("Scheduled task to update device should be running", provider.scheduledTask.isCancelled());
    }