Search in sources :

Example 26 with ModelControllerClient

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

the class DMRSecurityTestCase method testConnect.

/**
     * This test checks that CLI access is secured.
     *
     * @throws Exception We do not provide any credentials so the IOException is required to be thrown.
     */
@Test(expected = java.io.IOException.class)
public void testConnect() throws Exception {
    try (ModelControllerClient modelControllerClient = ModelControllerClient.Factory.create(InetAddress.getByName(TestSuiteEnvironment.getServerAddress()), TestSuiteEnvironment.getServerPort())) {
        ModelNode op = new ModelNode();
        op.get(OP).set(COMPOSITE);
        op.get(OP_ADDR).setEmptyList();
        ModelNode modelNode = op.get(STEPS).add();
        modelNode.get(OP).set(ADD);
        modelNode.get(OP_ADDR).add(SUBSYSTEM, "security");
        modelNode.get(OP_ADDR).add(SECURITY_DOMAIN, "NewSecurityDomain");
        Utils.applyUpdate(op, modelControllerClient);
    }
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 27 with ModelControllerClient

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

the class DeleteJMSResourceHandler method buildRequestWithoutHeaders.

@Override
public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws OperationFormatException {
    try {
        if (!ctx.getParsedCommandLine().hasProperties()) {
            throw new OperationFormatException("Arguments are missing");
        }
    } catch (CommandFormatException e) {
        throw new OperationFormatException(e.getLocalizedMessage());
    }
    //String target = null;
    String jndiName = null;
    // TODO read server name from props
    String serverName = "default";
    String[] args = ctx.getArgumentsString().split("\\s+");
    int i = 0;
    while (i < args.length) {
        String arg = args[i++];
        if (arg.equals("--target")) {
        //                if(i < args.length) {
        //                    target = args[i++];
        //                }
        } else {
            jndiName = arg;
        }
    }
    if (jndiName == null) {
        throw new OperationFormatException("name is missing.");
    }
    ModelControllerClient client = ctx.getModelControllerClient();
    final String resource;
    if (Util.isTopic(client, jndiName)) {
        resource = "jms-topic";
    } else if (Util.isQueue(client, jndiName)) {
        resource = "jms-queue";
    } else if (Util.isConnectionFactory(client, jndiName)) {
        resource = "connection-factory";
    } else {
        throw new OperationFormatException("'" + jndiName + "' wasn't found among existing JMS resources.");
    }
    DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
    builder.addNode("subsystem", "messaging");
    builder.addNode("hornetq-server", serverName);
    builder.addNode(resource, jndiName);
    builder.setOperationName("remove");
    return builder.buildRequest();
}
Also used : OperationFormatException(org.jboss.as.cli.operation.OperationFormatException) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) CommandFormatException(org.jboss.as.cli.CommandFormatException) DefaultOperationRequestBuilder(org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder)

Example 28 with ModelControllerClient

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

the class DeploymentResourceTestCase method executeOperation.

@SuppressWarnings("Duplicates")
private ModelNode executeOperation(final ModelNode op) throws IOException {
    final ModelControllerClient client = managementClient.getControllerClient();
    final ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        return Operations.readResult(result);
    }
    Assert.fail(Operations.getFailureDescription(result).asString());
    // Should never be reached
    return new ModelNode();
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode)

Example 29 with ModelControllerClient

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

the class JobControlTestCase method executeOperation.

private ModelNode executeOperation(final ModelNode op) throws IOException {
    final ModelControllerClient client = managementClient.getControllerClient();
    final ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        return Operations.readResult(result);
    }
    Assert.fail(Operations.getFailureDescription(result).asString());
    // Should never be reached
    return new ModelNode();
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode)

Example 30 with ModelControllerClient

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

the class JobXmlVisibilityTestCase method executeOperation.

@SuppressWarnings("Duplicates")
private ModelNode executeOperation(final ModelNode op) throws IOException {
    final ModelControllerClient client = managementClient.getControllerClient();
    final ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        return Operations.readResult(result);
    }
    Assert.fail(Operations.getFailureDescription(result).asString());
    // Should never be reached
    return new ModelNode();
}
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