org.osgi.service.cm.ConfigurationException Java Examples

The following examples show how to use org.osgi.service.cm.ConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileInventoryServiceFactory.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
    String path = (String) properties.get("path");

    LOG.info("Updating route for PID=" + pid + " with new path=" + path);
    
    // need to remove old route before updating
    deleted(pid);

    // now we create a new route with update path
    FileInventoryRoute newRoute = new FileInventoryRoute();
    newRoute.setInputPath(path);
    newRoute.setRouteId("file-" + pid);
    
    // finally we add the route
    try {
        camelContext.addRoutes(newRoute);
    } catch (Exception e) {
        LOG.error("Failed to add route", e);
    }
    routes.put(pid, newRoute);
}
 
Example #2
Source File: ManagedWorkQueueList.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void updated(String pid, Dictionary<String, ?> props)
    throws ConfigurationException {
    if (pid == null) {
        return;
    }
    Dictionary<String, String> properties = CastUtils.cast(props);
    String queueName = properties.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
    if (queues.containsKey(queueName)) {
        queues.get(queueName).update(properties);
    } else {
        AutomaticWorkQueueImpl wq = new AutomaticWorkQueueImpl(queueName);
        wq.setShared(true);
        wq.update(properties);
        wq.addChangeListener(this);
        queues.put(pid, wq);
    }
}
 
Example #3
Source File: LoggingConfigurationOSGiTest.java    From carbon-kernel with Apache License 2.0 6 votes vote down vote up
@Test
public void testLog4j2ConfigUpdate() throws IOException, ConfigurationException {
    Logger logger = LoggerFactory.getLogger(LoggingConfigurationOSGiTest.class);
    Assert.assertNotNull(managedService, "Managed Service is null");

    //default log level is "ERROR"
    Assert.assertEquals(logger.isErrorEnabled(), true);
    Assert.assertEquals(logger.isDebugEnabled(), false);

    Dictionary<String, Object> properties = new Hashtable<>();
    String log4jConfigFilePath = Paths.get(loggingConfigDirectory, LOG4J2_CONFIG_FILE).toString();
    properties.put(LOG4J2_CONFIG_FILE_KEY, log4jConfigFilePath);
    managedService.updated(properties);

    //updated log level is "DEBUG"
    Assert.assertEquals(logger.isDebugEnabled(), true);
}
 
Example #4
Source File: LoggingConfigurationOSGiTest.java    From carbon-kernel with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testLog4j2ConfigUpdate")
public void testAuditLog() throws IOException, ConfigurationException {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getCurrentContext();
    Principal principal = () -> "Banda";
    carbonContext.setUserPrincipal(principal);

    Logger audit = Constants.AUDIT_LOG;
    audit.info("Attempting to test the audit logs.");

    Path auditLog = Paths.get(System.getProperty("wso2.runtime.path"), "logs", "audit.log");

    Assert.assertTrue(Files.exists(auditLog), "audit.log does not exist.");
    try (Stream<String> stream = Files.lines(auditLog)) {
        Optional<String> match = stream.filter(line -> line.contains("user-name=Banda")).findAny();
        Assert.assertTrue(match.isPresent(), "user-name=Banda is not found in the audit.log");
    }
}
 
Example #5
Source File: HttpServer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void updated()
    throws ConfigurationException
{

  try {
    httpSocketListener.updated();
    httpsSocketListener.updated();
    doHttpReg();
  } catch (final ConfigurationException e) {
    // If configuration failed, make sure we don't have
    // any registered service
    if (httpReg != null) {
      httpReg.unregister();
      httpReg = null;
    }
    // and rethrow the exception
    throw e;
  }
}
 
