Examples of KernelServices


Examples of org.jboss.as.subsystem.test.KernelServices

    }

    @Test
    public void testSubsystemWithThreadAttributeChange() throws Exception {
        final int port = 12345;
        KernelServices services = installInController(new AdditionalInitialization(){
                @Override
                protected void setupController(ControllerInitializer controllerInitializer) {
                    controllerInitializer.addSocketBinding("test", port);
                }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices


    @Test
    public void testSubsystemWithConnectorPropertyChange() throws Exception {
        final int port = 12345;
        KernelServices services = installInController(new AdditionalInitialization(){
                @Override
                protected void setupController(ControllerInitializer controllerInitializer) {
                    controllerInitializer.addSocketBinding("test", port);
                }

                @Override
                protected void addExtraServices(ServiceTarget target) {
                    //Needed for initialization of the RealmAuthenticationProviderService
                    AbsolutePathService.addService(ServerEnvironment.CONTROLLER_TEMP_DIR, new File("target/temp" + System.currentTimeMillis()).getAbsolutePath(), target);
                }
            },readResource("remoting-with-threads.xml"));

        CurrentConnectorAndController current = CurrentConnectorAndController.create(services, RemotingServices.SUBSYSTEM_ENDPOINT, RemotingServices.serverServiceName("test-connector"));

        //Test that write property reloads the connector
        ModelNode write = new ModelNode();
        write.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
        write.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
        write.get(OP_ADDR).add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME).add(CommonAttributes.CONNECTOR, "test-connector").add(CommonAttributes.PROPERTY, "org.xnio.Options.WORKER_ACCEPT_THREADS");
        write.get(NAME).set(VALUE);
        write.get(VALUE).set(2);
        ModelNode result = services.executeOperation(write);
        assertFalse(result.get(FAILURE_DESCRIPTION).toString(), result.hasDefined(FAILURE_DESCRIPTION));
        assertEquals(2, services.readWholeModel().get(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME, CommonAttributes.CONNECTOR, "test-connector", CommonAttributes.PROPERTY, "org.xnio.Options.WORKER_ACCEPT_THREADS").require(VALUE).asInt());
        current.updateCurrentEndpoint(true);
        current.updateCurrentConnector(false);

        //remove property
        ModelNode remove = write.clone();
        remove.get(OP).set(REMOVE);
        remove.remove(NAME);
        remove.remove(VALUE);
        result = services.executeOperation(remove);
        assertFalse(result.get(FAILURE_DESCRIPTION).toString(), result.hasDefined(FAILURE_DESCRIPTION));
        assertFalse(services.readWholeModel().get(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME, CommonAttributes.CONNECTOR, "test-connector", CommonAttributes.PROPERTY, "org.xnio.Options.WORKER_ACCEPT_THREADS").isDefined());
        current.updateCurrentEndpoint(true);
        current.updateCurrentConnector(false);

        //TODO property
        ModelNode add = remove.clone();
        add.get(OP).set(ADD);
        add.get(VALUE).set(1);
        result = services.executeOperation(add);
        assertFalse(result.get(FAILURE_DESCRIPTION).toString(), result.hasDefined(FAILURE_DESCRIPTION));
        assertEquals(1, services.readWholeModel().get(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME, CommonAttributes.CONNECTOR, "test-connector", CommonAttributes.PROPERTY, "org.xnio.Options.WORKER_ACCEPT_THREADS").require(VALUE).asInt());
        current.updateCurrentEndpoint(true);
        current.updateCurrentConnector(false);
    }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    }

    @Test @Ignore("AS7-3632")
    public void testSubsystemWithBadConnectorProperty() throws Exception {
        final int port = 12345;
        KernelServices services = installInController(new AdditionalInitialization(){
                @Override
                protected void setupController(ControllerInitializer controllerInitializer) {
                    controllerInitializer.addSocketBinding("test", port);
                }

            },readResource("remoting-with-bad-connector-property.xml"));

        try {
            services.getContainer().getRequiredService(RemotingServices.SUBSYSTEM_ENDPOINT);
            fail("Expected no " + RemotingServices.SUBSYSTEM_ENDPOINT);
        } catch (ServiceNotFoundException expected) {
        }

        try {
            services.getContainer().getRequiredService(RemotingServices.serverServiceName("test-connector"));
            fail("Expected no " + RemotingServices.serverServiceName("test-connector"));
        } catch (ServiceNotFoundException expected) {
        }
    }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

        Assert.assertEquals(normalizeXML(subsystemXml), normalizeXML(triggered));
    }

    @Test
    public void testDescribeHandler() throws Exception {
        KernelServices servicesA = installInController(AdditionalInitialization.MANAGEMENT, SUBSYSTEM_XML_1_0);
        ModelNode modelA = servicesA.readWholeModel();
        ModelNode describeOp = new ModelNode();
        describeOp.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.DESCRIBE);
        describeOp.get(ModelDescriptionConstants.OP_ADDR).set(
                PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, ConfigAdminExtension.SUBSYSTEM_NAME)).toModelNode());
        List<ModelNode> operations = checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();

        KernelServices servicesB = installInController(AdditionalInitialization.MANAGEMENT, operations);
        ModelNode modelB = servicesB.readWholeModel();

        compare(modelA, modelB);
    }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

        assertTrue(logFile.delete());
    }

    @Test
    public void testAddRemoveFileHandler() throws Exception {
        KernelServices kernelServices = installInController(readResource("/operations.xml"));

        File logFile = new File(logDir, "test-fh.log");
        if (logFile.exists()) assertTrue(logFile.delete());

        // add file handler
        ModelNode op = createOpNode("subsystem=logging/file-handler=test-fh", "add");
        op.get("name").set("test-fh");
        op.get("level").set("INFO");
        op.get("file").get("path").set(logFile.getAbsolutePath());
        kernelServices.executeOperation(op);

        // register it with root logger
        op = createOpNode("subsystem=logging/root-logger=ROOT", "root-logger-assign-handler");
        op.get("name").set("test-fh");
        kernelServices.executeOperation(op);

        // check it is listed in root-logger
        op = createOpNode("subsystem=logging/root-logger=ROOT", "read-attribute");
        op.get("name").set("handlers");
        ModelNode handlers = kernelServices.executeOperation(op).require(RESULT);
        List<String> loggers = modelNodeAsStringList(handlers);
        assertTrue(loggers.contains("test-fh"));

        for (Logger.Level level : Logger.Level.values()) {
            log.log(level, "Test123");
        }

        // deregister handler from logger
        op = createOpNode("subsystem=logging/root-logger=ROOT", "root-logger-unassign-handler");
        op.get("name").set("test-fh");
        kernelServices.executeOperation(op);

        // check it is not listed in root-logger
        op = createOpNode("subsystem=logging/root-logger=ROOT", "read-attribute");
        op.get("name").set("handlers");
        handlers = kernelServices.executeOperation(op);
        loggers = modelNodeAsStringList(handlers);
        assertFalse(loggers.contains("test-fh"));

        // remove handler
        op = createOpNode("subsystem=logging/file-handler=test-fh", "remove");
        kernelServices.executeOperation(op);

        // check generated log file
        assertTrue(FileUtils.readFileToString(logFile).contains("Test123"));

        // verify that the logger is stopped, no more logs are comming to the file
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    @Test
    public void testParseAndMarshalModel() throws Exception {
        //Parse the subsystem xml and install into the first controller
        String subsystemXml = readResource("securitysubsystemv1.xml");

        KernelServices servicesA = super.installInController(AdditionalInitialization.MANAGEMENT, subsystemXml);
        //Get the model and the persisted xml from the first controller
        ModelNode modelA = servicesA.readWholeModel();
        String marshalled = servicesA.getPersistedSubsystemXml();
        servicesA.shutdown();

        System.out.println(marshalled);

        //Install the persisted xml from the first controller into a second controller
        KernelServices servicesB = super.installInController(AdditionalInitialization.MANAGEMENT, marshalled);
        ModelNode modelB = servicesB.readWholeModel();

        //Make sure the models from the two controllers are identical
        super.compare(modelA, modelB);
    }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    @Test
    public void testParseAndMarshalModelWithJASPI() throws Exception {
        //Parse the subsystem xml and install into the first controller
        String subsystemXml = readResource("securitysubsystemJASPIv1.xml");

        KernelServices servicesA = super.installInController(AdditionalInitialization.MANAGEMENT, subsystemXml);
        //Get the model and the persisted xml from the first controller
        ModelNode modelA = servicesA.readWholeModel();
        String marshalled = servicesA.getPersistedSubsystemXml();
        servicesA.shutdown();

        System.out.println(marshalled);

        //Install the persisted xml from the first controller into a second controller
        KernelServices servicesB = super.installInController(AdditionalInitialization.MANAGEMENT, marshalled);
        ModelNode modelB = servicesB.readWholeModel();

        //Make sure the models from the two controllers are identical
        super.compare(modelA, modelB);

        assertRemoveSubsystemResources(servicesA);
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    @Test
    public void testParseAndMarshalModel() throws Exception {
        //Parse the subsystem xml and install into the first controller
        String subsystemXml = readResource("securitysubsystemv11.xml");

        KernelServices servicesA = super.installInController(AdditionalInitialization.MANAGEMENT, subsystemXml);
        //Get the model and the persisted xml from the first controller
        ModelNode modelA = servicesA.readWholeModel();
        String marshalled = servicesA.getPersistedSubsystemXml();
        servicesA.shutdown();

        System.out.println(marshalled);

        //Install the persisted xml from the first controller into a second controller
        KernelServices servicesB = super.installInController(AdditionalInitialization.MANAGEMENT, marshalled);
        ModelNode modelB = servicesB.readWholeModel();

        //Make sure the models from the two controllers are identical
        super.compare(modelA, modelB);

        assertRemoveSubsystemResources(servicesA);
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    }

    @Test
    public void testChangeRootLogLevel() throws Exception {

        KernelServices kernelServices = installInController(readResource("/operations.xml"));

        // add new file loger so we can track logged messages
        File logFile = new File(logDir, "test-fh.log");
        if (logFile.exists()) assertTrue(logFile.delete());
        addFileHandler(kernelServices, "test-logger", "TRACE", logFile, true);

        Level[] levels = new Logger.Level[] {Level.ERROR, Level.WARN,
            Level.INFO, Level.DEBUG, Level.TRACE};
        Map<Level, Integer> levelOrd = new HashMap<Level,Integer>();
        levelOrd.put(Level.FATAL, 0);
        levelOrd.put(Level.ERROR, 1);
        levelOrd.put(Level.WARN, 2);
        levelOrd.put(Level.INFO, 3);
        levelOrd.put(Level.DEBUG, 4);
        levelOrd.put(Level.TRACE, 5);

        // log messages on all levels with different root logger level settings
        for(Level level : levels) {
            // change root log level
            ModelNode op = createOpNode("subsystem=logging/root-logger=ROOT", "change-root-log-level");
            op.get("level").set(level.name());
            ModelNode ret = kernelServices.executeOperation(op);

            // log a message
            for (Logger.Level lvl : Logger.Level.values()) {
                log.log(lvl, "RootLoggerTestCaseTST " + level);
            }
View Full Code Here

Examples of org.jboss.as.subsystem.test.KernelServices

    @Test
    @Ignore("AS7-2385")
    public void testSetRootLogger() throws Exception {

        KernelServices kernelServices = installInController(readResource("/operations.xml"));

        // add new file loger so we can test root logger change
        File logFile = new File(logDir, "test-fh.log");
        if (logFile.exists()) assertTrue(logFile.delete());
        addFileHandler(kernelServices, "test-logger", "TRACE", logFile, false);

        // read root logger
        ModelNode op = createOpNode("subsystem=logging", "read-attribute");
        op.get("name").set("root-logger");
        ModelNode rootLogger = kernelServices.executeOperation(op);
        List<String> handlers = modelNodeAsStringList(rootLogger.get("handlers"));

        // set new root logger
        op = createOpNode("subsystem=logging", "set-root-logger");
        op.get("level").set(rootLogger.get("level"));
        for(String handler : handlers) op.get("handlers").add(handler);
        op.get("handlers").add("test-logger");
        kernelServices.executeOperation(op);

        // log a message
        for (Logger.Level lvl : Logger.Level.values())
            log.log(lvl, "Test123");


        // revert root logger
        op = createOpNode("subsystem=logging", "set-root-logger");
        op.get("level").set(rootLogger.get("level"));
        op.get("handlers").set(rootLogger.get("handlers"));
        kernelServices.executeOperation(op);

        // remove file handler
        removeFileHandler(kernelServices, "test-logger", false);

        // check that root logger were changed - file logger was registered
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.