Search in sources :

Example 11 with CommandContextImpl

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

the class BatchTestCase method testRollbackBatchBoot.

@Test
public void testRollbackBatchBoot() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    CommandContext ctx = new CommandContextImpl(out);
    ctx.bindClient(managementClient.getControllerClient());
    try {
        doTestRollbackBatch(ctx, () -> {
            String str = out.toString();
            out.reset();
            return str;
        });
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 12 with CommandContextImpl

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

the class HelpSupportTestCase method testCLICommands.

@Test
public void testCLICommands() throws Exception {
    CommandContextImpl ctx = (CommandContextImpl) CommandContextFactory.getInstance().newCommandContext();
    AeshCommands commands = ctx.getAeshCommands();
    for (String name : commands.getRegistry().getAllCommandNames()) {
        CLICommandContainer container = (CLICommandContainer) commands.getRegistry().getCommand(name, name);
        if (!(container.getWrappedContainer() instanceof LegacyCommandContainer) && !isAeshExtension(container.getParser().getCommand())) {
            HelpSupport.checkCommand(null, container.getParser());
            for (CommandLineParser<CLICommandInvocation> child : container.getParser().getAllChildParsers()) {
                HelpSupport.checkCommand(container.getParser(), child);
            }
        }
    }
}
Also used : LegacyCommandContainer(org.jboss.as.cli.impl.aesh.cmd.operation.LegacyCommandContainer) CLICommandInvocation(org.wildfly.core.cli.command.aesh.CLICommandInvocation) CommandContextImpl(org.jboss.as.cli.impl.CommandContextImpl) Test(org.junit.Test)

Example 13 with CommandContextImpl

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

the class CliSpecialCharactersTestCase method testSingleQuotesBoot.

@Test
public void testSingleQuotesBoot() 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("It's", "It's", Delimiters.DOUBLE_QUOTE, ctx, str);
    testSetResourceValue("It\\'s", "It's", Delimiters.NONE, ctx, str);
    testSetResourceValue("''It's''", "''It's''", 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 14 with CommandContextImpl

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

the class CliSpecialCharactersTestCase method testWhitespaceInMiddleBoot.

/**
 * Tests whitespace in the middle of words Regression test for
 * https://issues.jboss.org/browse/JBEAP-4536
 *
 * @throws Exception
 */
@Test
public void testWhitespaceInMiddleBoot() 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 15 with CommandContextImpl

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

the class CliSpecialCharactersTestCase method testBracesBoot.

@Test
public void testBracesBoot() 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("{braces}", "{braces}", 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)

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