Example #6
Source File: LogConfigImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void checkTimestampPattern(final Dictionary<String, ?> cfg)
    throws ConfigurationException, IllegalArgumentException {
  final Object obj = cfg.get(TIMESTAMP_PATTERN);
  try {
    final String pattern = (String) obj;
    try {
      new SimpleDateFormat(pattern);
    } catch (final Throwable t) {
      throw new ConfigurationException(TIMESTAMP_PATTERN,
                                       "Invalid timestamp pattern: '"
                                       +pattern +"' "+t.getMessage());
    }
  } catch (final ClassCastException cce) {
    throw new IllegalArgumentException(
        "Wrong type supplied when attempting to set timestamp pattern."
            + " Correct type to use is String. " + obj + " "
            + obj.getClass().getName());
  }
}
 
Example #7
Source File: LogConfigImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void checkLogLevel(Dictionary<String, Object> cfg)
    throws ConfigurationException, IllegalArgumentException {
  String filter = null;
  final Object obj = cfg.get(L_FILTER);
  if (obj == null) {
    throw new IllegalArgumentException(
        "No log level given. Please supply a valid log level.");
  }
  try {
    filter = ((String) obj).trim();
  } catch (final ClassCastException cce) {
    throw new IllegalArgumentException(
        "Wrong type supplied when attempting to set log level."
            + " Correct type to use is String. " + obj + " "
            + obj.getClass().getName());
  }
  final int filterVal = LogUtil.toLevel(filter, -1);
  if (filterVal == -1) {
    throw new ConfigurationException(L_FILTER, "Undefined log level <"
        + filter + ">.");
  }
  if (filterVal == 0) {
    cfg.put(L_FILTER, LogUtil.fromLevel(LOG_WARNING));
  }
}
 
Example #8
Source File: TelnetServer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void start(BundleContext bc)
{
  TelnetServer.bc = bc;

  log = new LogRef(bc, true);

  telnetSessions = new Hashtable<TelnetSession, Thread>();

  final Dictionary<String, String> conf = new Hashtable<String, String>();
  try {
    telnetConfig = new TelnetConfig(bc);
    conf.put(Constants.SERVICE_PID, getClass().getName());

    configServReg =
      bc.registerService(ManagedService.class, this, conf);
  } catch (final ConfigurationException cexp) {
    log.error("Consoletelnet configuration error " + cexp.toString());
  }

  telnetServerThread = new Thread(this, "ConsoleTelnetServer");
  telnetServerThread.setDaemon(true);
  telnetServerThread.start();
}
 
Example #9
Source File: BrokerHandlerTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Utility method for tests that need the handler to be initialized to go on.
 *
 * @return Return true if successful. You usually want to use:
 *         assertThat(initializeHandlerWaitForTimeout(), is(true));
 * @throws InterruptedException
 * @throws IllegalArgumentException
 * @throws MqttException
 * @throws ConfigurationException
 */
boolean initializeHandlerWaitForTimeout()
        throws InterruptedException, IllegalArgumentException, MqttException, ConfigurationException {

    MqttBrokerConnection c = connection;

    MqttConnectionObserverEx o = new MqttConnectionObserverEx();
    c.addConnectionObserver(o);

    assertThat(connection.connectionState(), is(MqttConnectionState.DISCONNECTED));
    handler.initialize();
    verify(connection, times(2)).addConnectionObserver(any());
    verify(connection, times(1)).start();
    boolean s = o.semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
    // First we expect a CONNECTING state and then a CONNECTED unique state change
    assertThat(o.counter, is(2));
    // First we expect a CONNECTING state and then a CONNECTED state change
    // (and other CONNECTED after the future completes)
    verify(handler, times(3)).connectionStateChanged(any(), any());
    return s;
}
 
Example #10
Source File: MqttBrokerConnectionTests.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void subscribeBeforeOnlineThenConnect() throws ConfigurationException, MqttException, InterruptedException,
        ExecutionException, TimeoutException, org.eclipse.paho.client.mqttv3.MqttException {
    MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("123.123.123.123", null, false,
            "MqttBrokerConnectionTests");

    // Add a subscriber while still offline
    MqttMessageSubscriber subscriber = mock(MqttMessageSubscriber.class);
    connection.subscribe("homie/device123/$name", subscriber);

    assertTrue(connection.start().get(200, TimeUnit.MILLISECONDS));
    assertTrue(connection.hasSubscribers());
    assertThat(connection.connectionState(), is(MqttConnectionState.CONNECTED));

    // Test if subscription is active
    connection.clientCallback.messageArrived("homie/device123/$name", new MqttMessage("hello".getBytes()));
    verify(subscriber).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
}
 
