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