Polishing
This commit is contained in:
@@ -54,14 +54,14 @@ public class MessageBrokerRegistry {
|
||||
@Nullable
|
||||
private String userDestinationPrefix;
|
||||
|
||||
private boolean preservePublishOrder;
|
||||
|
||||
@Nullable
|
||||
private PathMatcher pathMatcher;
|
||||
|
||||
@Nullable
|
||||
private Integer cacheLimit;
|
||||
|
||||
private boolean preservePublishOrder;
|
||||
|
||||
|
||||
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel) {
|
||||
Assert.notNull(clientInboundChannel, "Inbound channel must not be null");
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Unit tests for SimpleBrokerMessageHandler.
|
||||
* Unit tests for {@link SimpleBrokerMessageHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
@@ -141,7 +141,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void connect() {
|
||||
|
||||
String id = "sess1";
|
||||
|
||||
Message<String> connectMessage = startSession(id);
|
||||
@@ -157,9 +156,7 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void heartbeatValueWithAndWithoutTaskScheduler() {
|
||||
|
||||
assertNull(this.messageHandler.getHeartbeatValue());
|
||||
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
|
||||
assertNotNull(this.messageHandler.getHeartbeatValue());
|
||||
@@ -175,7 +172,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void startAndStopWithHeartbeatValue() {
|
||||
|
||||
ScheduledFuture future = mock(ScheduledFuture.class);
|
||||
when(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), eq(15000L))).thenReturn(future);
|
||||
|
||||
@@ -195,7 +191,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void startWithOneZeroHeartbeatValue() {
|
||||
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.setHeartbeatValue(new long[] {0, 10000});
|
||||
this.messageHandler.start();
|
||||
@@ -205,7 +200,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void readInactivity() throws Exception {
|
||||
|
||||
this.messageHandler.setHeartbeatValue(new long[] {0, 1});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
@@ -237,7 +231,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void writeInactivity() throws Exception {
|
||||
|
||||
this.messageHandler.setHeartbeatValue(new long[] {1, 0});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
@@ -269,7 +262,6 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void readWriteIntervalCalculation() throws Exception {
|
||||
|
||||
this.messageHandler.setHeartbeatValue(new long[] {1, 1});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
@@ -294,6 +286,7 @@ public class SimpleBrokerMessageHandlerTests {
|
||||
messages.get(0).getHeaders().get(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER));
|
||||
}
|
||||
|
||||
|
||||
private Message<String> startSession(String id) {
|
||||
this.messageHandler.start();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,8 +65,9 @@ public class ExecutorSubscribableChannelTests {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void messageMustNotBeNull() throws Exception {
|
||||
public void messageMustNotBeNull() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Message must not be null");
|
||||
this.channel.send(null);
|
||||
@@ -84,7 +85,7 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendWithExecutor() throws Exception {
|
||||
public void sendWithExecutor() {
|
||||
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
|
||||
TaskExecutor executor = mock(TaskExecutor.class);
|
||||
ExecutorSubscribableChannel testChannel = new ExecutorSubscribableChannel(executor);
|
||||
@@ -100,7 +101,7 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscribeTwice() throws Exception {
|
||||
public void subscribeTwice() {
|
||||
assertThat(this.channel.subscribe(this.handler), equalTo(true));
|
||||
assertThat(this.channel.subscribe(this.handler), equalTo(false));
|
||||
this.channel.send(this.message);
|
||||
@@ -108,7 +109,7 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unsubscribeTwice() throws Exception {
|
||||
public void unsubscribeTwice() {
|
||||
this.channel.subscribe(this.handler);
|
||||
assertThat(this.channel.unsubscribe(this.handler), equalTo(true));
|
||||
assertThat(this.channel.unsubscribe(this.handler), equalTo(false));
|
||||
@@ -117,7 +118,7 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failurePropagates() throws Exception {
|
||||
public void failurePropagates() {
|
||||
RuntimeException ex = new RuntimeException();
|
||||
willThrow(ex).given(this.handler).handleMessage(this.message);
|
||||
MessageHandler secondHandler = mock(MessageHandler.class);
|
||||
@@ -133,7 +134,7 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void concurrentModification() throws Exception {
|
||||
public void concurrentModification() {
|
||||
this.channel.subscribe(message1 -> channel.unsubscribe(handler));
|
||||
this.channel.subscribe(this.handler);
|
||||
this.channel.send(this.message);
|
||||
@@ -208,8 +209,8 @@ public class ExecutorSubscribableChannelTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterMessageHandled(Message<?> message, MessageChannel channel, MessageHandler handler,
|
||||
Exception ex) {
|
||||
public void afterMessageHandled(
|
||||
Message<?> message, MessageChannel channel, MessageHandler handler, Exception ex) {
|
||||
|
||||
this.afterHandledInvoked = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user