Search in sources :

Example 16 with ModelControllerClient

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

the class AbstractMessagingHATestCase method setUp.

@Before
public void setUp() throws Exception {
    // start server1 and reload it in admin-only
    container.start(SERVER1);
    ModelControllerClient client1 = createClient1();
    snapshotForServer1 = takeSnapshot(client1);
    executeReloadAndWaitForCompletionOfServer1(client1, true);
    client1 = createClient1();
    // start server2 and reload it in admin-only
    container.start(SERVER2);
    ModelControllerClient client2 = createClient2();
    snapshotForServer2 = takeSnapshot(client2);
    executeReloadAndWaitForCompletionOfServer2(client2, true);
    client2 = createClient2();
    // setup both servers
    try {
        setUpServer1(client1);
        setUpServer2(client2);
    } catch (Exception e) {
        tearDown();
        throw e;
    }
    // reload server1 in normal mode
    executeReloadAndWaitForCompletionOfServer1(client1, false);
    client1 = createClient1();
    // reload server2  in normal mode
    executeReloadAndWaitForCompletionOfServer2(client2, false);
    client2 = createClient2();
    // both servers are started and configured
    assertTrue(container.isStarted(SERVER1));
    client1.close();
    assertTrue(container.isStarted(SERVER2));
    client2.close();
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) NamingException(javax.naming.NamingException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Before(org.junit.Before)

Example 17 with ModelControllerClient

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

the class AbstractIdentityManagementServerSetupTask method tearDown.

@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
    ModelControllerClient controllerClient = managementClient.getControllerClient();
    removeIdentityManagementConfiguration(controllerClient);
    applyUpdate(Util.createRemoveOperation(PathAddress.pathAddress().append(SUBSYSTEM, SUBSYSTEM_NAME)), controllerClient);
    applyUpdate(Util.createRemoveOperation(PathAddress.pathAddress().append(EXTENSION, EXTENSION_MODULE_NAME)), controllerClient);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient)

Example 18 with ModelControllerClient

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

the class AccessConstraintUtilizationTestCase method testConstraintUtilization.

@Test
public void testConstraintUtilization() throws Exception {
    ModelControllerClient client = managementClient.getControllerClient();
    for (ExpectedDef expectedDef : EXPECTED_DEFS) {
        AccessConstraintKey acdKey = expectedDef.key;
        String constraint = ModelDescriptionConstants.SENSITIVE.equals(acdKey.getType()) ? ModelDescriptionConstants.SENSITIVITY_CLASSIFICATION : ModelDescriptionConstants.APPLICATION_CLASSIFICATION;
        String acdType = acdKey.isCore() ? "core" : acdKey.getSubsystemName();
        String path = String.format(ADDR_FORMAT, acdKey.getType(), acdType, acdKey.getName());
        ModelNode op = createOpNode(path, READ_CHILDREN_RESOURCES_OPERATION);
        op.get(ModelDescriptionConstants.CHILD_TYPE).set(ModelDescriptionConstants.APPLIES_TO);
        //System.out.println("Testing " + acdKey);
        ModelNode result = RbacUtil.executeOperation(client, op, Outcome.SUCCESS).get(ModelDescriptionConstants.RESULT);
        Assert.assertTrue(acdKey + "result is defined", result.isDefined());
        Assert.assertTrue(acdKey + "result has content", result.asInt() > 0);
        boolean foundResource = false;
        boolean foundAttr = false;
        boolean foundOps = false;
        for (Property prop : result.asPropertyList()) {
            ModelNode pathResult = prop.getValue();
            if (pathResult.get(ModelDescriptionConstants.ENTIRE_RESOURCE).asBoolean()) {
                Assert.assertTrue(acdKey + " -- " + prop.getName() + " resource", expectedDef.expectResource);
                foundResource = true;
            }
            ModelNode attrs = pathResult.get(ATTRIBUTES);
            if (attrs.isDefined() && attrs.asInt() > 0) {
                Assert.assertTrue(acdKey + " -- " + prop.getName() + " attributes = " + attrs.asString(), expectedDef.expectAttributes);
                foundAttr = true;
            }
            ModelNode ops = pathResult.get(OPERATIONS);
            if (ops.isDefined() && ops.asInt() > 0) {
                Assert.assertTrue(acdKey + " -- " + prop.getName() + " operations = " + ops.asString(), expectedDef.expectOps);
                foundOps = true;
            }
        }
        Assert.assertEquals(acdKey + " -- resource", expectedDef.expectResource, foundResource);
        Assert.assertEquals(acdKey + " -- attributes", expectedDef.expectAttributes, foundAttr);
        Assert.assertEquals(acdKey + " -- operations", expectedDef.expectOps, foundOps);
    }
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) AccessConstraintKey(org.jboss.as.controller.access.management.AccessConstraintKey) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) Test(org.junit.Test)

Example 19 with ModelControllerClient

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

the class DomainHostExcludesTest method test001SlaveBoot.

@Test
public void test001SlaveBoot() throws Exception {
    ModelControllerClient slaveClient = testSupport.getDomainSlaveLifecycleUtil().getDomainClient();
    checkExtensions(slaveClient);
    checkProfiles(slaveClient);
    checkSocketBindingGroups(slaveClient);
    checkSockets(slaveClient, PathAddress.pathAddress(SOCKET_BINDING_GROUP, "full-sockets"));
    checkSockets(slaveClient, PathAddress.pathAddress(SOCKET_BINDING_GROUP, "full-ha-sockets"));
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Test(org.junit.Test)

Example 20 with ModelControllerClient

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

the class DomainHostExcludesTest method stopSlave.

private static void stopSlave() throws IOException, MgmtOperationException, InterruptedException {
    ModelControllerClient client = testSupport.getDomainMasterLifecycleUtil().getDomainClient();
    executeForResult(Util.createEmptyOperation(SHUTDOWN, PathAddress.pathAddress(HOST)), client);
    boolean gone = false;
    long timeout = TimeoutUtil.adjust(30000);
    long deadline = System.currentTimeMillis() + timeout;
    do {
        ModelNode hosts = readChildrenNames(client, PathAddress.EMPTY_ADDRESS, HOST.getKey());
        gone = true;
        for (ModelNode host : hosts.asList()) {
            if (HOST.getValue().equals(host.asString())) {
                gone = false;
                Thread.sleep(100);
                break;
            }
        }
    } while (!gone && System.currentTimeMillis() < deadline);
    Assert.assertTrue("Slave was not removed within " + timeout + " ms", gone);
    testSupport.getDomainSlaveLifecycleUtil().stop();
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode)

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