Search in sources :

Example 1 with ConfigRepository

use of org.apache.karaf.config.core.ConfigRepository in project karaf by apache.

the class UpdateCommandTest method testupdateRegularConfig.

public void testupdateRegularConfig() throws Exception {
    Dictionary<String, Object> props = new Hashtable<>();
    UpdateCommand command = new UpdateCommand();
    ConfigRepository configRepo = EasyMock.createMock(ConfigRepository.class);
    configRepo.update(EasyMock.eq(PID), EasyMock.eq(props));
    EasyMock.expectLastCall();
    command.setConfigRepository(configRepo);
    MockCommandSession session = createMockSessionForFactoryEdit(PID, false, props);
    command.setSession(session);
    replay(configRepo);
    command.execute();
    EasyMock.verify(configRepo);
}
Also used : Hashtable(java.util.Hashtable) ConfigRepository(org.apache.karaf.config.core.ConfigRepository)

Example 2 with ConfigRepository

use of org.apache.karaf.config.core.ConfigRepository in project karaf by apache.

the class UpdateCommandTest method testupdateOnNewFactoryPid.

public void testupdateOnNewFactoryPid() throws Exception {
    Dictionary<String, Object> props = new Hashtable<>();
    UpdateCommand command = new UpdateCommand();
    ConfigRepository configRepo = EasyMock.createMock(ConfigRepository.class);
    expect(configRepo.createFactoryConfiguration(EasyMock.eq(FACTORY_PID), EasyMock.eq(null), EasyMock.eq(props))).andReturn(PID + ".35326647");
    command.setConfigRepository(configRepo);
    MockCommandSession session = createMockSessionForFactoryEdit(FACTORY_PID, true, props);
    command.setSession(session);
    replay(configRepo);
    command.execute();
    EasyMock.verify(configRepo);
}
Also used : Hashtable(java.util.Hashtable) ConfigRepository(org.apache.karaf.config.core.ConfigRepository)

Example 3 with ConfigRepository

use of org.apache.karaf.config.core.ConfigRepository in project karaf by apache.

the class Activator method doStart.

protected void doStart() throws Exception {
    ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
    if (configurationAdmin == null) {
        return;
    }
    ConfigRepository configRepository = new ConfigRepositoryImpl(configurationAdmin, new File(System.getProperty("karaf.etc")));
    register(ConfigRepository.class, configRepository);
    ConfigMBeanImpl configMBean = new ConfigMBeanImpl();
    configMBean.setConfigRepo(configRepository);
    registerMBean(configMBean, "type=config");
}
Also used : ConfigRepository(org.apache.karaf.config.core.ConfigRepository) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) File(java.io.File) ConfigRepositoryImpl(org.apache.karaf.config.core.impl.ConfigRepositoryImpl) ConfigMBeanImpl(org.apache.karaf.config.core.impl.ConfigMBeanImpl)

Aggregations

ConfigRepository (org.apache.karaf.config.core.ConfigRepository)3 Hashtable (java.util.Hashtable)2 File (java.io.File)1 ConfigMBeanImpl (org.apache.karaf.config.core.impl.ConfigMBeanImpl)1 ConfigRepositoryImpl (org.apache.karaf.config.core.impl.ConfigRepositoryImpl)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1