Search in sources :

Example 41 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class ClusteredMessagingTestCase method tearDown.

@After
public void tearDown() throws Exception {
    try (ModelControllerClient client = createClient1()) {
        JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
        jmsOperations.removeJmsQueue(jmsQueueName);
        jmsOperations.removeJmsTopic(jmsTopicName);
    }
    try (ModelControllerClient client = createClient2()) {
        JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
        jmsOperations.removeJmsQueue(jmsQueueName);
        jmsOperations.removeJmsTopic(jmsTopicName);
    }
    container.stop(CONTAINER_0);
    container.stop(CONTAINER_1);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) After(org.junit.After)

Example 42 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class ModClusterSubsystemAddTestCase method testModClusterAdd.

@Test
@InSequence(1)
public void testModClusterAdd() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();
    try {
        ctx.connectController();
        // Add the mod_cluster extension first (not in this profile by default)
        ModelNode request = ctx.buildRequest("/extension=org.jboss.as.modcluster:add");
        ModelNode response = controllerClient.execute(request);
        String outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster extension failed! " + request.toJSONString(false), "success", outcome);
        // Now lets execute subsystem add operation but we need to specify a connector
        ctx.getBatchManager().activateNewBatch();
        Batch b = ctx.getBatchManager().getActiveBatch();
        b.add(ctx.toBatchedCommand("/socket-binding-group=standard-sockets/socket-binding=modcluster:add(multicast-port=23364, multicast-address=224.0.1.105)"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster:add"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster/mod-cluster-config=configuration:add(connector=http,advertise-socket=modcluster)"));
        request = b.toRequest();
        b.clear();
        ctx.getBatchManager().discardActiveBatch();
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster subsystem failed! " + request.toJSONString(false), "success", outcome);
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Batch(org.jboss.as.cli.batch.Batch) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 43 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class ModClusterSubsystemAddTestCase method testModClusterRemove.

@Test
@InSequence(2)
public void testModClusterRemove() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();
    try {
        ctx.connectController();
        // Test subsystem remove
        ModelNode request = ctx.buildRequest("/subsystem=modcluster:remove");
        ModelNode response = controllerClient.execute(request);
        String outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster subsystem failed! " + request.toJSONString(false), "success", outcome);
        // Cleanup socket binding
        request = ctx.buildRequest("/socket-binding-group=standard-sockets/socket-binding=modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing socket binding failed! " + request.toJSONString(false), "success", outcome);
        // Cleanup and remove the extension
        request = ctx.buildRequest("/extension=org.jboss.as.modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster extension failed! " + request.toJSONString(false), "success", outcome);
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 44 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class StatelessBean method getJBossProperty.

public String getJBossProperty(String name) {
    ModelControllerClient client = getClient();
    String result = Utils.getProperty(name, client);
    log.debug("JBoss system property " + name + " was resolved to be " + result);
    return result;
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient)

Example 45 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class HTTPSWebConnectorTestCase method stopContainer.

@Test
@InSequence(3)
public void stopContainer() throws Exception {
    deployer.undeploy(APP_CONTEXT);
    final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
    final ManagementClient managementClient = new ManagementClient(client, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
    LOGGER.trace("*** reseting test configuration");
    serverTearDown(managementClient);
    LOGGER.trace("*** stopping container");
    containerController.stop(CONTAINER);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ManagementClient(org.jboss.as.arquillian.container.ManagementClient) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)58 ModelNode (org.jboss.dmr.ModelNode)27 Test (org.junit.Test)21 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)17 IOException (java.io.IOException)11 InSequence (org.jboss.arquillian.junit.InSequence)8 URL (java.net.URL)5 PathAddress (org.jboss.as.controller.PathAddress)5 Before (org.junit.Before)5 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)4 UnknownHostException (java.net.UnknownHostException)3 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 CommandContext (org.jboss.as.cli.CommandContext)2 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)2 DefaultOperationRequestBuilder (org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder)2 After (org.junit.After)2 BeforeClass (org.junit.BeforeClass)2