source: src/test/java/geniusweb/partiesserver/RunningPartiesUpdaterTest.java@ 1

Last change on this file since 1 was 1, checked in by bart, 5 years ago

Initial Release

File size: 1.5 KB
Line 
1package geniusweb.partiesserver;
2
3import static org.mockito.Mockito.mock;
4import static org.mockito.Mockito.times;
5import static org.mockito.Mockito.verify;
6import static org.mockito.Mockito.when;
7
8import java.util.Collection;
9import java.util.Date;
10import java.util.LinkedList;
11
12import org.junit.Test;
13
14import geniusweb.actions.PartyId;
15import geniusweb.partiesserver.RunningPartiesUpdater;
16import geniusweb.partiesserver.repository.RunningPartiesRepo;
17import geniusweb.partiesserver.repository.RunningParty;
18
19public class RunningPartiesUpdaterTest {
20 @Test
21 public void smokeTest() throws InterruptedException {
22 RunningPartiesRepo repo = mock(RunningPartiesRepo.class);
23 RunningPartiesUpdater updater = new RunningPartiesUpdater(repo, 100);
24 Thread.sleep(500);
25 }
26
27 @Test
28 public void timeoutTest() throws InterruptedException {
29 RunningPartiesRepo repo = mock(RunningPartiesRepo.class);
30 RunningParty runningparty = mock(RunningParty.class);
31 PartyId id = new PartyId("partyid");
32 when(runningparty.getID()).thenReturn(id);
33 Date soon = new Date(System.currentTimeMillis() + 100);
34 when(runningparty.getEndDate()).thenReturn(soon);
35 Collection<RunningParty> list = new LinkedList<>();
36 list.add(runningparty);
37 when(repo.list()).thenReturn(list);
38 RunningPartiesUpdater updater = new RunningPartiesUpdater(repo, 100);
39 updater.update();
40 verify(repo, times(0)).remove(id);
41 Thread.sleep(400 + 2000); // there is 2000 extra kill wait time
42 updater.update();
43 verify(repo, times(1)).remove(id);
44
45 }
46}
Note: See TracBrowser for help on using the repository browser.