Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which will later allow for an easier migration to Mockito's extension for JUnit Jupiter. In addition, this commit deletes unnecessary stubbing for various mocks and polishes test fixture setup in various test classes.
This commit is contained in:
@@ -19,34 +19,25 @@ package org.springframework.messaging.simp;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Unit tests for
|
||||
* {@link org.springframework.messaging.simp.SimpAttributes}.
|
||||
* Unit tests for {@link SimpAttributes}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*/
|
||||
public class SimpAttributesTests {
|
||||
|
||||
private SimpAttributes simpAttributes;
|
||||
private final Map<String, Object> map = new ConcurrentHashMap<>();
|
||||
|
||||
private Map<String, Object> map;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.map = new ConcurrentHashMap<>();
|
||||
this.simpAttributes = new SimpAttributes("session1", this.map);
|
||||
}
|
||||
private final SimpAttributes simpAttributes = new SimpAttributes("session1", this.map);
|
||||
|
||||
|
||||
@Test
|
||||
@@ -69,7 +60,7 @@ public class SimpAttributesTests {
|
||||
|
||||
@Test
|
||||
public void registerDestructionCallback() {
|
||||
Runnable callback = Mockito.mock(Runnable.class);
|
||||
Runnable callback = mock(Runnable.class);
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback);
|
||||
|
||||
assertThat(this.simpAttributes.getAttribute(
|
||||
@@ -80,14 +71,14 @@ public class SimpAttributesTests {
|
||||
public void registerDestructionCallbackAfterSessionCompleted() {
|
||||
this.simpAttributes.sessionCompleted();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.simpAttributes.registerDestructionCallback("name1", Mockito.mock(Runnable.class)))
|
||||
this.simpAttributes.registerDestructionCallback("name1", mock(Runnable.class)))
|
||||
.withMessageContaining("already completed");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDestructionCallback() {
|
||||
Runnable callback1 = Mockito.mock(Runnable.class);
|
||||
Runnable callback2 = Mockito.mock(Runnable.class);
|
||||
Runnable callback1 = mock(Runnable.class);
|
||||
Runnable callback2 = mock(Runnable.class);
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
this.simpAttributes.registerDestructionCallback("name2", callback2);
|
||||
|
||||
@@ -109,8 +100,8 @@ public class SimpAttributesTests {
|
||||
|
||||
@Test
|
||||
public void sessionCompleted() {
|
||||
Runnable callback1 = Mockito.mock(Runnable.class);
|
||||
Runnable callback2 = Mockito.mock(Runnable.class);
|
||||
Runnable callback1 = mock(Runnable.class);
|
||||
Runnable callback2 = mock(Runnable.class);
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
this.simpAttributes.registerDestructionCallback("name2", callback2);
|
||||
|
||||
@@ -122,7 +113,7 @@ public class SimpAttributesTests {
|
||||
|
||||
@Test
|
||||
public void sessionCompletedIsIdempotent() {
|
||||
Runnable callback1 = Mockito.mock(Runnable.class);
|
||||
Runnable callback1 = mock(Runnable.class);
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
|
||||
this.simpAttributes.sessionCompleted();
|
||||
|
||||
@@ -28,11 +28,11 @@ import javax.security.auth.Subject;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
@@ -58,6 +58,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@@ -68,6 +69,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SendToMethodReturnValueHandlerTests {
|
||||
|
||||
private static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8);
|
||||
@@ -75,16 +77,18 @@ public class SendToMethodReturnValueHandlerTests {
|
||||
private static final String PAYLOAD = "payload";
|
||||
|
||||
|
||||
@Mock
|
||||
private MessageChannel messageChannel;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<Message<?>> messageCaptor;
|
||||
|
||||
private SendToMethodReturnValueHandler handler;
|
||||
|
||||
private SendToMethodReturnValueHandler handlerAnnotationNotRequired;
|
||||
|
||||
private SendToMethodReturnValueHandler jsonHandler;
|
||||
|
||||
@Mock private MessageChannel messageChannel;
|
||||
|
||||
@Captor private ArgumentCaptor<Message<?>> messageCaptor;
|
||||
|
||||
private MethodParameter noAnnotationsReturnType = param("handleNoAnnotations");
|
||||
private MethodParameter sendToReturnType = param("handleAndSendTo");
|
||||
private MethodParameter sendToDefaultDestReturnType = param("handleAndSendToDefaultDest");
|
||||
@@ -118,8 +122,6 @@ public class SendToMethodReturnValueHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
|
||||
messagingTemplate.setMessageConverter(new StringMessageConverter());
|
||||
this.handler = new SendToMethodReturnValueHandler(messagingTemplate, true);
|
||||
@@ -319,7 +321,7 @@ public class SendToMethodReturnValueHandlerTests {
|
||||
public void testHeadersToSend() throws Exception {
|
||||
Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null);
|
||||
|
||||
SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class);
|
||||
SimpMessageSendingOperations messagingTemplate = mock(SimpMessageSendingOperations.class);
|
||||
SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false);
|
||||
|
||||
handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, message);
|
||||
@@ -630,10 +632,12 @@ public class SendToMethodReturnValueHandlerTests {
|
||||
|
||||
private static class TestUser implements Principal {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "joe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implies(Subject subject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import reactor.core.publisher.EmitterProcessor;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.FluxProcessor;
|
||||
@@ -74,22 +75,18 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Test fixture for
|
||||
* {@link org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler}.
|
||||
* Test fixture for {@link SimpAnnotationMethodMessageHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SimpAnnotationMethodMessageHandlerTests {
|
||||
|
||||
private static final String TEST_INVALID_VALUE = "invalidValue";
|
||||
|
||||
|
||||
private TestSimpAnnotationMethodMessageHandler messageHandler;
|
||||
|
||||
private TestController testController;
|
||||
|
||||
@Mock
|
||||
private SubscribableChannel channel;
|
||||
|
||||
@@ -99,11 +96,13 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
@Captor
|
||||
private ArgumentCaptor<Object> payloadCaptor;
|
||||
|
||||
private TestSimpAnnotationMethodMessageHandler messageHandler;
|
||||
|
||||
private TestController testController = new TestController();
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.channel);
|
||||
brokerTemplate.setMessageConverter(this.converter);
|
||||
|
||||
@@ -111,8 +110,6 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
this.messageHandler.setApplicationContext(new StaticApplicationContext());
|
||||
this.messageHandler.setValidator(new StringTestValidator(TEST_INVALID_VALUE));
|
||||
this.messageHandler.afterPropertiesSet();
|
||||
|
||||
this.testController = new TestController();
|
||||
}
|
||||
|
||||
|
||||
@@ -287,12 +284,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void listenableFutureFailure() {
|
||||
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
given(this.channel.send(any(Message.class))).willReturn(true);
|
||||
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
|
||||
|
||||
ListenableFutureController controller = new ListenableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
@@ -325,12 +317,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void completableFutureFailure() {
|
||||
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
given(this.channel.send(any(Message.class))).willReturn(true);
|
||||
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
|
||||
|
||||
CompletableFutureController controller = new CompletableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
@@ -363,12 +350,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void monoFailure() {
|
||||
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
given(this.channel.send(any(Message.class))).willReturn(true);
|
||||
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
|
||||
|
||||
ReactiveController controller = new ReactiveController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
@@ -381,12 +363,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void fluxNotHandled() {
|
||||
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
given(this.channel.send(any(Message.class))).willReturn(true);
|
||||
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
|
||||
|
||||
ReactiveController controller = new ReactiveController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.security.Principal;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -49,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
@@ -57,6 +58,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SubscriptionMethodReturnValueHandlerTests {
|
||||
|
||||
public static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8);
|
||||
@@ -64,14 +66,16 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
||||
private static final String PAYLOAD = "payload";
|
||||
|
||||
|
||||
@Mock
|
||||
private MessageChannel messageChannel;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<Message<?>> messageCaptor;
|
||||
|
||||
private SubscriptionMethodReturnValueHandler handler;
|
||||
|
||||
private SubscriptionMethodReturnValueHandler jsonHandler;
|
||||
|
||||
@Mock private MessageChannel messageChannel;
|
||||
|
||||
@Captor private ArgumentCaptor<Message<?>> messageCaptor;
|
||||
|
||||
private MethodParameter subscribeEventReturnType;
|
||||
|
||||
private MethodParameter subscribeEventSendToReturnType;
|
||||
@@ -83,8 +87,6 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
|
||||
messagingTemplate.setMessageConverter(new StringMessageConverter());
|
||||
this.handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
|
||||
@@ -148,7 +150,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
||||
String destination = "/dest";
|
||||
Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);
|
||||
|
||||
MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class);
|
||||
MessageSendingOperations messagingTemplate = mock(MessageSendingOperations.class);
|
||||
SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
|
||||
|
||||
handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);
|
||||
|
||||
@@ -21,9 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
@@ -42,14 +40,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
public class BrokerMessageHandlerTests {
|
||||
|
||||
private TestBrokerMessageHandler handler;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.handler = new TestBrokerMessageHandler();
|
||||
}
|
||||
private final TestBrokerMessageHandler handler = new TestBrokerMessageHandler();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -61,7 +52,6 @@ public class BrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void stopShouldUpdateIsRunning() {
|
||||
|
||||
this.handler.start();
|
||||
assertThat(this.handler.isRunning()).isTrue();
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -56,11 +57,13 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
private SimpleBrokerMessageHandler messageHandler;
|
||||
|
||||
|
||||
@Mock
|
||||
private SubscribableChannel clientInChannel;
|
||||
|
||||
@@ -79,7 +82,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.messageHandler = new SimpleBrokerMessageHandler(
|
||||
this.clientInChannel, this.clientOutChannel, this.brokerChannel, Collections.emptyList());
|
||||
}
|
||||
|
||||
@@ -24,10 +24,11 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
@@ -60,15 +61,17 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DefaultStompSessionTests {
|
||||
|
||||
private DefaultStompSession session;
|
||||
|
||||
private StompHeaders connectHeaders;
|
||||
|
||||
|
||||
@Mock
|
||||
private StompSessionHandler sessionHandler;
|
||||
|
||||
private StompHeaders connectHeaders;
|
||||
|
||||
@Mock
|
||||
private TcpConnection<byte[]> connection;
|
||||
|
||||
@@ -78,9 +81,6 @@ public class DefaultStompSessionTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
this.sessionHandler = mock(StompSessionHandler.class);
|
||||
this.connectHeaders = new StompHeaders();
|
||||
this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders);
|
||||
this.session.setMessageConverter(new StringMessageConverter());
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -50,6 +50,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* User tests for {@link UserRegistryMessageHandler}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UserRegistryMessageHandlerTests {
|
||||
|
||||
private UserRegistryMessageHandler handler;
|
||||
@@ -60,6 +61,7 @@ public class UserRegistryMessageHandlerTests {
|
||||
|
||||
private MessageConverter converter;
|
||||
|
||||
|
||||
@Mock
|
||||
private MessageChannel brokerChannel;
|
||||
|
||||
@@ -69,9 +71,6 @@ public class UserRegistryMessageHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
given(this.brokerChannel.send(any())).willReturn(true);
|
||||
this.converter = new MappingJackson2MessageConverter();
|
||||
|
||||
@@ -95,7 +94,7 @@ public class UserRegistryMessageHandlerTests {
|
||||
@Test
|
||||
public void brokerUnavailableEvent() throws Exception {
|
||||
|
||||
ScheduledFuture future = Mockito.mock(ScheduledFuture.class);
|
||||
ScheduledFuture future = mock(ScheduledFuture.class);
|
||||
given(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), any(Long.class))).willReturn(future);
|
||||
|
||||
BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
|
||||
|
||||
@@ -18,12 +18,12 @@ package org.springframework.messaging.support;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -46,6 +46,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ExecutorSubscribableChannelTests {
|
||||
|
||||
private ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel();
|
||||
@@ -53,18 +54,12 @@ public class ExecutorSubscribableChannelTests {
|
||||
@Mock
|
||||
private MessageHandler handler;
|
||||
|
||||
private final Object payload = new Object();
|
||||
|
||||
private final Message<Object> message = MessageBuilder.withPayload(this.payload).build();
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<Runnable> runnableCaptor;
|
||||
|
||||
private final Object payload = new Object();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
private final Message<Object> message = MessageBuilder.withPayload(this.payload).build();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user