Search in sources :

Example 96 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class OperationsTestCase method testTransportReadWriteWithParameters.

@Test
public void testTransportReadWriteWithParameters() throws Exception {
    // Parse and install the XML into the controller
    KernelServices services = this.buildKernelServices();
    Assert.assertTrue("Could not create services", services.isSuccessfulBoot());
    // add a protocol stack specifying TRANSPORT and PROTOCOLS parameters
    ModelNode result = services.executeOperation(getProtocolStackAddOperationWithParameters("maximal2"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // write the rack attribute
    result = services.executeOperation(getTransportWriteOperation("maximal", "TCP", TransportResourceDefinition.Attribute.RACK, "new-rack"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the rack attribute
    result = services.executeOperation(getTransportReadOperation("maximal", "TCP", TransportResourceDefinition.Attribute.RACK));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("new-rack", result.get(RESULT).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 97 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class OperationsTestCase method testSubsystemReadWriteOperations.

/**
     * Tests access to subsystem attributes
     */
@Test
public void testSubsystemReadWriteOperations() throws Exception {
    KernelServices services = this.buildKernelServices();
    // read the default stack
    ModelNode result = services.executeOperation(getSubsystemReadOperation(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL));
    Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("ee", result.get(RESULT).resolve().asString());
    // write the default stack
    result = services.executeOperation(getSubsystemWriteOperation(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL, "bridge"));
    Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the default stack
    result = services.executeOperation(getSubsystemReadOperation(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL));
    Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("bridge", result.get(RESULT).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 98 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class EeOperationsTestCase method testManagedExecutorOperations.

@Test
public void testManagedExecutorOperations() throws Exception {
    // Boot the container
    final KernelServices kernelServices = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()).build();
    // Default address
    final ModelNode address = Operations.createAddress(ClientConstants.SUBSYSTEM, EeExtension.SUBSYSTEM_NAME, "managed-executor-service", "default");
    ModelNode op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", Integer.MAX_VALUE)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 5)).build().getOperation();
    executeForSuccess(kernelServices, op);
    op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "max-threads", 5)).addStep(Operations.createWriteAttributeOperation(address, "queue-length", 10)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 0)).build().getOperation();
    executeForSuccess(kernelServices, op);
    // The max-threads must be greater than or equal to the core-threads
    op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "core-threads", 4)).addStep(Operations.createWriteAttributeOperation(address, "max-threads", 4)).build().getOperation();
    executeForSuccess(kernelServices, op);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 99 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class EeSubsystemTestCase method testTransformersDiscardsImpliedValues1_0_0.

private void testTransformersDiscardsImpliedValues1_0_0(ModelTestControllerVersion controllerVersion) throws Exception {
    String subsystemXml = readResource("subsystem-transformers-discard.xml");
    ModelVersion modelVersion = ModelVersion.create(1, 0, 0);
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(subsystemXml);
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-ee:" + controllerVersion.getMavenGavVersion()).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, new ModelFixer() {

        // The regular model will have the new attributes because they are in the xml,
        // but the reverse controller model will not because transformation strips them
        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            for (ModelNode node : modelNode.get(GLOBAL_MODULES).asList()) {
                if ("org.apache.log4j".equals(node.get(NAME).asString())) {
                    if (!node.has(ANNOTATIONS)) {
                        node.get(ANNOTATIONS).set(false);
                    }
                    if (!node.has(META_INF)) {
                        node.get(META_INF).set(false);
                    }
                    if (!node.has(SERVICES)) {
                        node.get(SERVICES).set(true);
                    }
                }
            }
            return modelNode;
        }
    });
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    ModelNode globalModules = mainServices.readTransformedModel(modelVersion).get(ModelDescriptionConstants.SUBSYSTEM, "ee").get(GlobalModulesDefinition.GLOBAL_MODULES);
    for (ModelNode node : globalModules.asList()) {
        if (node.hasDefined(ANNOTATIONS) || node.hasDefined(SERVICES) || node.hasDefined(META_INF)) {
            Assert.fail(node + " -- attributes not discarded");
        }
    }
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 100 with KernelServices

use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.

the class EeSubsystemTestCase method testTransformers1_0_x_reject.

private void testTransformers1_0_x_reject(ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
    String subsystemXml = readResource("subsystem.xml");
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    List<ModelNode> xmlOps = builder.parseXml(subsystemXml);
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-ee:" + controllerVersion.getMavenGavVersion());
    KernelServices mainServices = builder.build();
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    FailedOperationTransformationConfig.ChainedConfig chained = FailedOperationTransformationConfig.ChainedConfig.createBuilder(GlobalModulesDefinition.INSTANCE.getName(), EESubsystemModel.ANNOTATION_PROPERTY_REPLACEMENT).addConfig(new GlobalModulesConfig()).addConfig(new FailedOperationTransformationConfig.RejectExpressionsConfig(EESubsystemModel.ANNOTATION_PROPERTY_REPLACEMENT) {

        @Override
        protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
            ModelNode resolved = super.correctValue(toResolve, isWriteAttribute);
            //Make it a boolean
            return new ModelNode(resolved.asBoolean());
        }
    }).build();
    FailedOperationTransformationConfig config = new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM), chained).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.CONTEXT_SERVICE)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_THREAD_FACTORY)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_EXECUTOR_SERVICE)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE)), REJECTED_RESOURCE);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, xmlOps, config);
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Aggregations

KernelServices (org.jboss.as.subsystem.test.KernelServices)144 ModelNode (org.jboss.dmr.ModelNode)102 Test (org.junit.Test)86 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)69 ModelVersion (org.jboss.as.controller.ModelVersion)30 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)29 PathAddress (org.jboss.as.controller.PathAddress)24 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)21 AbstractSubsystemTest (org.jboss.as.subsystem.test.AbstractSubsystemTest)11 ClusteringSubsystemTest (org.jboss.as.clustering.subsystem.ClusteringSubsystemTest)10 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)8 ModelFixer (org.jboss.as.model.test.ModelFixer)7 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)6 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 Properties (java.util.Properties)4 Session (javax.mail.Session)4 CompositeOperationBuilder (org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder)3 ConnectorLogger (org.jboss.as.connector.logging.ConnectorLogger)2 Operation (org.jboss.as.controller.client.Operation)2 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2