22 package com.realtime.crossfire.jxclient.scripts;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import org.jetbrains.annotations.NotNull;
31 import org.junit.Assert;
32 import org.junit.Test;
45 final Collection<ReceivedPacketListener> listeners =
new ArrayList<>();
50 listeners.add(listener);
55 listeners.remove(listener);
59 final StringBuilder sb =
new StringBuilder();
63 public void commandSent(@NotNull
final String cmd) {
64 sb.append(cmd).append(
'\n');
72 listener.processEmpty(
"command");
74 Assert.assertEquals(
"", sb.toString());
81 listener.processEmpty(
"comman");
82 listener.processEmpty(
"command");
84 listener.processEmpty(
"commandx");
87 Assert.assertEquals(
"watch command\n"+
"watch commandx\n", sb.toString());
void test1()
Checks that PacketWatcher#addCommand(String) does work.
Regression tests for PacketWatcher.
void addCommand(@NotNull final String command)
Adds a command to watch for.
Implements CrossfireServerConnection for regression tests.
Interface for listeners interested in received packets.
Implements the "watch" function for client-sided scripts.
Implements ScriptProcess for regression tests.
An external command executed as a client-sided script.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.