Search in sources :

Example 6 with OperationBuilder

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

the class DeploymentManagementTestCase method testDeploymentViaStream.

@Test
public void testDeploymentViaStream() throws Exception {
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode composite = createDeploymentOperation(content, MAIN_SERVER_GROUP_DEPLOYMENT_ADDRESS, OTHER_SERVER_GROUP_DEPLOYMENT_ADDRESS);
    OperationBuilder builder = new OperationBuilder(composite, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    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 7 with OperationBuilder

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

the class DeploymentOverlayTestCase method setupDeploymentOverride.

public void setupDeploymentOverride() throws Exception {
    ModelNode op = new ModelNode();
    op.get(ModelDescriptionConstants.OP_ADDR).set(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_OVERLAY);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    executeOnMaster(op);
    //add an override that will not be linked via a wildcard
    //add the content
    op = new ModelNode();
    OperationBuilder builder = new OperationBuilder(op, true);
    ModelNode addr = new ModelNode();
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_OVERLAY);
    addr.add(ModelDescriptionConstants.CONTENT, "WEB-INF/web.xml");
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    op.get(ModelDescriptionConstants.CONTENT).get(INPUT_STREAM_INDEX).set(0);
    builder.addInputStream(getClass().getClassLoader().getResourceAsStream("deploymentoverlay/override.xml"));
    executeOnMaster(builder.build());
    //add the non-wildcard link to the server group
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.SERVER_GROUP, "main-server-group");
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_OVERLAY);
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    executeOnMaster(op);
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.SERVER_GROUP, "main-server-group");
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_OVERLAY);
    addr.add(ModelDescriptionConstants.DEPLOYMENT, "test.war");
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    executeOnMaster(op);
    //add the wildard link
    final ModelNode composite = new ModelNode();
    final OperationBuilder opBuilder = new OperationBuilder(composite, true);
    composite.get(Util.OPERATION).set(Util.COMPOSITE);
    composite.get(Util.ADDRESS).setEmptyList();
    final ModelNode steps = composite.get(Util.STEPS);
    op = new ModelNode();
    op.get(ModelDescriptionConstants.OP_ADDR).set(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_WILDCARD);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    steps.add(op);
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_WILDCARD);
    addr.add(ModelDescriptionConstants.CONTENT, "WEB-INF/web.xml");
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    op.get(ModelDescriptionConstants.CONTENT).get(ModelDescriptionConstants.BYTES).set(FileUtils.readFile(getClass().getClassLoader().getResource("deploymentoverlay/wildcard-override.xml")).getBytes());
    steps.add(op);
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_WILDCARD);
    addr.add(ModelDescriptionConstants.CONTENT, "WEB-INF/classes/wildcard-new-file");
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    op.get(ModelDescriptionConstants.CONTENT).get(ModelDescriptionConstants.INPUT_STREAM_INDEX).set(0);
    opBuilder.addInputStream(new ByteArrayInputStream("new file".getBytes()));
    steps.add(op);
    //add the non-wildcard link to the server group
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.SERVER_GROUP, "main-server-group");
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_WILDCARD);
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    steps.add(op);
    op = new ModelNode();
    addr = new ModelNode();
    addr.add(ModelDescriptionConstants.SERVER_GROUP, "main-server-group");
    addr.add(ModelDescriptionConstants.DEPLOYMENT_OVERLAY, TEST_WILDCARD);
    addr.add(ModelDescriptionConstants.DEPLOYMENT, "*.war");
    op.get(ModelDescriptionConstants.OP_ADDR).set(addr);
    op.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    steps.add(op);
    executeOnMaster(opBuilder.build());
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ModelNode(org.jboss.dmr.ModelNode)

Example 8 with OperationBuilder

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

the class DeploymentOverlayTestCase method testDeploymentOverlayInDomainMode.

/**
     * This test creates and links two deployment overlays, does a deployment, and then tests that the overlay has taken effect
     * @throws Exception
     */
@Test
public void testDeploymentOverlayInDomainMode() throws Exception {
    setupDeploymentOverride();
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode composite = createDeploymentOperation(content, MAIN_SERVER_GROUP_DEPLOYMENT_ADDRESS);
    OperationBuilder builder = new OperationBuilder(composite, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    DomainClient client = testSupport.getDomainMasterLifecycleUtil().createDomainClient();
    Assert.assertEquals("OVERRIDDEN", performHttpCall(client, "master", "main-one", "standard-sockets"));
    Assert.assertEquals("OVERRIDDEN", performHttpCall(client, "slave", "main-three", "standard-sockets"));
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 9 with OperationBuilder

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

the class DeploymentManagementTestCase method testManagedFullReplaceUnmanaged.

@Test
public void testManagedFullReplaceUnmanaged() throws Exception {
    // Establish the deployment
    testUnmanagedExplodedDeployment();
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode op = createDeploymentFullReplaceOperation(content);
    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 10 with OperationBuilder

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

the class DeploymentManagementTestCase method testFullReplaceViaStream.

@Test
public void testFullReplaceViaStream() throws Exception {
    // Establish the deployment
    testDeploymentViaStream();
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    ModelNode op = createDeploymentFullReplaceOperation(content);
    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