Example #11
Source File: MqttBrokerConnectionTests.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void subscribeToWildcardTopic() throws ConfigurationException, MqttException, InterruptedException,
        ExecutionException, TimeoutException, org.eclipse.paho.client.mqttv3.MqttException {
    MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("123.123.123.123", null, false,
            "MqttBrokerConnectionTests");

    // Add a subscriber while still offline
    MqttMessageSubscriber subscriber = mock(MqttMessageSubscriber.class);
    connection.subscribe("homie/device123/+", subscriber);

    MqttMessageSubscriber subscriber2 = mock(MqttMessageSubscriber.class);
    connection.subscribe("#", subscriber2);

    MqttMessageSubscriber subscriber3 = mock(MqttMessageSubscriber.class);
    connection.subscribe("homie/#", subscriber3);

    assertTrue(connection.start().get(200, TimeUnit.MILLISECONDS));
    assertTrue(connection.hasSubscribers());
    assertThat(connection.connectionState(), is(MqttConnectionState.CONNECTED));

    connection.clientCallback.messageArrived("homie/device123/$name", new MqttMessage("hello".getBytes()));

    verify(subscriber).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
    verify(subscriber2).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
    verify(subscriber3).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
}
 
Example #12
Source File: MqttBrokerConnectionTests.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void timeoutWhenNotReachableFuture()
        throws ConfigurationException, MqttException, InterruptedException, ExecutionException, TimeoutException {
    MqttBrokerConnectionEx connection = spy(
            new MqttBrokerConnectionEx("10.0.10.10", null, false, "MqttBrokerConnectionTests"));
    connection.setConnectionCallback(connection);

    ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(1);
    connection.setTimeoutExecutor(s, 10);
    assertThat(connection.timeoutExecutor, is(s));

    // Adjust test conditions
    connection.connectTimeout = true;

    CompletableFuture<Boolean> future = connection.start();
    verify(connection.connectionCallback).createFuture();
    verify(connection.connectionCallback, times(0)).onConnected(any());
    verify(connection.connectionCallback, times(0)).onDisconnected(any(MqttClientDisconnectedContext.class));
    assertNotNull(connection.timeoutFuture);

    assertThat(future.get(70, TimeUnit.MILLISECONDS), is(false));
}
 
Example #13
Source File: EmailAlerter.java    From karaf-decanter with Apache License 2.0 6 votes vote down vote up
protected void activate(Dictionary<String, Object> config) throws ConfigurationException {
    from = (config.get("from") != null) ? config.get("from").toString() : null;
    to = (config.get("to") != null) ? config.get("to").toString() : null;
    subjectTemplate = (config.get("subject.template") != null) ? config.get("subject.template").toString() : null;
    bodyTemplate = (config.get("body.template") != null) ? config.get("body.template").toString() : null;
    bodyType = (config.get("body.type") != null) ? config.get("body.type").toString() : "text/plain";
    cc = (config.get("cc") != null) ? config.get("cc").toString() : null;
    bcc = (config.get("bcc")  != null) ? config.get("bcc").toString() : null;

    properties = new Properties();
    properties.put("mail.smtp.host", config.get("host"));
    properties.put("mail.smtp.port", config.get("port"));
    properties.put("mail.smtp.auth", config.get("auth"));
    properties.put("mail.smtp.starttls.enable", config.get("starttls"));
    properties.put("mail.smtp.ssl.enable", config.get("ssl"));
    String username = (String) config.get("username");
    String password = (String) config.get("password");
    if (username != null) {
        properties.put("mail.smtp.user", username);
    }
    if (password != null) {
        properties.put("mail.smtp.password", password);
    }

    formatter = new EmailFormatter();
}
 
