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);
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations