Package org.osgi.service.cm

Examples of org.osgi.service.cm.Configuration


        assertEquals(1, ta.events.size());
    }

    @Test
    public void testOsgiAppenderRef() throws Exception {
        Configuration config = ca.getConfiguration(ITConfigAdminSupport.PID, null);
        Dictionary<String, Object> p = new Hashtable<String, Object>();
        p.put(ITConfigAdminSupport.LOG_LEVEL, "INFO");
        p.put(ITConfigAdminSupport.LOGBACK_FILE,absolutePath("test-osg-appender-ref-config.xml"));
        config.update(p);

        delay();

        Logger ref = (Logger)LoggerFactory.getLogger("foo.ref.osgi");
        assertTrue(ref.isDebugEnabled());
View Full Code Here


    }

    @Test
    public void testChangeLogLevelWithConfig() throws Exception {
        // Set log level to debug for foo1.bar
        Configuration config = ca.createFactoryConfiguration(FACTORY_PID_CONFIGS, null);
        Dictionary<String, Object> p = new Hashtable<String, Object>();
        p.put(LOG_LOGGERS, new String[] {
            "foo1.bar"
        });
        p.put(LOG_LEVEL, "DEBUG");
        config.update(p);

        delay();

        Logger slf4jLogger = LoggerFactory.getLogger("foo1.bar");
        assertTrue(slf4jLogger.isDebugEnabled());
View Full Code Here

    }

    @Test
    public void testChangeGlobalConfig() throws Exception {
        // Set log level to debug for Root logger
        Configuration config = ca.getConfiguration(PID, null);
        Dictionary<String, Object> p = new Hashtable<String, Object>();
        p.put(LOG_LEVEL, "DEBUG");
        config.update(p);

        delay();

        assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled());

        // Reset back to Info
        config = ca.getConfiguration(PID, null);
        p = new Hashtable<String, Object>();
        p.put(LOG_LEVEL, "INFO");
        config.update(p);

        delay();

        assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isInfoEnabled());
        assertFalse(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled());
View Full Code Here

    }

    @Test
    public void testPackagingDataConfig() throws Exception {
        // Set log level to debug for Root logger
        Configuration config = ca.getConfiguration(PID, null);
        Dictionary<String, Object> p = new Hashtable<String, Object>();
        p.put(LOG_PACKAGING_DATA, Boolean.FALSE);
        p.put(LOG_LEVEL, "INFO");
        config.update(p);

        delay();

        assertFalse(((LoggerContext)LoggerFactory.getILoggerFactory()).isPackagingDataEnabled());
    }
View Full Code Here

        assertFalse(((LoggerContext)LoggerFactory.getILoggerFactory()).isPackagingDataEnabled());
    }

    @Test
    public void testExternalConfig() throws Exception {
        Configuration config = ca.getConfiguration(PID, null);
        Dictionary<String, Object> p = new Hashtable<String, Object>();
        p.put(LOG_LEVEL, "DEBUG");
        p.put(LOGBACK_FILE,absolutePath("test1-external-config.xml"));
        config.update(p);

        delay();

        ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
        assertNotNull(rootLogger.getAppender("FILE"));
View Full Code Here

    }

    // test support

    protected int httpPort() throws IOException {
        final Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.web");
        return Integer.parseInt(configuration.getProperties().get("org.osgi.service.http.port").toString());
    }
View Full Code Here

                Map<String, Object> properties = entry.getValue();

                String configName = getConfigName(resourceName);
                properties.put(friendlyNameProperty, configName);

                Configuration configuration = getConfiguration(configName);

                if (configuration == null) {
                    configuration = configurationAdmin.createFactoryConfiguration(configFactory);
                }

                properties = filterBeforeSave(properties);
                configuration.update(toDictionary(properties));
            }

            for (String resourceName : deletedResources) {
                String configName = getConfigName(resourceName);
                Configuration configuration = getConfiguration(configName);
                if (configuration != null) {
                    configuration.delete();
                }
            }
        } catch (IOException e) {
            throw new PersistenceException("Resources cannot be commited", e);
        }
View Full Code Here

    @Override
    protected Map<String, Object> getResourceProperties(String resourceName) {

        String configName = getConfigName(resourceName);
        Configuration configuration = getConfiguration(configName);


        if (configuration == null) {
            return null;
        }

        if (!configFactory.equals(configuration.getFactoryPid())) {
            return null;
        }


        Map<String, Object> properties = toMap(configuration);
View Full Code Here

    @Test
    public void testEnableQueueProcessing() throws Exception {
        JobManager jobManager = mock(JobManager.class);
        ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
        Configuration config = mock(Configuration.class);
        when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
        BundleContext context = mock(BundleContext.class);
        JobHandlingReplicationQueueProvider jobHandlingReplicationQueueProvider = new JobHandlingReplicationQueueProvider(
                jobManager, context);
        String agentName = "dummy-agent";
View Full Code Here

    @Test
    public void testDisableQueueProcessing() throws Exception {
        JobManager jobManager = mock(JobManager.class);
        ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
        Configuration config = mock(Configuration.class);
        when(configAdmin.createFactoryConfiguration(QueueConfiguration.class.getName(), null)).thenReturn(config);
        BundleContext context = mock(BundleContext.class);
        JobHandlingReplicationQueueProvider jobHandlingReplicationQueueProvider = new JobHandlingReplicationQueueProvider(
                jobManager,  context);
        String agentName = "dummy-agent";
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.