Changeset 45fe238


Ignore:
Timestamp:
Jul 27, 2015 11:50:01 AM (5 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
843e2a8
Parents:
e704bad
Message:

Refactor SchedulerDead? tests

Location:
apps/streaming/java/test/junit/net/i2p/client/streaming/impl
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/test/junit/net/i2p/client/streaming/impl/SchedulerDeadTest.java

    re704bad r45fe238  
    77import org.mockito.Mock;
    88
    9 public class SchedulerDeadTest extends SchedulerImplTestBase {
     9public class SchedulerDeadTest extends TaskSchedulerTestBase {
    1010
    11     private SchedulerDead s;
    1211    @Mock private Connection con;
    1312    @Mock private ConnectionOptions opts;
    1413
    15     protected void initScheduler() {
    16         s = new SchedulerDead(context);
    17     }
    18 
    19     @Test
    20     public void testAccept_null() {
    21         assertFalse(s.accept(null));
     14    protected TaskScheduler createScheduler() {
     15        return new SchedulerDead(context);
    2216    }
    2317
     
    3428    public void testAccept_nothingLeftToDo() {
    3529        setMocks(10*60*1000, 9*60*1000 - Connection.DISCONNECT_TIMEOUT, 0, 0, 0);
    36         assertTrue(s.accept(con));
     30        assertTrue(scheduler.accept(con));
    3731    }
    3832
     
    4034    public void testAccept_noDisconnectScheduled() {
    4135        setMocks(10*60*1000, 0, 0, 0, 0);
    42         assertFalse(s.accept(con));
     36        assertFalse(scheduler.accept(con));
    4337    }
    4438
     
    4640    public void testAccept_timedOut() {
    4741        setMocks(0, 0, Connection.DISCONNECT_TIMEOUT/2, Connection.DISCONNECT_TIMEOUT, 0);
    48         assertTrue(s.accept(con));
     42        assertTrue(scheduler.accept(con));
    4943    }
    5044
    5145    @Test
    5246    public void testEventOccurred() {
    53         s.eventOccurred(con);
     47        scheduler.eventOccurred(con);
    5448        verify(con).disconnectComplete();
    5549    }
  • apps/streaming/java/test/junit/net/i2p/client/streaming/impl/TaskSchedulerTestBase.java

    re704bad r45fe238  
    11package net.i2p.client.streaming.impl;
    22
    3 import static org.hamcrest.Matchers.*;
    4 import static org.junit.Assert.*;
     3import static org.junit.Assert.assertFalse;
    54import static org.mockito.Mockito.*;
    65import net.i2p.I2PAppContext;
     
    1615import org.mockito.junit.MockitoRule;
    1716
    18 public abstract class SchedulerImplTestBase {
     17public abstract class TaskSchedulerTestBase {
    1918
    2019    @Rule
     
    2524    @Mock protected SimpleTimer2 timer;
    2625
    27     protected SchedulerDead scheduler;
     26    protected TaskScheduler scheduler;
    2827
    2928    @Before
     
    3231        when(context.simpleTimer2()).thenReturn(timer);
    3332
    34         initScheduler();
     33        scheduler = createScheduler();
    3534    }
    3635
    37     protected abstract void initScheduler();
     36    protected abstract TaskScheduler createScheduler();
     37
     38    @Test
     39    public void testAccept_null() {
     40        assertFalse(scheduler.accept(null));
     41    }
    3842}
Note: See TracChangeset for help on using the changeset viewer.