Search in sources :

Example 91 with KernelServices

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

the class JGroupsSubsystemParsingTestCase method testDescribeHandler.

/**
     * Starts a controller with the given subsystem xml and then checks that a second controller
     * started with the operations from its describe action results in the same model
     */
@Test
public void testDescribeHandler() throws Exception {
    KernelServices servicesA = this.buildKernelServices();
    // Get the model and the describe operations from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    ModelNode operation = Operations.createDescribeOperation(PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH));
    List<ModelNode> operations = checkResultAndGetContents(servicesA.executeOperation(operation)).asList();
    // Install the describe options from the first controller into a second controller
    KernelServices servicesB = this.createKernelServicesBuilder().setBootOperations(operations).build();
    ModelNode modelB = servicesB.readWholeModel();
    // Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) ClusteringSubsystemTest(org.jboss.as.clustering.subsystem.ClusteringSubsystemTest) Test(org.junit.Test)

Example 92 with KernelServices

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

the class JGroupsTransformersTestCase method testRejections.

private void testRejections(final ModelTestControllerVersion controller) throws Exception {
    final ModelVersion version = getModelVersion(controller).getVersion();
    final String[] dependencies = getDependencies(controller);
    // create builder for current subsystem version
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    // initialize the legacy services and add required jars
    builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controller, version).addSingleChildFirstClass(AdditionalInitialization.class).addMavenResourceURL(dependencies).dontPersistXml();
    KernelServices services = builder.build();
    Assert.assertTrue(services.isSuccessfulBoot());
    KernelServices legacyServices = services.getLegacyServices(version);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    List<ModelNode> operations = builder.parseXmlResource("subsystem-jgroups-transform-reject.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(services, version, operations, createFailedOperationTransformationConfig(version));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 93 with KernelServices

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

the class OperationSequencesTestCase method testProtocolStackRemoveRemoveSequence.

@Test
public void testProtocolStackRemoveRemoveSequence() throws Exception {
    KernelServices services = buildKernelServices();
    ModelNode operation = Operations.createCompositeOperation(addStackOp, addTransportOp, addProtocolOp);
    // add a protocol stack
    ModelNode result = services.executeOperation(operation);
    Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
    // remove the protocol stack
    result = services.executeOperation(removeStackOp);
    Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
    // remove the protocol stack again
    result = services.executeOperation(removeStackOp);
    Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 94 with KernelServices

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

the class OperationsTestCase method testProtocolReadWriteOperation.

@Test
public void testProtocolReadWriteOperation() throws Exception {
    KernelServices services = this.buildKernelServices();
    // add a protocol stack specifying TRANSPORT and PROTOCOLS parameters
    ModelNode result = services.executeOperation(getProtocolStackAddOperationWithParameters("maximal2"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // read the socket binding attribute
    result = services.executeOperation(getProtocolReadOperation("maximal", "MPING", SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("jgroups-mping", result.get(RESULT).asString());
    // write the attribute
    result = services.executeOperation(getProtocolWriteOperation("maximal", "MPING", SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING, "new-socket-binding"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the attribute
    result = services.executeOperation(getProtocolReadOperation("maximal", "MPING", SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("new-socket-binding", result.get(RESULT).asString());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 95 with KernelServices

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

the class OperationsTestCase method testProtocolPropertyReadWriteOperation.

@Test
public void testProtocolPropertyReadWriteOperation() throws Exception {
    KernelServices services = this.buildKernelServices();
    // read the name protocol property
    ModelNode result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "name"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("value", result.get(RESULT).resolve().asString());
    // write the property
    result = services.executeOperation(getProtocolPutPropertyOperation("maximal", "MPING", "name", "new-value"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the property
    result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "name"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("new-value", result.get(RESULT).asString());
    // remove the property
    result = services.executeOperation(getProtocolRemovePropertyOperation("maximal", "MPING", "name"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    // re-read the property
    result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "name"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
    // Validate property add/read/write/remove via legacy property resource
    result = services.executeOperation(getProtocolPropertyAddOperation("maximal", "MPING", "async_discovery", "false"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    result = services.executeOperation(getProtocolPropertyReadOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("false", result.get(RESULT).asString());
    result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("false", result.get(RESULT).asString());
    result = services.executeOperation(getProtocolPropertyWriteOperation("maximal", "MPING", "async_discovery", "true"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    result = services.executeOperation(getProtocolPropertyReadOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("true", result.get(RESULT).asString());
    result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("true", result.get(RESULT).asString());
    result = services.executeOperation(getProtocolPropertyRemoveOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    result = services.executeOperation(getProtocolGetPropertyOperation("maximal", "MPING", "async_discovery"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertFalse(result.get(RESULT).isDefined());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

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