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 org.drftpd.slaveselection.filter;
19:
20: import junit.framework.TestCase;
21: import junit.framework.TestSuite;
22:
23: import net.sf.drftpd.NoAvailableSlaveException;
24:
25: import org.apache.log4j.BasicConfigurator;
26:
27: import org.drftpd.master.RemoteSlave;
28: import org.drftpd.master.RemoteTransfer;
29:
30: import org.drftpd.slave.Transfer;
31: import org.drftpd.tests.DummyRemoteSlave;
32:
33: import java.util.Arrays;
34: import java.util.Properties;
35:
36: /**
37: * @author mog
38: * @version $Id: SlaveSelectionManagerTest.java 838 2004-12-01 02:35:02Z mog $
39: */
40: public class SlaveSelectionManagerTest extends TestCase {
41: public SlaveSelectionManagerTest(String fName) {
42: super (fName);
43: }
44:
45: public static TestSuite suite() {
46: return new TestSuite(SlaveSelectionManagerTest.class);
47: }
48:
49: public void testEmptyPass() {
50: Properties p = new Properties();
51:
52: try {
53: new FilterChain(null, p);
54: } catch (IllegalArgumentException pass) {
55: fail();
56: }
57: }
58:
59: public void testBandwidth() {
60: Properties p = new Properties();
61: p.put("1.filter", "bandwidth");
62:
63: //p.put("1.expr", "*");
64: p.put("1.multiplier", "1");
65:
66: FilterChain ssm = new FilterChain(null, p);
67: RemoteSlave[] rslaves = { new DummyRemoteSlave("slave1", null),
68: new DummyRemoteSlave("slave2", null) };
69:
70: try {
71: ssm.getBestSlave(new ScoreChart(Arrays.asList(rslaves)),
72: null, null, Transfer.TRANSFER_SENDING_DOWNLOAD,
73: new MatchdirFilterTest.LinkedRemoteFilePath(
74: "/blabla/file.txt"), null);
75: fail(); // no slaves are online
76: } catch (NoAvailableSlaveException pass) {
77: }
78: }
79:
80: public void setUp() {
81: BasicConfigurator.configure();
82: }
83: }
|