use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.
the class BatchesInIfElseTestCase method testElseNoBatchBoot.
@Test
public void testElseNoBatchBoot() throws Exception {
final CommandContext ctx = new CommandContextImpl(cliOut);
CommandLineException expectedEx = null;
try {
ctx.bindClient(managementClient.getControllerClient());
ctx.handle(getAddPropertyReq("1"));
ctx.handle("if result.value==\"3\" of " + getReadPropertyReq());
ctx.handle("else");
ctx.handle(getWritePropertyReq("2"));
ctx.handle(getReadNonexistingPropReq());
try {
ctx.handle("end-if");
} catch (CommandLineException e) {
expectedEx = e;
// for cleanup
throw e;
}
} catch (CommandLineException e) {
cliOut.reset();
ctx.handle(getReadPropertyReq());
assertEquals("2", getValue());
} finally {
ctx.handleSafe(getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
assertNotNull("expected exception", expectedEx);
}
use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.
the class BatchesInIfElseTestCase method testIfNoBatchBoot.
@Test
public void testIfNoBatchBoot() throws Exception {
final CommandContext ctx = new CommandContextImpl(cliOut);
CommandLineException expectedEx = null;
try {
ctx.bindClient(managementClient.getControllerClient());
ctx.handle(getAddPropertyReq("1"));
ctx.handle("if result.value==\"1\" of " + getReadPropertyReq());
ctx.handle(getWritePropertyReq("2"));
ctx.handle(getReadNonexistingPropReq());
try {
ctx.handle("end-if");
} catch (CommandLineException e) {
expectedEx = e;
// for cleanup
throw e;
}
} catch (CommandLineException e) {
cliOut.reset();
ctx.handle(getReadPropertyReq());
assertEquals("2", getValue());
} finally {
ctx.handleSafe(getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
assertNotNull("expected exception", expectedEx);
}
use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.
the class NonExistingPathComparisonTestCase method testUndefinedBoot.
@Test
public void testUndefinedBoot() throws Exception {
final CommandContext ctx = new CommandContextImpl(cliOut);
try {
ctx.bindClient(managementClient.getControllerClient());
ctx.handle(this.getAddPropertyReqWithoutValue());
assertEquals("undefined", runIf(ctx, "==", "&&", "undefined"));
assertEquals("true", runIf(ctx, "==", "||", "undefined"));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.
the class NonExistingPathComparisonTestCase method testGreaterThanBoot.
@Test
public void testGreaterThanBoot() throws Exception {
final CommandContext ctx = new CommandContextImpl(cliOut);
try {
ctx.bindClient(managementClient.getControllerClient());
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.impl.CommandContextImpl in project wildfly-core by wildfly.
the class NonExistingPathComparisonTestCase method testNotEqualBoot.
@Test
public void testNotEqualBoot() throws Exception {
final CommandContext ctx = new CommandContextImpl(cliOut);
try {
ctx.bindClient(managementClient.getControllerClient());
ctx.handle(this.getAddPropertyReq("\"false\""));
assertEquals("false", runIf(ctx, "!=", "&&", "\"true\""));
assertEquals("true", runIf(ctx, "!=", "||", "\"true\""));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
Aggregations