Skip to content

Commit a469b33

Browse files
committed
pause for a moment so duration is definitely !=0
1 parent a811128 commit a469b33

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

web/src/test/java/com/microsoft/applicationinsights/web/internal/httputils/HttpServerHandlerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import org.junit.Rule;
1414
import org.junit.Test;
1515
import org.junit.rules.ExpectedException;
16-
import org.junit.runner.RunWith;
17-
import org.junit.runners.JUnit4;
1816
import org.mockito.InOrder;
1917
import org.mockito.InjectMocks;
2018
import org.mockito.Mock;
@@ -25,14 +23,12 @@
2523
import javax.servlet.http.HttpServletResponse;
2624
import java.net.MalformedURLException;
2725
import java.util.Date;
26+
import java.util.concurrent.TimeUnit;
2827

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.*;
3330
import static org.mockito.Mockito.*;
3431

35-
@RunWith(JUnit4.class)
3632
public class HttpServerHandlerTest {
3733

3834
@Rule public final ExpectedException thrown = ExpectedException.none();
@@ -161,7 +157,11 @@ public void timeStatusCodeAreSetWhenHandleEndIsInvoked() throws MalformedURLExce
161157
assertThat(rt.getUrl().toString(), equalTo(url));
162158
assertThat(rt.getContext().getUser().getUserAgent(), equalTo("User-Agent"));
163159
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+
}
165165
httpServerHandler.handleEnd(request, response, rtc);
166166
// ensure same request telemetry is modified (picked from TLS)
167167
assertThat(rt.getDuration().getTotalMilliseconds(), is(not(0L)));

0 commit comments

Comments
 (0)