01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * DrFTPD is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with DrFTPD; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package net.sf.drftpd.master.command.plugins;
19:
20: import f00f.net.irc.martyr.IRCConnection;
21: import f00f.net.irc.martyr.OutCommand;
22: import f00f.net.irc.martyr.commands.MessageCommand;
23:
24: import junit.framework.TestCase;
25:
26: import net.sf.drftpd.event.Event;
27:
28: import org.drftpd.plugins.SiteBot;
29:
30: import java.io.BufferedReader;
31: import java.io.IOException;
32: import java.io.StringReader;
33:
34: import java.net.UnknownHostException;
35:
36: import java.util.ArrayList;
37:
38: /**
39: * @author zubov
40: * @version $Id: TextoutputTest.java 936 2005-01-31 22:25:52Z mog $
41: */
42: public class TextoutputTest extends TestCase {
43: public TextoutputTest(String arg0) {
44: super (arg0);
45: }
46:
47: public static void main(String[] args) {
48: junit.textui.TestRunner.run(TextoutputTest.class);
49: }
50:
51: public void testSendTextToIRC() throws UnknownHostException,
52: IOException {
53: SB irc = new SB();
54:
55: irc.actionPerformed(new Event("RELOAD"));
56: irc.connect();
57:
58: BufferedReader in = new BufferedReader(new StringReader(
59: "Sample text\nMore text"));
60: Textoutput.sendTextToIRC(irc.getIRCConnection(), "zubov", in);
61: assertEquals(irc.msgs.size(), 2);
62: assertEquals("Sample text", ((MessageCommand) irc.msgs.get(0))
63: .getMessage());
64: assertEquals("More text", ((MessageCommand) irc.msgs.get(1))
65: .getMessage());
66: }
67:
68: public static class SB extends SiteBot {
69: public final ArrayList<OutCommand> msgs = new ArrayList<OutCommand>();
70:
71: public SB() throws IOException {
72: super ();
73: }
74:
75: public IRCConnection getIRCConnection() {
76: return new IRCConnection() {
77: public void sendCommand(OutCommand arg) {
78: msgs.add(arg);
79: }
80: };
81: }
82:
83: public void actionPerformed() {
84: return;
85: }
86:
87: public void connect() {
88: return;
89: }
90: }
91: }
|