|
13 | 13 | import org.junit.Rule; |
14 | 14 | import org.junit.Test; |
15 | 15 | import org.junit.rules.ExpectedException; |
16 | | -import org.junit.runner.RunWith; |
17 | | -import org.junit.runners.JUnit4; |
18 | 16 | import org.mockito.InOrder; |
19 | 17 | import org.mockito.InjectMocks; |
20 | 18 | import org.mockito.Mock; |
|
25 | 23 | import javax.servlet.http.HttpServletResponse; |
26 | 24 | import java.net.MalformedURLException; |
27 | 25 | import java.util.Date; |
| 26 | +import java.util.concurrent.TimeUnit; |
28 | 27 |
|
29 | | -import static org.hamcrest.CoreMatchers.*; |
30 | | -import static org.hamcrest.MatcherAssert.assertThat; |
31 | | -import static org.hamcrest.core.Is.is; |
32 | | -import static org.hamcrest.core.StringContains.containsString; |
| 28 | +import static org.hamcrest.Matchers.*; |
| 29 | +import static org.junit.Assert.*; |
33 | 30 | import static org.mockito.Mockito.*; |
34 | 31 |
|
35 | | -@RunWith(JUnit4.class) |
36 | 32 | public class HttpServerHandlerTest { |
37 | 33 |
|
38 | 34 | @Rule public final ExpectedException thrown = ExpectedException.none(); |
@@ -161,7 +157,11 @@ public void timeStatusCodeAreSetWhenHandleEndIsInvoked() throws MalformedURLExce |
161 | 157 | assertThat(rt.getUrl().toString(), equalTo(url)); |
162 | 158 | assertThat(rt.getContext().getUser().getUserAgent(), equalTo("User-Agent")); |
163 | 159 | assertThat(rt.getTimestamp(), is(CoreMatchers.<Date>notNullValue())); |
164 | | - |
| 160 | + try { |
| 161 | + TimeUnit.MILLISECONDS.sleep(100); // pause for a moment |
| 162 | + } catch (InterruptedException e) { |
| 163 | + Thread.currentThread().interrupt(); |
| 164 | + } |
165 | 165 | httpServerHandler.handleEnd(request, response, rtc); |
166 | 166 | // ensure same request telemetry is modified (picked from TLS) |
167 | 167 | assertThat(rt.getDuration().getTotalMilliseconds(), is(not(0L))); |
|
0 commit comments