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

Last change on this file was 46, checked in by ruud, 20 months ago

Fixed small issues in domaineditor.

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.repository.RunningPartiesRepo;
16import geniusweb.partiesserver.repository.RunningParty;
17
18public class RunningPartiesUpdaterTest {
19 @Test
20 public void smokeTest() throws InterruptedException {
21 RunningPartiesRepo repo = mock(RunningPartiesRepo.class);
22 RunningPartiesUpdater updater = new RunningPartiesUpdater(repo, 100);
23 Thread.sleep(500);
24 }
25
26 @Test
27 public void timeoutTest() throws InterruptedException {
28 RunningPartiesRepo repo = mock(RunningPartiesRepo.class);
29 RunningParty runningparty = mock(RunningParty.class);
30 PartyId id = new PartyId("partyid");
31 when(runningparty.getID()).thenReturn(id);
32 Date soon = new Date(System.currentTimeMillis() + 100);
33 when(runningparty.getEndDate()).thenReturn(soon);
34 Collection<RunningParty> list = new LinkedList<>();
35 list.add(runningparty);
36 when(repo.list()).thenReturn(list);
37 RunningPartiesUpdater updater = new RunningPartiesUpdater(repo, 100);
38 updater.update();
39 verify(repo, times(0)).remove(id);
40 // we also need to account for the kill delay
41 Thread.sleep(400 + RunningPartiesUpdater.KILL_DELAY);
42 updater.update();
43 verify(repo, times(1)).remove(id);
44
45 }
46}
Note: See TracBrowser for help on using the repository browser.