Search in sources :

Example 26 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class NonExistingPathComparisonTestCase method testNotLessThan.

@Test
public void testNotLessThan() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.connectController();
        ctx.handle(this.getAddPropertyReq("\"5\""));
        assertEquals("5", runIf(ctx, ">=", "&&", "\"5\""));
        assertEquals("true", runIf(ctx, ">=", "||", "\"5\""));
    } finally {
        ctx.handleSafe(this.getRemovePropertyReq());
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Example 27 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class SilentModeTestCase method testMain.

@Test
public void testMain() throws Exception {
    cliOut.reset();
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.handle("help");
        assertFalse(cliOut.toString().isEmpty());
        cliOut.reset();
        ctx.setSilent(true);
        ctx.handle("help");
        assertTrue(cliOut.toString().isEmpty());
        cliOut.reset();
        ctx.setSilent(false);
        ctx.handle("help");
        assertFalse(cliOut.toString().isEmpty());
    } finally {
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Example 28 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class TryCatchFinallyTestCase method testErrorInTryCatchFinally.

@Test
public void testErrorInTryCatchFinally() throws Exception {
    cliOut.reset();
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.connectController();
        ctx.handle("try");
        ctx.handle(this.getReadNonexistingPropReq());
        ctx.handle("catch");
        ctx.handle(this.getAddPropertyReq("catch"));
        ctx.handle("finally");
        ctx.handle(this.getWritePropertyReq("finally"));
        ctx.handle("end-try");
        cliOut.reset();
        ctx.handle(getReadPropertyReq());
        assertEquals("finally", getValue());
    } finally {
        ctx.handleSafe(getRemovePropertyReq());
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Example 29 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class TryCatchFinallyTestCase method testErrorInCatch.

@Test
public void testErrorInCatch() throws Exception {
    cliOut.reset();
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.connectController();
        ctx.handle("try");
        ctx.handle(this.getReadNonexistingPropReq());
        ctx.handle("catch");
        ctx.handle(this.getReadNonexistingPropReq());
        ctx.handle("end-try");
        fail("catch is expected to throw an exception");
    } catch (CommandLineException e) {
    // expected
    } finally {
        ctx.handleSafe(getRemovePropertyReq());
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) CommandLineException(org.jboss.as.cli.CommandLineException) Test(org.junit.Test)

Example 30 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class TryCatchFinallyTestCase method testCatch.

@Test
public void testCatch() throws Exception {
    cliOut.reset();
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.connectController();
        ctx.handle("try");
        ctx.handle(this.getReadNonexistingPropReq());
        ctx.handle("catch");
        ctx.handle(getAddPropertyReq("catch"));
        ctx.handle("end-try");
        cliOut.reset();
        ctx.handle(getReadPropertyReq());
        assertEquals("catch", getValue());
    } finally {
        ctx.handleSafe(getRemovePropertyReq());
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Aggregations

CommandContext (org.jboss.as.cli.CommandContext)37 Test (org.junit.Test)33 ModelNode (org.jboss.dmr.ModelNode)7 CommandLineException (org.jboss.as.cli.CommandLineException)4 Batch (org.jboss.as.cli.batch.Batch)3 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)3 InSequence (org.jboss.arquillian.junit.InSequence)2 Property (org.jboss.dmr.Property)2 Ignore (org.junit.Ignore)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 CliEvent (org.jboss.as.cli.CliEvent)1 CliEventListener (org.jboss.as.cli.CliEventListener)1