1 18 package org.drftpd.slaveselection.filter; 19 20 import java.util.Arrays ; 21 import java.util.Properties ; 22 23 import junit.framework.TestCase; 24 import junit.framework.TestSuite; 25 import net.sf.drftpd.NoAvailableSlaveException; 26 import net.sf.drftpd.master.RemoteSlave; 27 import net.sf.drftpd.slave.Transfer; 28 import net.sf.drftpd.util.Time; 29 30 import org.apache.log4j.BasicConfigurator; 31 32 36 public class MintimeonlineFilterTest extends TestCase { 37 38 public MintimeonlineFilterTest(String name) { 39 super(name); 40 } 41 42 public static TestSuite suite() { 43 return new TestSuite(MintimeonlineFilterTest.class); 44 } 45 46 public static class RS extends RemoteSlave { 47 48 public RS(String name) { 49 super(name, null); 50 } 51 52 public long getLastTransferForDirection(char dir) { 53 return System.currentTimeMillis() - Time.parseTime("1m"); 54 } 55 } 56 public void setUp() { 57 BasicConfigurator.configure(); 58 } 59 public void testSimple() throws NoAvailableSlaveException { 60 Properties p = new Properties (); 61 p.put("1.multiplier", "1"); 62 p.put("1.mintime", "2m"); 63 64 RemoteSlave rslaves[] = { new RS("slave1")}; 65 ScoreChart sc = new ScoreChart(Arrays.asList(rslaves)); 66 Filter f = new MintimeonlineFilter(null, 1, p); 67 f.process(sc, null, null, Transfer.TRANSFER_UNKNOWN, null); 68 assertEquals(-Time.parseTime("1m"), sc.getBestSlaveScore().getScore()); 69 } 70 } 71 | Popular Tags |