Search in sources :

Example 16 with CommandContextImpl

use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.

the class CliSpecialCharactersTestCase method testWhitespaceTrimmingBoot.

@Test
public void testWhitespaceTrimmingBoot() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    CommandContext ctx = new CommandContextImpl(out);
    ctx.bindClient(managementClient.getControllerClient());
    Supplier<String> str = () -> {
        String s = out.toString();
        out.reset();
        return s;
    };
    testSetResourceValue("   Hello World!   ", "   Hello World!   ", Delimiters.DOUBLE_QUOTE, ctx, str);
    testSetResourceValue("   Hello World!   ", "Hello World!", Delimiters.CURLY_BRACE, ctx, str);
    testSetResourceValue("   Hello\\ World!   ", "Hello World!", Delimiters.NONE, ctx, str);
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 17 with CommandContextImpl

use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.

the class CliSpecialCharactersTestCase method testCommasInDoubleQuotesBoot.

@Test
public void testCommasInDoubleQuotesBoot() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    CommandContext ctx = new CommandContextImpl(out);
    ctx.bindClient(managementClient.getControllerClient());
    Supplier<String> str = () -> {
        String s = out.toString();
        out.reset();
        return s;
    };
    testSetResourceValue("Last,First", "Last,First", Delimiters.DOUBLE_QUOTE, ctx, str);
    testSetResourceValue(",,,A,B,C,D,E,F,,,", ",,,A,B,C,D,E,F,,,", Delimiters.DOUBLE_QUOTE, ctx, str);
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 18 with CommandContextImpl

use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.

the class BasicIfElseTestCase method testIfInsideIfBoot.

@Test
public void testIfInsideIfBoot() throws Exception {
    final CommandContext ctx = new CommandContextImpl(cliOut);
    boolean failed = false;
    try {
        ctx.bindClient(managementClient.getControllerClient());
        ctx.handle("if result.value==\"true\" of " + this.getReadPropertyReq());
        ctx.handle("if result.value==\"true\" of " + this.getReadPropertyReq());
    } catch (CommandFormatException ex) {
        failed = true;
    } finally {
        try {
            if (!failed) {
                throw new Exception("if inside if should have failed");
            }
        } finally {
            ctx.terminateSession();
            cliOut.reset();
        }
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) CommandFormatException(org.jboss.as.cli.CommandFormatException) CommandFormatException(org.jboss.as.cli.CommandFormatException) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 19 with CommandContextImpl

use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.

the class BasicIfElseTestCase method testIfMatchComparisonBoot.

@Test
public void testIfMatchComparisonBoot() throws Exception {
    final CommandContext ctx = new CommandContextImpl(cliOut, false);
    try {
        ctx.bindClient(managementClient.getControllerClient());
        ctx.handle(this.getAddPropertyReq("match-test-values", "\"AAA BBB\""));
        assertEquals("true", runIfWithMatchComparison("match-test-values", "AAA", ctx));
        assertEquals("true", runIfWithMatchComparison("match-test-values", "BBB", ctx));
        assertEquals("false", runIfWithMatchComparison("match-test-values", "CCC", ctx));
    } finally {
        ctx.handleSafe(this.getRemovePropertyReq("match-test-values"));
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 20 with CommandContextImpl

use of org.jboss.as.cli.impl.CommandContextImpl in project wildfly-core by wildfly.

the class BasicIfElseTestCase method testMainBoot.

@Test
public void testMainBoot() throws Exception {
    final CommandContext ctx = new CommandContextImpl(cliOut);
    try {
        ctx.bindClient(managementClient.getControllerClient());
        ctx.handle(this.getAddPropertyReq("\"true\""));
        assertEquals("false", runIf(ctx));
        assertEquals("true", runIf(ctx));
        assertEquals("false", runIf(ctx));
    } finally {
        ctx.handleSafe(this.getRemovePropertyReq());
        ctx.terminateSession();
        cliOut.reset();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Aggregations

CommandContextImpl (org.jboss.as.cli.impl.CommandContextImpl)29 Test (org.junit.Test)29 CommandContext (org.jboss.as.cli.CommandContext)27 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 CommandLineException (org.jboss.as.cli.CommandLineException)4 CLICommandInvocation (org.wildfly.core.cli.command.aesh.CLICommandInvocation)2 Path (java.nio.file.Path)1 CommandFormatException (org.jboss.as.cli.CommandFormatException)1 AeshCommands (org.jboss.as.cli.impl.aesh.AeshCommands)1 LegacyCommandContainer (org.jboss.as.cli.impl.aesh.cmd.operation.LegacyCommandContainer)1