Search in sources :

Example 1 with ModelController

use of org.jboss.as.controller.ModelController in project wildfly by wildfly.

the class JpaDsRestartTestCase method toggleDataSource.

private void toggleDataSource(boolean enable, boolean expectFailure) throws Exception {
    ModelNode op = new ModelNode();
    op.get(OP).set(enable ? "enable" : "disable");
    op.get(OP_ADDR).add("subsystem", "datasources").add("data-source", "H2DS");
    if (!enable) {
        op.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    }
    ModelController controller = (ModelController) serviceContainer.getRequiredService(Services.JBOSS_SERVER_CONTROLLER).getValue();
    ModelNode result = controller.execute(op, OperationMessageHandler.logging, OperationTransactionControl.COMMIT, null);
    if (expectFailure) {
        //System.out.println("Expected failure " + result.get(FAILURE_DESCRIPTION).asString());
        Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
    } else {
        Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) ModelController(org.jboss.as.controller.ModelController)

Aggregations

ModelController (org.jboss.as.controller.ModelController)1 ModelNode (org.jboss.dmr.ModelNode)1