Fix tests

This commit is contained in:
James Agnew 2016-09-26 12:24:54 -04:00
parent 2316a887c2
commit 2c277864f1
1 changed files with 19 additions and 21 deletions

View File

@ -97,6 +97,8 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
avoidRaceCondition();
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
assertThat(captor.getAllValues().get(0), StringContains.containsString("ERROR - GET http://localhost:" + ourPort + "/Patient/EX")); assertThat(captor.getAllValues().get(0), StringContains.containsString("ERROR - GET http://localhost:" + ourPort + "/Patient/EX"));
@ -115,6 +117,8 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
avoidRaceCondition();
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
assertThat(captor.getValue(), StringContains.containsString("metadata - ")); assertThat(captor.getValue(), StringContains.containsString("metadata - "));
@ -134,15 +138,19 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
assertEquals("extended-operation-instance - $everything - Patient/123", captor.getValue()); assertEquals("extended-operation-instance - $everything - Patient/123", captor.getValue());
} }
private void avoidRaceCondition() throws InterruptedException {
// The server finishes the response and closes the connection, then runs the final interceptor so technically
// we could get here before the interceptor has fired
Thread.sleep(100);
}
@Test @Test
public void testRequestBodyRead() throws Exception { public void testRequestBodyRead() throws Exception {
@ -179,9 +187,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
@ -229,9 +235,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpPost); HttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
@ -261,9 +265,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpPost); HttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
@ -284,6 +286,8 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
avoidRaceCondition();
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
assertEquals("extended-operation-server - $everything - ", captor.getValue()); assertEquals("extended-operation-server - $everything - ", captor.getValue());
@ -303,9 +307,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
@ -325,9 +327,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());
@ -348,9 +348,7 @@ public class LoggingInterceptorDstu2Test {
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
// The server finishes the response and closes the connection, then runs the final interceptor so technically avoidRaceCondition();
// we could get here before the interceptor has fired
Thread.sleep(100);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(logger, times(1)).info(captor.capture()); verify(logger, times(1)).info(captor.capture());