Search in sources :

Example 1 with CommandLineException

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

the class CdTestCase method testInvalidAddress.

@Test
public void testInvalidAddress() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    try {
        ctx.connectController();
        ctx.handle("cd subsystem=subsystem");
        Assert.fail("Can't cd into a non-existing nodepath.");
    } catch (CommandLineException e) {
    // expected
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) CommandLineException(org.jboss.as.cli.CommandLineException) Test(org.junit.Test)

Example 2 with CommandLineException

use of org.jboss.as.cli.CommandLineException 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 3 with CommandLineException

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

the class TryCatchFinallyTestCase method testErrorInTryErroInCatchFinally.

@Test
public void testErrorInTryErroInCatchFinally() 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("finally");
        ctx.handle(this.getAddPropertyReq("finally"));
        ctx.handle("end-try");
        fail("catch is expceted to throw an exception");
    } catch (CommandLineException e) {
        cliOut.reset();
        ctx.handle(getReadPropertyReq());
        assertEquals("finally", getValue());
    } 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 4 with CommandLineException

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

the class TryCatchFinallyTestCase method testErrorInFinally.

@Test
public void testErrorInFinally() throws Exception {
    cliOut.reset();
    final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
    try {
        ctx.connectController();
        ctx.handle("try");
        ctx.handle(this.getAddPropertyReq("try"));
        ctx.handle("finally");
        ctx.handle(this.getReadNonexistingPropReq());
        ctx.handle("end-try");
        fail("finally is expceted to throw an exception");
    } catch (CommandLineException e) {
        cliOut.reset();
        ctx.handle(getReadPropertyReq());
        assertEquals("try", getValue());
    } 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)

Aggregations

CommandContext (org.jboss.as.cli.CommandContext)4 CommandLineException (org.jboss.as.cli.CommandLineException)4 Test (org.junit.Test)4