Example #14
Source File: AbstractBrokerHandlerTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void brokerAdded() throws ConfigurationException, MqttException {
    MqttBrokerConnectionEx connection = spy(
            new MqttBrokerConnectionEx("10.10.0.10", 80, false, "BrokerHandlerTest"));
    doReturn(connection).when(service).getBrokerConnection(eq(handler.brokerID));

    verify(callback, times(0)).statusUpdated(any(), any());
    handler.brokerAdded(handler.brokerID, connection);

    assertThat(handler.connection, is(connection));

    verify(connection).start();

    // First connecting then connected and another connected after the future completes
    verify(callback, times(3)).statusUpdated(any(), any());
}
 
Example #15
Source File: MqttBrokerConnectionTests.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void timeoutWhenNotReachableFuture()
        throws ConfigurationException, MqttException, InterruptedException, ExecutionException, TimeoutException {
    MqttBrokerConnectionEx connection = spy(
            new MqttBrokerConnectionEx("10.0.10.10", null, false, "MqttBrokerConnectionTests"));
    connection.setConnectionCallback(connection);

    ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(1);
    connection.setTimeoutExecutor(s, 10);
    assertThat(connection.timeoutExecutor, is(s));

    // Adjust test conditions
    connection.connectTimeout = true;

    CompletableFuture<Boolean> future = connection.start();
    verify(connection.connectionCallback).createFuture();
    verify(connection.connectionCallback, times(0)).onSuccess(any());
    verify(connection.connectionCallback, times(0)).onFailure(any(), any());
    assertNotNull(connection.timeoutFuture);

    assertThat(future.get(70, TimeUnit.MILLISECONDS), is(false));
}
 
Example #16
Source File: DecanterTailerListener.java    From karaf-decanter with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Activate
public void activate(ComponentContext context) throws ConfigurationException {
    properties = context.getProperties();
    if (properties.get("type") == null) {
        throw new ConfigurationException("type", "type property is mandatory");
    }
    String type = (String) properties.get("type");
    if (properties.get("path") == null) {
        throw new ConfigurationException("path", "path property is mandatory");
    }
    String path = (String) properties.get("path");

    LOGGER.debug("Starting tail on {}", path);
    tailer = new Tailer(new File(path), this, 1000, true, true);
    Thread thread = new Thread(tailer, "File tailer for " + path);
    this.type = type;
    this.path = path;
    this.regex = (String) properties.get("regex");
    thread.start();
    if (regex != null) {
        compiledRegex  = Pattern.compile(regex);
    }
}
 
Example #17
Source File: MqttBrokerConnectionTests.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void subscribeBeforeOnlineThenConnect()
        throws ConfigurationException, MqttException, InterruptedException, ExecutionException, TimeoutException {
    MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("123.123.123.123", null, false,
            "MqttBrokerConnectionTests");

    // Add a subscriber while still offline
    MqttMessageSubscriber subscriber = mock(MqttMessageSubscriber.class);
    connection.subscribe("homie/device123/$name", subscriber);

    assertTrue(connection.start().get(200, TimeUnit.MILLISECONDS));
    assertTrue(connection.hasSubscribers());
    assertThat(connection.connectionState(), is(MqttConnectionState.CONNECTED));

    Mqtt3Publish publishMessage = Mqtt3Publish.builder().topic("homie/device123/$name").payload("hello".getBytes())
            .build();
    // Test if subscription is active
    connection.getSubscribers().get("homie/device123/$name").messageArrived(publishMessage);
    verify(subscriber).processMessage(eq("homie/device123/$name"), eq("hello".getBytes()));
}
 
Example #18
Source File: Update.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void doUpdate(PluginManager pm)
    throws ConfigurationException
{
  if (sr == null) {
    return;
  }
  Object targetService = getTargetService();
  if (targetService == null) {
    return;
  }
  processedConfiguration = pm.callPluginsAndCreateACopy(sr, configuration);
  if (factoryPid == null) {
    update((ManagedService) targetService);
  } else {
    update((ManagedServiceFactory) targetService);
  }
}
 
