Package org.jboss.as.configadmin.service

Examples of org.jboss.as.configadmin.service.ConfigAdminService


    @Test
    public void testConfigAdminService() throws Exception {

        // Verify that there is no config with this PID already
        ConfigAdminService configAdmin = getConfigAdminService();
        boolean hasconfig = configAdmin.hasConfiguration(ConfiguredService.SERVICE_PID);
        assertFalse("Config null", hasconfig);

        Dictionary<String, String> config = new Hashtable<String, String>();
        config.put("foo", "bar");

        // Register a new config for the given PID
        Dictionary<String, String> oldConfig = configAdmin.putConfiguration(ConfiguredService.SERVICE_PID, config);
        try {
            assertNull("Config null", oldConfig);

            // Verify the registered config
            Dictionary<String, String> regConfig = configAdmin.getConfiguration(ConfiguredService.SERVICE_PID);
            assertNotNull("Config not null", regConfig);
            assertEquals("Config not null", 1, regConfig.size());
            assertEquals("bar", regConfig.get("foo"));

            // Verify unmodifiable dictionary
            try {
                regConfig.remove("foo");
                fail("UnsupportedOperationException expected");
            } catch (UnsupportedOperationException ex) {
                // expected
            }

            // Verify unmodifiable dictionary
            config.put("foo", "baz");
            regConfig = configAdmin.getConfiguration(ConfiguredService.SERVICE_PID);
            assertEquals("bar", regConfig.get("foo"));

        } finally {
            oldConfig = configAdmin.removeConfiguration(ConfiguredService.SERVICE_PID);
            assertNotNull("Config not null", oldConfig);

            hasconfig = configAdmin.hasConfiguration(ConfiguredService.SERVICE_PID);
            assertFalse("Config null", hasconfig);
        }
    }
View Full Code Here


            @Override
            public Set<String> getPIDs() {
                return Collections.singleton(ConfiguredService.SERVICE_PID);
            }
        };
        ConfigAdminService configAdmin = getConfigAdminService();
        configAdmin.addListener(listener);

        latches[0].await();
        assertNull("First invocation with null", dictionaries[0]);

        Dictionary<String, String> config = new Hashtable<String, String>();
        config.put("foo", "bar");

        // Register a new config for the given PID
        configAdmin.putConfiguration(ConfiguredService.SERVICE_PID, config);
        try {
            latches[1].await();
            assertNotNull("Second invocation not null", dictionaries[1]);
        } finally {
            configAdmin.removeConfiguration(ConfiguredService.SERVICE_PID);
            configAdmin.removeListener(listener);
        }
    }
View Full Code Here

        Dictionary<String, String> config = new Hashtable<String, String>();
        config.put("foo", "bar");

        // Register a new config for the given PID
        ConfigAdminService configAdmin = getConfigAdminService();
        configAdmin.putConfiguration(ConfiguredService.SERVICE_PID, config);
        try {
            ConfiguredService.addService(serviceTarget);
            final CountDownLatch latch = new CountDownLatch(1);
            final ServiceController<ConfiguredService> controller = (ServiceController<ConfiguredService>) serviceContainer.getService(ConfiguredService.SERVICE_NAME);
            controller.addListener(new AbstractServiceListener<ConfiguredService>(){
                public void serviceStarted(ServiceController<? extends ConfiguredService> controller) {
                    controller.removeListener(this);
                    latch.countDown();
                }
            });
            latch.await(3, TimeUnit.SECONDS);
            ConfiguredService service = controller.getValue();
            assertEquals("bar", service.getConfigValue("foo"));
        } finally {
            configAdmin.removeConfiguration(ConfiguredService.SERVICE_PID);
            serviceContainer.getService(ConfiguredService.SERVICE_NAME).setMode(ServiceController.Mode.REMOVE);
        }
    }
View Full Code Here

    // [TODO] Move this to @Before when Arquillian supports injected values there
    private ConfigAdminService getConfigAdminService() {
        ServiceController<?> controller = serviceContainer.getService(ConfigAdminService.SERVICE_NAME);
        assertNotNull("ServiceController available: " + ConfigAdminService.SERVICE_NAME, controller);
        ConfigAdminService configAdmin = (ConfigAdminService) controller.getValue();
        assertNotNull("Service available: " + ConfigAdminService.SERVICE_NAME, configAdmin);
        return configAdmin;
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.configadmin.service.ConfigAdminService

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.