22 package com.realtime.crossfire.jxclient.commands;
26 import java.util.Arrays;
27 import java.util.Collection;
28 import org.jetbrains.annotations.NotNull;
29 import org.junit.Assert;
30 import org.junit.Test;
79 check(
";;;", commands);
97 check(
"cmd;cmd;cm;cmd;cmd2", commands,
new CommandExec(cmd,
""),
new CommandExec(cmd,
""),
new CommandExec(null,
"cm"),
new CommandExec(cmd,
""),
new CommandExec(null,
"cmd2"));
150 check(
"bind cmd;cmd bind", commands,
new CommandExec(bind,
"cmd;cmd bind"));
152 check(
"bind cmd;cmd bind;bind cmd", commands,
new CommandExec(bind,
"cmd;cmd bind;bind cmd"));
154 check(
"bind cmd ; cmd bind ; bind cmd", commands,
new CommandExec(bind,
"cmd ; cmd bind ; bind cmd"));
164 private static void check(@NotNull
final CharSequence command, @NotNull
final Commands commands, @NotNull
final CommandExec... commandList) {
166 Assert.assertEquals(Arrays.asList(commandList), expandedCommands);
Expands a command (or list of commands) into a sequence of Commands to execute.
A Command instance and its arguments.
static Collection< CommandExec > expand(@NotNull final CharSequence commandList, @NotNull final Commands commands)
Expands a command list into a sequence of Commands to execute.
void testExpandAllArguments()
Checks that CommandExpander#expand(CharSequence, Commands) correctly parses commands that consume all...
void testExpandCaseInsensitiveCommandNames()
Checks that CommandExpander#expand(CharSequence, Commands) matches command names case-insensitive.
void addCommand(@NotNull final Command command)
Adds an executable Command.
void testExpandMultiple()
Checks that CommandExpander#expand(CharSequence, Commands) works as expected.
void testExpandArguments()
Checks that CommandExpander#expand(CharSequence, Commands) correctly parses command arguments...
Implements CrossfireServerConnection for regression tests.
void testExpandSingle()
Checks that CommandExpander#expand(CharSequence, Commands) works as expected.
void testExpandIgnoreEmpty()
Checks that CommandExpander#expand(CharSequence, Commands) ignores empty commands.
Regression test for CommandExpander.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
void testExpandPredefined()
Checks that CommandExpander#expand(CharSequence, Commands) detects predefined commands.
void testExpandIgnoreWhitespace()
Checks that CommandExpander#expand(CharSequence, Commands) allows whitespace before or after the comm...
static void check(@NotNull final CharSequence command, @NotNull final Commands commands, @NotNull final CommandExec... commandList)
Checks that CommandExpander#expand(CharSequence, Commands) works as expected.
A Command for regression tests.
Parses and executes client-side commands.