Example #19
Source File: CustomTrustManagerFactory.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Deprecated
public CustomTrustManagerFactory(SSLContextProvider contextProvider) {
    TrustManager[] tm;
    try {
        SSLContext ctx = contextProvider.getContext();

        // get SSLContextImpl
        Field contextSpiField = ctx.getClass().getDeclaredField("contextSpi");
        contextSpiField.setAccessible(true);
        Object sslContextImpl = contextSpiField.get(ctx);
        Class<?> sslContextImplClass = sslContextImpl.getClass().getSuperclass().getSuperclass();

        // get trustmanager
        Field trustManagerField = sslContextImplClass.getDeclaredField("trustManager");
        trustManagerField.setAccessible(true);
        Object trustManagerObj = trustManagerField.get(sslContextImpl);

        tm = new TrustManager[] { (X509TrustManager) trustManagerObj };
    } catch (IllegalAccessException | NoSuchFieldException | ConfigurationException e) {
        logger.warn("using default insecure trustmanager, could not extract trustmanager from SSL context:", e);
        tm = InsecureTrustManagerFactory.INSTANCE.getTrustManagers();
    }
    trustManagers = tm;
}
 
Example #20
Source File: MQTTTopicDiscoveryServiceTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws ConfigurationException, MqttException {
    scheduler = new ScheduledThreadPoolExecutor(1);
    MockitoAnnotations.initMocks(this);

    when(thing.getUID()).thenReturn(MqttThingID.getThingUID("10.10.0.10", 80));
    connection = spy(new MqttBrokerConnectionEx("10.10.0.10", 80, false, "BrokerHandlerTest"));
    connection.setTimeoutExecutor(scheduler, 10);
    connection.setConnectionCallback(connection);

    Configuration config = new Configuration();
    config.put("host", "10.10.0.10");
    config.put("port", 80);
    when(thing.getConfiguration()).thenReturn(config);

    handler = spy(new BrokerHandlerEx(thing, connection));
    handler.setCallback(callback);

    subject = new MqttBrokerHandlerFactory();
}
 
Example #21
Source File: UpdateQueue.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void run()
{
  while (true) {
    Update update = dequeue();
    if (update == null) {
      return;
    }
    try {
      update.doUpdate(pm);
    } catch (ConfigurationException ce) {
      Activator.log
          .error("[CM] Error in configuration for " + update.pid, ce);
    } catch (Throwable t) {
      Activator.log.error("[CM] Error while updating " + update.pid, t);
    }
  }
}
 
Example #22
Source File: MqttBrokerConnectionTests.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void lastWillAndTestamentTests() throws ConfigurationException {
    MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("123.123.123.123", null, false,
            "lastWillAndTestamentTests");

    assertNull(connection.getLastWill());
    assertNull(MqttWillAndTestament.fromString(""));
    connection.setLastWill(MqttWillAndTestament.fromString("topic:message:1:true"));
    assertTrue(connection.getLastWill().getTopic().equals("topic"));
    assertEquals(1, connection.getLastWill().getQos());
    assertEquals(true, connection.getLastWill().isRetain());
    byte b[] = { 'm', 'e', 's', 's', 'a', 'g', 'e' };
    assertTrue(Arrays.equals(connection.getLastWill().getPayload(), b));
}
 
Example #23
Source File: PinningSSLContextProvider.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public SSLContext getContext() throws ConfigurationException {
    try {
        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
        sslContext.init(null, new TrustManager[] { trustManager }, new java.security.SecureRandom());
        return sslContext;
    } catch (KeyManagementException | NoSuchAlgorithmException e) {
        logger.warn("SSL configuration failed", e);
        throw new ConfigurationException("ssl", e.getMessage());
    }
}
 
