1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package net.grinder.util.logback;
23
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26
27 import java.io.File;
28 import java.io.FileWriter;
29 import java.io.IOException;
30
31 import net.grinder.testutility.AbstractJUnit4FileTestCase;
32
33 import org.junit.Test;
34
35
36
37
38
39
40
41 public class TestRollOnStartUp extends AbstractJUnit4FileTestCase {
42
43 @Test public void testRollOnStartUp() throws IOException {
44 final File f = new File(getDirectory(), "foo");
45 final FileWriter out = new FileWriter(f);
46 out.write("foo");
47 out.close();
48
49 final RollOnStartUp<Object> r1 = new RollOnStartUp<Object>();
50 assertTrue(r1.isTriggeringEvent(f, null));
51 assertFalse(r1.isTriggeringEvent(f, null));
52 assertFalse(r1.isTriggeringEvent(f, null));
53
54 assertTrue(new RollOnStartUp<Object>().isTriggeringEvent(f, null));
55 assertFalse(r1.isTriggeringEvent(f, null));
56 }
57
58 @Test public void testRollOnStartUpNoFile() throws IOException {
59 final File f = new File(getDirectory(), "foo");
60
61 final RollOnStartUp<Object> r1 = new RollOnStartUp<Object>();
62 assertFalse(r1.isTriggeringEvent(f, null));
63 }
64
65 @Test public void testRollOnStartUpEmptyFile() throws IOException {
66 final File f = new File(getDirectory(), "foo");
67 f.createNewFile();
68
69 final RollOnStartUp<Object> r1 = new RollOnStartUp<Object>();
70 assertFalse(r1.isTriggeringEvent(f, null));
71 }
72 }