Search in sources :

Example 1 with OperationBuilder

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

the class SlaveHostControllerAuthenticationTestCase method setSlaveSecret.

private static void setSlaveSecret(String value) throws IOException {
    ModelNode op = new ModelNode();
    op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
    op.get(OP_ADDR).add(HOST, "slave").add(CORE_SERVICE, MANAGEMENT).add(SECURITY_REALM, "ManagementRealm").add(SERVER_IDENTITY, SECRET);
    op.get(NAME).set(VALUE);
    op.get(VALUE).set(value);
    domainSlaveClient.execute(new OperationBuilder(op).build());
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with OperationBuilder

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

the class ModelPersistenceTestCase method executeAndRollbackOperation.

protected void executeAndRollbackOperation(DomainClient client, final ModelNode op) throws IOException, OperationFormatException {
    ModelNode addDeploymentOp = ModelUtil.createOpNode("deployment=malformedDeployment.war", "add");
    addDeploymentOp.get("content").get(0).get("input-stream-index").set(0);
    DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
    builder.setOperationName("deploy");
    builder.addNode("deployment", "malformedDeployment.war");
    ModelNode[] steps = new ModelNode[3];
    steps[0] = op;
    steps[1] = addDeploymentOp;
    steps[2] = builder.buildRequest();
    ModelNode compositeOp = ModelUtil.createCompositeNode(steps);
    OperationBuilder ob = new OperationBuilder(compositeOp, true);
    ob.addInputStream(new FileInputStream(getBrokenWar()));
    ModelNode ret = client.execute(ob.build());
    Assert.assertFalse(SUCCESS.equals(ret.get(OUTCOME).asString()));
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) DefaultOperationRequestBuilder(org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder) ModelNode(org.jboss.dmr.ModelNode) FileInputStream(java.io.FileInputStream)

Example 3 with OperationBuilder

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

the class DeploymentManagementTestCase method testManagedReplaceUnmanaged.

@Test
public void testManagedReplaceUnmanaged() throws Exception {
    // Establish the deployment
    testUnmanagedArchiveDeployment();
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode op = createDeploymentReplaceOperation(content, MAIN_SERVER_GROUP_ADDRESS, OTHER_SERVER_GROUP_ADDRESS);
    OperationBuilder builder = new OperationBuilder(op, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    // Thread.sleep(1000);
    performHttpCall(DomainTestSupport.masterAddress, 8080);
    performHttpCall(DomainTestSupport.slaveAddress, 8630);
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 4 with OperationBuilder

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

the class DeploymentManagementTestCase method testDeployToSingleServerGroup.

@Test
public void testDeployToSingleServerGroup() throws Exception {
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode composite = createDeploymentOperation(content, OTHER_SERVER_GROUP_DEPLOYMENT_ADDRESS);
    OperationBuilder builder = new OperationBuilder(composite, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    performHttpCall(DomainTestSupport.slaveAddress, 8630);
    try {
        performHttpCall(DomainTestSupport.masterAddress, 8080);
        fail("Webapp deployed to unselected server group");
    } catch (IOException ioe) {
    // good
    }
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 5 with OperationBuilder

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

the class DeploymentManagementTestCase method testReplace.

@Test
public void testReplace() throws Exception {
    // Establish the deployment
    testDeploymentViaStream();
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode op = createDeploymentReplaceOperation(content, MAIN_SERVER_GROUP_ADDRESS, OTHER_SERVER_GROUP_ADDRESS);
    OperationBuilder builder = new OperationBuilder(op, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    // Thread.sleep(1000);
    performHttpCall(DomainTestSupport.masterAddress, 8080);
    performHttpCall(DomainTestSupport.slaveAddress, 8630);
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

OperationBuilder (org.jboss.as.controller.client.OperationBuilder)43 ModelNode (org.jboss.dmr.ModelNode)42 Test (org.junit.Test)17 IOException (java.io.IOException)7 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)7 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)6 BeforeClass (org.junit.BeforeClass)6 Before (org.junit.Before)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DefaultOperationRequestBuilder (org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder)1 DomainClient (org.jboss.as.controller.client.helpers.domain.DomainClient)1 VaultSession (org.jboss.as.security.vault.VaultSession)1 VaultHandler (org.jboss.as.test.integration.security.common.VaultHandler)1 RetryTaskExecutor (org.jboss.as.test.shared.RetryTaskExecutor)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1