Example #24
Source File: MqttServiceTests.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void brokerConnectionListenerTests() throws ConfigurationException {
    MqttService service = new MqttServiceImpl();
    assertFalse(service.hasBrokerObservers());
    MqttServiceObserver observer = mock(MqttServiceObserver.class);

    service.addBrokersListener(observer);
    assertTrue(service.hasBrokerObservers());

    MqttBrokerConnectionEx connection = new MqttBrokerConnectionEx("tcp://123.123.123.123", null, false,
            "brokerConnectionListenerTests");
    assertTrue(service.addBrokerConnection("name", connection));

    ArgumentCaptor<MqttBrokerConnection> argumentCaptorConn = ArgumentCaptor.forClass(MqttBrokerConnection.class);
    ArgumentCaptor<String> argumentCaptorConnName = ArgumentCaptor.forClass(String.class);

    verify(observer).brokerAdded(argumentCaptorConnName.capture(), argumentCaptorConn.capture());
    assertThat(argumentCaptorConnName.getValue(), equalTo("name"));
    assertThat(argumentCaptorConn.getValue(), equalTo(connection));

    service.removeBrokerConnection("name");
    verify(observer).brokerRemoved(argumentCaptorConnName.capture(), argumentCaptorConn.capture());
    assertThat(argumentCaptorConnName.getValue(), equalTo("name"));
    assertThat(argumentCaptorConn.getValue(), equalTo(connection));

    service.removeBrokersListener(observer);
    assertFalse(service.hasBrokerObservers());
}
 
Example #25
Source File: BrokerHandlerTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void handlerInit()
        throws InterruptedException, IllegalArgumentException, MqttException, ConfigurationException {

    assertThat(initializeHandlerWaitForTimeout(), is(true));

    ArgumentCaptor<ThingStatusInfo> statusInfoCaptor = ArgumentCaptor.forClass(ThingStatusInfo.class);
    verify(callback, atLeast(3)).statusUpdated(eq(thing), statusInfoCaptor.capture());
    Assert.assertThat(statusInfoCaptor.getValue().getStatus(), is(ThingStatus.ONLINE));
}
 
Example #26
Source File: AbstractBrokerHandlerTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void brokerAddedWrongID() throws ConfigurationException, MqttException {
    MqttBrokerConnection brokerConnection = mock(MqttBrokerConnection.class);
    when(brokerConnection.connectionState()).thenReturn(MqttConnectionState.CONNECTED);
    handler.brokerAdded("nonsense_id", brokerConnection);
    assertNull(handler.connection);
    // We do not expect a status change, because brokerAdded will do nothing with invalid connections.
    verify(callback, times(0)).statusUpdated(any(), any());
}
 
Example #27
Source File: ConfigManagerService.java    From g-suite-identity-sync with Apache License 2.0 5 votes vote down vote up
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
    if (properties != null) {
        LOG.info("LDAP Configuration changed");
        configurables.stream().forEach(c -> c.reconfigure());
    }
}
 
Example #28
Source File: CamelAppender.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
public void open(Dictionary<String, Object> config) throws ConfigurationException {
    this.config = config;
    if (config.get(DESTINATION_URI_KEY) == null) {
        throw new ConfigurationException(DESTINATION_URI_KEY, DESTINATION_URI_KEY + " is not defined");
    }
    LOGGER.debug("Creating CamelContext, and use the {} URI", config.get(DESTINATION_URI_KEY));
    this.camelContext = new DefaultCamelContext();
}
 
Example #29
Source File: AbstractBrokerHandlerTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void brokerRemovedBroker() throws ConfigurationException, MqttException {
    MqttBrokerConnectionEx connection = spy(
            new MqttBrokerConnectionEx("10.10.0.10", 80, false, "BrokerHandlerTest"));
    handler.brokerAdded(handler.brokerID, connection);
    assertThat(handler.connection, is(connection));
    handler.brokerRemoved("something", connection);
    assertNull(handler.connection);
}
 
Example #30
Source File: CamelAlerter.java    From karaf-decanter with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Activate
public void activate(ComponentContext context) throws ConfigurationException {
    Dictionary<String, Object> config = context.getProperties();
    this.alertDestinationUri = (String) config.get("alert.destination.uri");
    if (alertDestinationUri == null) {
        throw new ConfigurationException("alert.destination.uri", "alert.destination.uri property is not defined");
    }
    this.camelContext = new DefaultCamelContext();
}