Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 24, 2018
1 parent 2e4f5a7 commit 90d395e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import static org.mockito.Mockito.*;

/**
* Unit tests for SimpleBrokerMessageHandler.
* Unit tests for {@link SimpleBrokerMessageHandler}.
*
* @author Rossen Stoyanchev
* @since 4.0
Expand Down Expand Up @@ -141,7 +141,6 @@ public void subscribeDisconnectPublish() {

@Test
public void connect() {

String id = "sess1";

Message<String> connectMessage = startSession(id);
Expand All @@ -157,9 +156,7 @@ public void connect() {

@Test
public void heartbeatValueWithAndWithoutTaskScheduler() {

assertNull(this.messageHandler.getHeartbeatValue());

this.messageHandler.setTaskScheduler(this.taskScheduler);

assertNotNull(this.messageHandler.getHeartbeatValue());
Expand All @@ -175,7 +172,6 @@ public void startWithHeartbeatValueWithoutTaskScheduler() {
@SuppressWarnings("unchecked")
@Test
public void startAndStopWithHeartbeatValue() {

ScheduledFuture future = mock(ScheduledFuture.class);
when(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), eq(15000L))).thenReturn(future);

Expand All @@ -195,7 +191,6 @@ public void startAndStopWithHeartbeatValue() {
@SuppressWarnings("unchecked")
@Test
public void startWithOneZeroHeartbeatValue() {

this.messageHandler.setTaskScheduler(this.taskScheduler);
this.messageHandler.setHeartbeatValue(new long[] {0, 10000});
this.messageHandler.start();
Expand All @@ -205,7 +200,6 @@ public void startWithOneZeroHeartbeatValue() {

@Test
public void readInactivity() throws Exception {

this.messageHandler.setHeartbeatValue(new long[] {0, 1});
this.messageHandler.setTaskScheduler(this.taskScheduler);
this.messageHandler.start();
Expand Down Expand Up @@ -237,7 +231,6 @@ public void readInactivity() throws Exception {

@Test
public void writeInactivity() throws Exception {

this.messageHandler.setHeartbeatValue(new long[] {1, 0});
this.messageHandler.setTaskScheduler(this.taskScheduler);
this.messageHandler.start();
Expand Down Expand Up @@ -269,7 +262,6 @@ public void writeInactivity() throws Exception {

@Test
public void readWriteIntervalCalculation() throws Exception {

this.messageHandler.setHeartbeatValue(new long[] {1, 1});
this.messageHandler.setTaskScheduler(this.taskScheduler);
this.messageHandler.start();
Expand All @@ -294,6 +286,7 @@ public void readWriteIntervalCalculation() throws Exception {
messages.get(0).getHeaders().get(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER));
}


private Message<String> startSession(String id) {
this.messageHandler.start();

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -65,8 +65,9 @@ public void setup() {
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);
Expand All @@ -84,7 +85,7 @@ public void sendWithoutExecutor() {
}

@Test
public void sendWithExecutor() throws Exception {
public void sendWithExecutor() {
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
TaskExecutor executor = mock(TaskExecutor.class);
ExecutorSubscribableChannel testChannel = new ExecutorSubscribableChannel(executor);
Expand All @@ -100,15 +101,15 @@ public void sendWithExecutor() throws Exception {
}

@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);
verify(this.handler, times(1)).handleMessage(this.message);
}

@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));
Expand All @@ -117,7 +118,7 @@ public void unsubscribeTwice() throws Exception {
}

@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);
Expand All @@ -133,7 +134,7 @@ public void failurePropagates() throws Exception {
}

@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);
Expand Down Expand Up @@ -208,8 +209,8 @@ public Message<?> beforeHandle(Message<?> message, MessageChannel channel, Messa
}

@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;
}
Expand Down

0 comments on commit 90d395e

Please sign in to comment.