use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.
the class ArchiveTestCase method testDeployArchive.
@Test
public void testDeployArchive() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext();
try {
ctx.connectController();
ctx.handle("deploy " + cliArchiveFile.getAbsolutePath() + " --script=install.scr");
// check that now both wars are deployed
String response = HttpRequest.get(getBaseURL(url) + "deployment0/SimpleServlet", 10, TimeUnit.SECONDS);
assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
response = HttpRequest.get(getBaseURL(url) + "deployment1/SimpleServlet", 10, TimeUnit.SECONDS);
assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
assertTrue(checkUndeployed(getBaseURL(url) + "deployment2/SimpleServlet"));
ctx.handle("deploy " + cliArchiveFile.getAbsolutePath() + " --script=uninstall.scr");
// check that both wars are undeployed
assertTrue(checkUndeployed(getBaseURL(url) + "deployment0/SimpleServlet"));
assertTrue(checkUndeployed(getBaseURL(url) + "deployment1/SimpleServlet"));
} finally {
ctx.terminateSession();
}
}
use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.
the class ArchiveDefaultScriptNamesTestCase method testDeployUndeployArchive.
@Test
public void testDeployUndeployArchive() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext();
try {
ctx.connectController();
ctx.handle("deploy " + cliArchiveFile.getAbsolutePath());
// check that now both wars are deployed
String response = HttpRequest.get(getBaseURL(url) + "deployment0/SimpleServlet", 10, TimeUnit.SECONDS);
assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
response = HttpRequest.get(getBaseURL(url) + "deployment1/SimpleServlet", 10, TimeUnit.SECONDS);
assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
assertTrue(checkUndeployed(getBaseURL(url) + "deployment2/SimpleServlet"));
ctx.handle("undeploy " + "--path=" + cliArchiveFile.getAbsolutePath());
// check that both wars are undeployed
assertTrue(checkUndeployed(getBaseURL(url) + "deployment0/SimpleServlet"));
assertTrue(checkUndeployed(getBaseURL(url) + "deployment1/SimpleServlet"));
} finally {
ctx.terminateSession();
}
}
use of org.jboss.as.cli.CommandContext in project quickstarts by jboss-switchyard.
the class JBossCliUtil method executeCliScript.
/**
* Executes CLI script file.
* @param path file path
* @throws Exception exception
*/
public static void executeCliScript(String path) throws Exception {
File file = new File(path);
if (!file.exists() || !file.isFile()) {
throw new IllegalArgumentException(path + " is not a valid CLI script file");
}
final CommandContext cmdCtx = CommandContextFactory.getInstance().newCommandContext(HOST, PORT, USER, PASSWORD != null ? PASSWORD.toCharArray() : null, NO_LOCAL_AUTH, INIT_CONSOLE, CONNECTION_TIMEOUT);
if (_logger.isDebugEnabled()) {
cmdCtx.addEventListener(new CliEventListener() {
@Override
public void cliEvent(CliEvent event, CommandContext ctx) {
_logger.debug("CLI Event: " + event.toString());
}
});
}
cmdCtx.connectController();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
_logger.info("Executing CLI script file: " + path);
String line = reader.readLine();
while (cmdCtx.getExitCode() == 0 && !cmdCtx.isTerminated() && line != null) {
if (_logger.isDebugEnabled()) {
_logger.debug(">>> " + line.trim());
}
cmdCtx.handleSafe(line.trim());
line = reader.readLine();
}
} finally {
StreamUtils.safeClose(reader);
cmdCtx.terminateSession();
_logger.info("CLI session is terminated with exit code '" + cmdCtx.getExitCode() + "'");
}
}
use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.
the class NonExistingPathComparisonTestCase method testGreaterThan.
@Test
public void testGreaterThan() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
try {
ctx.connectController();
ctx.handle(this.getAddPropertyReq("\"5\""));
assertEquals("5", runIf(ctx, ">", "&&", "\"1\""));
assertEquals("true", runIf(ctx, ">", "||", "\"1\""));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.
the class NonExistingPathComparisonTestCase method testEquals.
@Test
public void testEquals() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
try {
ctx.connectController();
ctx.handle(this.getAddPropertyReq("\"false\""));
assertEquals("false", runIf(ctx, "==", "&&", "\"false\""));
assertEquals("true", runIf(ctx, "==", "||", "\"false\""));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
Aggregations