INT-3717: Fix QueueChannelTests Race Condition
JIRA: https://jira.spring.io/browse/INT-3717 **Cherry-pick to 4.1.x and 4.0.x**
This commit is contained in:
@@ -16,16 +16,10 @@
|
||||
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -35,16 +29,12 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.selector.UnexpiredMessageSelector;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
@@ -64,10 +54,6 @@ public class QueueChannelTests {
|
||||
final AtomicBoolean messageReceived = new AtomicBoolean(false);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
Log logger = spy(TestUtils.getPropertyValue(channel, "logger", Log.class));
|
||||
when(logger.isDebugEnabled()).thenReturn(true);
|
||||
when(logger.isTraceEnabled()).thenReturn(true);
|
||||
new DirectFieldAccessor(channel).setPropertyValue("logger", logger);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -82,12 +68,6 @@ public class QueueChannelTests {
|
||||
channel.send(new GenericMessage<String>("testing"));
|
||||
latch.await(1000, TimeUnit.MILLISECONDS);
|
||||
assertTrue(messageReceived.get());
|
||||
ArgumentCaptor<String> preCaptor = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<String> postCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(logger).trace(preCaptor.capture());
|
||||
verify(logger, times(3)).debug(postCaptor.capture());
|
||||
assertThat(preCaptor.getValue(), startsWith("preReceive"));
|
||||
assertThat(postCaptor.getValue(), startsWith("postReceive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user