Search in sources :

Example 26 with OperationBuilder

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

the class MixedDomainDeploymentTest method testExplodedDeployment.

@Test
public void testExplodedDeployment() throws Exception {
    ModelNode composite = createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    ModelNode steps = composite.get(STEPS);
    ModelNode op = createAddOperation(ROOT_DEPLOYMENT_ADDRESS);
    op.get(CONTENT).setEmptyList();
    ModelNode empty = new ModelNode();
    empty.get(EMPTY).set(true);
    op.get(CONTENT).add(empty);
    steps.add(op);
    op = createEmptyOperation(ADD_CONTENT, ROOT_DEPLOYMENT_ADDRESS);
    op.get(CONTENT).setEmptyList();
    ModelNode file = new ModelNode();
    file.get(TARGET_PATH).set("index.html");
    file.get(INPUT_STREAM_INDEX).set(0);
    op.get(CONTENT).add(file);
    file = new ModelNode();
    file.get(TARGET_PATH).set("index2.html");
    file.get(INPUT_STREAM_INDEX).set(1);
    op.get(CONTENT).add(file);
    steps.add(op);
    ModelNode sg = steps.add();
    sg.set(createAddOperation(OTHER_SERVER_GROUP_DEPLOYMENT_ADDRESS));
    sg.get(ENABLED).set(true);
    sg = steps.add();
    sg.set(createAddOperation(MAIN_SERVER_GROUP_DEPLOYMENT_ADDRESS));
    sg.get(ENABLED).set(true);
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    OperationBuilder builder = new OperationBuilder(composite);
    builder.addInputStream(tccl.getResourceAsStream("helloWorld/index.html"));
    builder.addInputStream(tccl.getResourceAsStream("helloWorld/index2.html"));
    if (supportManagedExplodedDeployment()) {
        executeOnMaster(builder.build());
        performHttpCall(DomainTestSupport.slaveAddress, 8080);
    } else {
        ModelNode failure = executeForFailureOnMaster(builder.build());
        assertTrue(failure.toJSONString(true), failure.toJSONString(true).contains("WFLYCTL0421:"));
    }
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 27 with OperationBuilder

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

the class MixedDomainDeploymentTest 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, OTHER_SERVER_GROUP_ADDRESS, MAIN_SERVER_GROUP_ADDRESS);
    OperationBuilder builder = new OperationBuilder(op, true);
    builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    performHttpCall(DomainTestSupport.slaveAddress, 8080);
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 28 with OperationBuilder

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

the class MixedDomainDeploymentTest method testJsfWorks.

@Test
public void testJsfWorks() throws Exception {
    ModelNode content = new ModelNode();
    content.get(INPUT_STREAM_INDEX).set(0);
    //Just be lazy here and deploy the jsf-test.war with the same name as the other deployments we tried
    ModelNode composite = createDeploymentOperation(content, OTHER_SERVER_GROUP_DEPLOYMENT_ADDRESS, MAIN_SERVER_GROUP_DEPLOYMENT_ADDRESS);
    OperationBuilder builder = new OperationBuilder(composite, true);
    builder.addInputStream(jsfTestArchive.as(ZipExporter.class).exportAsInputStream());
    executeOnMaster(builder.build());
    performHttpCall(DomainTestSupport.slaveAddress, 8080, "test/home.jsf", "Bean Works");
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 29 with OperationBuilder

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

the class SlaveHostControllerAuthenticationTestCase method slaveWithVaultPasswordTest.

private void slaveWithVaultPasswordTest() throws Exception {
    VaultHandler.cleanFilesystem(RESOURCE_LOCATION, true);
    // create new vault
    VaultHandler vaultHandler = new VaultHandler(RESOURCE_LOCATION);
    try {
        // create security attributes
        String attributeName = "value";
        String vaultPasswordString = vaultHandler.addSecuredAttribute(VAULT_BLOCK, attributeName, RIGHT_PASSWORD.toCharArray());
        // create new vault setting in host
        ModelNode op = new ModelNode();
        op.get(OP).set(ADD);
        op.get(OP_ADDR).add(HOST, "slave").add(CORE_SERVICE, VAULT);
        ModelNode vaultOption = op.get(VAULT_OPTIONS);
        vaultOption.get("KEYSTORE_URL").set(vaultHandler.getKeyStore());
        vaultOption.get("KEYSTORE_PASSWORD").set(vaultHandler.getMaskedKeyStorePassword());
        vaultOption.get("KEYSTORE_ALIAS").set(vaultHandler.getAlias());
        vaultOption.get("SALT").set(vaultHandler.getSalt());
        vaultOption.get("ITERATION_COUNT").set(vaultHandler.getIterationCountAsString());
        vaultOption.get("ENC_FILE_DIR").set(vaultHandler.getEncodedVaultFileDirectory());
        domainSlaveClient.execute(new OperationBuilder(op).build());
        setSlaveSecret("${" + vaultPasswordString + "}");
        reloadSlave();
        // Validate that it joined the master
        readHostControllerStatus(domainMasterClient, 0);
    } finally {
        // remove temporary files
        vaultHandler.cleanUp();
    }
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) VaultHandler(org.jboss.as.test.integration.security.common.VaultHandler) ModelNode(org.jboss.dmr.ModelNode)

Example 30 with OperationBuilder

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

the class SlaveHostControllerAuthenticationTestCase method reloadSlave.

private static void reloadSlave() throws Exception {
    ModelNode op = new ModelNode();
    op.get(OP).set("reload");
    op.get(OP_ADDR).add(HOST, "slave");
    op.get(ADMIN_ONLY).set(false);
    try {
        domainSlaveClient.execute(new OperationBuilder(op).build());
    } catch (IOException e) {
        final Throwable cause = e.getCause();
        if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
            throw e;
        }
    // else ignore, this might happen if the channel gets closed before we got the response
    }
    // Wait until host is reloaded
    readHostControllerStatus(domainSlaveClient, TIMEOUT);
}
Also used : OperationBuilder(org.jboss.as.controller.client.OperationBuilder) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode) ExecutionException(java.util.concurrent.ExecutionException)

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