Skip to content

Commit

Permalink
Fix AsyncAppender/SocketAppender unit tests
Browse files Browse the repository at this point in the history
AsyncAppenderBaseTest: The appender was not allowed enough time to
flush the appender on #stop(), causing the empty-check of the appender's
queue to fail. The test appender's max-flush time is now extended from
30ms to >1000ms.

AbstractSocketAppenderIntegrationTest: A unit test expected
deque.takeFirst() to be called only once after a log-event is appended,
but the call actually occurs twice in a while-loop, where the second
call is intended to block, waiting for the next log-event.

AbstractSocketAppenderTest: A unit test that verified appender
behavior when its deque was at capacity neglected to fill the deque
before testing for errors.
  • Loading branch information
tony19 committed Jun 21, 2014
1 parent c4382b3 commit 1688361
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Expand Up @@ -162,7 +162,7 @@ public void invalidQueueCapacityShouldResultInNonStartedAppender() {
@Test
public void workerThreadFlushesOnStop() {
int loopLen = 5;
int maxRuntime = (loopLen + 1) * delayingListAppender.delay;
int maxRuntime = (loopLen + 1) * Math.max(1000, delayingListAppender.delay);
ListAppender la = delayingListAppender;
asyncAppenderBase.addAppender(la);
asyncAppenderBase.setDiscardingThreshold(0);
Expand Down
Expand Up @@ -89,7 +89,7 @@ public void dispatchesEvents() throws Exception {
instrumentedAppender.append("some event");

// wait for event to be taken from deque and being written into the stream
verify(deque, timeout(TIMEOUT)).takeFirst();
verify(deque, timeout(TIMEOUT).atLeastOnce()).takeFirst();
verify(objectWriter, timeout(TIMEOUT)).write("some event");

// then
Expand Down
Expand Up @@ -392,11 +392,16 @@ public void addsInfoMessageWhenEventIsBeingDroppedBecauseOfConnectionProblemAndD

// given
doThrow(new IOException()).when(objectWriter).write(anyObject());
doThrow(new IllegalStateException()).when(deque).offerFirst("some event");
appender.start();
awaitStartOfEventDispatching();
reset(appender);

// fill up deque
int max = deque.remainingCapacity();
for (int i = 0; i < max; i++) {
deque.offer(""+i);
}

// when
appender.append("some event");

Expand Down

0 comments on commit 1688361

Please sign in to comment.