KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > drftpd > slaveselection > filter > SlaveSelectionManagerTest


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 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 java.util.Arrays JavaDoc;
21 import java.util.Collections JavaDoc;
22 import java.util.Properties JavaDoc;
23
24 import junit.framework.TestCase;
25 import junit.framework.TestSuite;
26 import net.sf.drftpd.NoAvailableSlaveException;
27 import net.sf.drftpd.master.RemoteSlave;
28 import net.sf.drftpd.slave.Transfer;
29
30 import org.apache.log4j.BasicConfigurator;
31
32 /**
33  * @author mog
34  * @version $Id: SlaveSelectionManagerTest.java,v 1.3 2004/03/01 00:21:10 mog Exp $
35  */

36 public class SlaveSelectionManagerTest extends TestCase {
37
38     public SlaveSelectionManagerTest(String JavaDoc fName) {
39         super(fName);
40     }
41
42     public static TestSuite suite() {
43         return new TestSuite(SlaveSelectionManagerTest.class);
44     }
45
46     public void testEmptyFail() {
47         Properties JavaDoc p = new Properties JavaDoc();
48         try {
49             new FilterChain(null, p);
50             fail();
51         } catch (IllegalArgumentException JavaDoc pass) {
52         }
53     }
54
55     public void testBandwidth() {
56         Properties JavaDoc p = new Properties JavaDoc();
57         p.put("1.filter", "bandwidth");
58         //p.put("1.expr", "*");
59
p.put("1.multiplier", "1");
60         FilterChain ssm = new FilterChain(null, p);
61         RemoteSlave rslaves[] =
62             {
63                 new RemoteSlave("slave1", Collections.EMPTY_LIST),
64                 new RemoteSlave("slave2", Collections.EMPTY_LIST)};
65
66         try {
67             ssm.getBestSlave(
68                 new ScoreChart(Arrays.asList(rslaves)), null, null,
69                 Transfer.TRANSFER_SENDING_DOWNLOAD,
70                 new MatchdirFilterTest.LinkedRemoteFilePath(
71                     "/blabla/file.txt"));
72             fail(); // no slaves are online
73
} catch (NoAvailableSlaveException pass) {
74         }
75     }
76     public void setUp() {
77         BasicConfigurator.configure();
78     }
79 }
80
Popular Tags