KickJava   Java API By Example, From Geeks To Geeks.

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


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
23 import net.sf.drftpd.NoAvailableSlaveException;
24 import net.sf.drftpd.ObjectNotFoundException;
25 import net.sf.drftpd.master.RemoteSlave;
26 import net.sf.drftpd.slave.Transfer;
27
28 import junit.framework.TestCase;
29
30 /*
31  * @author zubov
32  * @version $Id
33  */

34 public class CycleFilterTest extends TestCase {
35
36     /**
37      * Constructor for CycleFilterTest.
38      * @param arg0
39      */

40     public CycleFilterTest(String JavaDoc arg0) {
41         super(arg0);
42     }
43
44     public static void main(String JavaDoc[] args) {
45         junit.textui.TestRunner.run(CycleFilterTest.class);
46     }
47
48     public void testProcess() throws NoAvailableSlaveException, ObjectNotFoundException {
49         RemoteSlave rslaves[] =
50             {
51                 new RemoteSlave("slave1", Collections.EMPTY_LIST),
52                 new RemoteSlave("slave2", Collections.EMPTY_LIST),
53                 new RemoteSlave("slave3", Collections.EMPTY_LIST)};
54         ScoreChart sc = new ScoreChart(Arrays.asList(rslaves));
55         Filter f = new CycleFilter(null,0,null);
56         f.process(sc, null, null,Transfer.TRANSFER_SENDING_DOWNLOAD, null);
57         assertEquals(1,sc.getSlaveScore(rslaves[0]).getScore());
58         assertEquals(0,sc.getSlaveScore(rslaves[1]).getScore());
59         assertEquals(0,sc.getSlaveScore(rslaves[2]).getScore());
60     }
61 }
62
Popular Tags