System.out.println();
ASConnection connection = getDomainControllerASConnection();
Address deploymentsAddress = new Address("deployment", TEST_WAR_FILE_NAME);
Operation op = new Operation("add", deploymentsAddress);
List<Object> content = new ArrayList<Object>(1);
Map<String, Object> contentValues = new HashMap<String, Object>();
contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
content.add(contentValues);
op.addAdditionalProperty("content", content);
op.addAdditionalProperty("name", TEST_WAR_FILE_NAME); // this needs to be unique per upload
op.addAdditionalProperty("runtime-name", TEST_WAR_FILE_NAME);
System.out.flush();
JsonNode ret = connection.executeRaw(op);
System.out.println("Add to /deploy done " + ret);
System.out.flush();
assert ret.toString().contains("success") : ret;
Address serverGroupAddress = new Address();
serverGroupAddress.add("server-group", "main-server-group");
serverGroupAddress.add("deployment", TEST_WAR_FILE_NAME);
Operation attach = new Operation("add", serverGroupAddress);//,"enabled","true");
// deploy.addAdditionalProperty("runtime-name", TEST_WAR);
System.out.flush();
ret = connection.executeRaw(attach);
System.out.println("Add to server group done: " + ret);
System.out.flush();
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
Operation deploy = new Operation("deploy", serverGroupAddress);
Result depRes = connection.execute(deploy);
assert depRes.isSuccess() : "Deploy went wrong: " + depRes.getFailureDescription();
Thread.sleep(500);
Operation undeploy = new Operation("undeploy", serverGroupAddress);
depRes = connection.execute(undeploy);
assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();
// Now tear down stuff again
Operation unattach = new Operation("remove", serverGroupAddress);
ret = connection.executeRaw(unattach);
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success "
+ ret.getTextValue();
// remove from domain
Operation remove = new Operation("remove", deploymentsAddress);
ret = connection.executeRaw(remove);
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success "
+ ret.getTextValue();