diff --git a/solr/core/src/test/org/apache/solr/util/TimeOutTest.java b/solr/core/src/test/org/apache/solr/util/TimeOutTest.java index d6defa00c95..b316affa2be 100644 --- a/solr/core/src/test/org/apache/solr/util/TimeOutTest.java +++ b/solr/core/src/test/org/apache/solr/util/TimeOutTest.java @@ -23,42 +23,41 @@ import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.util.TimeSource; import org.junit.BeforeClass; +import org.junit.Test; public class TimeOutTest extends SolrTestCaseJ4 { + private static TimeSource mockTimeSource; @BeforeClass public static void setUpOnce() { assumeWorkingMockito(); + mockTimeSource = mock(TimeSource.class); } + @Test public void testHasTimedOut() { - TimeSource mockTimeSource = mock(TimeSource.class); when(mockTimeSource.getTimeNs()).thenReturn(Long.valueOf(10)).thenReturn(Long.valueOf(50)); - TimeOut timeOut = new TimeOut(20, NANOSECONDS, mockTimeSource); assertTrue(timeOut.hasTimedOut()); } + @Test public void testHasNotTimedOut() { - TimeSource mockTimeSource = mock(TimeSource.class); when(mockTimeSource.getTimeNs()).thenReturn(Long.valueOf(10)).thenReturn(Long.valueOf(11)); - TimeOut timeOut = new TimeOut(20, NANOSECONDS, mockTimeSource); assertFalse(timeOut.hasTimedOut()); } + @Test public void testTimeLeft() { - TimeSource mockTimeSource = mock(TimeSource.class); when(mockTimeSource.getTimeNs()).thenReturn(Long.valueOf(10)).thenReturn(Long.valueOf(15)); - TimeOut timeOut = new TimeOut(90, NANOSECONDS, mockTimeSource); assertEquals(timeOut.timeLeft(NANOSECONDS), 85); } + @Test public void testTimeElapsed() { - TimeSource mockTimeSource = mock(TimeSource.class); when(mockTimeSource.getTimeNs()).thenReturn(Long.valueOf(10)).thenReturn(Long.valueOf(25)); - TimeOut timeOut = new TimeOut(70, NANOSECONDS, mockTimeSource); assertEquals(timeOut.timeElapsed(NANOSECONDS), 15); }