/
TimerTest.java
48 lines (38 loc) · 1.66 KB
/
TimerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package jrds.starter;
import java.io.IOException;
import jrds.PropertiesManager;
import jrds.Tools;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class TimerTest {
static Logger logger = Logger.getLogger(TimerTest.class);
@Rule
public final TemporaryFolder testFolder = new TemporaryFolder();
@BeforeClass
static public void configure() throws Exception {
Tools.configure();
logger.setLevel(Level.TRACE);
Tools.setLevel(logger.getLevel(), StarterNode.class.getCanonicalName(), Starter.class.getCanonicalName());
}
@Test
public void buildDefault() throws IOException {
PropertiesManager pm = Tools.makePm(testFolder, "timeout=1", "step=5", "slowcollecttime=1");
Timer t = new Timer(Timer.DEFAULTNAME, pm.timers.get(Timer.DEFAULTNAME));
Assert.assertEquals("bad timeout", 1, t.getTimeout());
Assert.assertEquals("bad step", 5, t.getStep());
Assert.assertEquals("bad slow collect time", 1, t.getSlowCollectTime());
}
@Test
public void buildOther() throws IOException {
PropertiesManager pm = Tools.makePm(testFolder, "timeout=1", "step=5", "timers=slow", "timer.slow.timeout=30", "timer.slow.step=3600", "timer.slow.slowcollecttime=15");
Timer t = new Timer("slow", pm.timers.get("slow"));
Assert.assertEquals("bad timeout", 30, t.getTimeout());
Assert.assertEquals("bad step", 3600, t.getStep());
Assert.assertEquals("bad slow collect time", 15, t.getSlowCollectTime());
}
}