Browse Source

Polishing

pull/24251/head
Sam Brannen 6 years ago
parent
commit
1b4fd1cba1
  1. 2
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java
  2. 8
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java
  3. 3
      spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java
  4. 8
      spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java
  5. 1
      spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java
  6. 1
      spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java
  7. 3
      spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java
  8. 3
      spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java
  9. 3
      spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java
  10. 3
      spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java
  11. 35
      spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java
  12. 27
      spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java
  13. 40
      spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java
  14. 3
      spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java

2
spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java

@ -154,7 +154,7 @@ public abstract class AbstractEncoderMethodReturnValueHandler implements Handler
} }
Encoder<?> encoder = getEncoder(elementType, mimeType); Encoder<?> encoder = getEncoder(elementType, mimeType);
return Flux.from((Publisher) publisher).map(value -> return Flux.from(publisher).map(value ->
encodeValue(value, elementType, encoder, bufferFactory, mimeType, hints)); encodeValue(value, elementType, encoder, bufferFactory, mimeType, hints));
} }

8
spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java

@ -566,14 +566,6 @@ public abstract class AbstractMethodMessageHandler<T>
this.handlerMethod = handlerMethod; this.handlerMethod = handlerMethod;
} }
public T getMapping() {
return this.mapping;
}
public HandlerMethod getHandlerMethod() {
return this.handlerMethod;
}
@Override @Override
public String toString() { public String toString() {
return this.mapping.toString(); return this.mapping.toString();

3
spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -541,6 +541,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
} }
@Override @Override
@SuppressWarnings("rawtypes")
public TypedValue read(EvaluationContext context, @Nullable Object target, String name) { public TypedValue read(EvaluationContext context, @Nullable Object target, String name) {
Object value; Object value;
if (target instanceof Message) { if (target instanceof Message) {

8
spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java

@ -215,6 +215,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
} }
} }
@SuppressWarnings("unused")
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@ -223,6 +224,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
return this.id; return this.id;
} }
@SuppressWarnings("unused")
public void setUserMap(Map<String, TransferSimpUser> users) { public void setUserMap(Map<String, TransferSimpUser> users) {
this.users = users; this.users = users;
} }
@ -297,6 +299,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
} }
} }
@SuppressWarnings("unused")
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@ -328,6 +331,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
return null; return null;
} }
@SuppressWarnings("unused")
public void setSessions(Set<TransferSimpSession> sessions) { public void setSessions(Set<TransferSimpSession> sessions) {
this.sessions.addAll(sessions); this.sessions.addAll(sessions);
} }
@ -407,6 +411,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
} }
} }
@SuppressWarnings("unused")
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@ -425,6 +430,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
return this.user; return this.user;
} }
@SuppressWarnings("unused")
public void setSubscriptions(Set<TransferSimpSubscription> subscriptions) { public void setSubscriptions(Set<TransferSimpSubscription> subscriptions) {
this.subscriptions.addAll(subscriptions); this.subscriptions.addAll(subscriptions);
} }
@ -487,6 +493,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
this.destination = subscription.getDestination(); this.destination = subscription.getDestination();
} }
@SuppressWarnings("unused")
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@ -505,6 +512,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
return this.session; return this.session;
} }
@SuppressWarnings("unused")
public void setDestination(String destination) { public void setDestination(String destination) {
this.destination = destination; this.destination = destination;
} }

1
spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java

@ -51,6 +51,7 @@ public class HeaderMethodArgumentResolverTests {
@BeforeEach @BeforeEach
@SuppressWarnings("resource")
public void setup() { public void setup() {
GenericApplicationContext context = new GenericApplicationContext(); GenericApplicationContext context = new GenericApplicationContext();
context.refresh(); context.refresh();

1
spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java

@ -53,6 +53,7 @@ public class HeaderMethodArgumentResolverTests {
@BeforeEach @BeforeEach
@SuppressWarnings("resource")
public void setup() { public void setup() {
GenericApplicationContext context = new GenericApplicationContext(); GenericApplicationContext context = new GenericApplicationContext();
context.refresh(); context.refresh();

3
spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/StubArgumentResolver.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,7 +64,6 @@ public class StubArgumentResolver implements HandlerMethodArgumentResolver {
return parameter.getParameterType().equals(this.valueType); return parameter.getParameterType().equals(this.valueType);
} }
@SuppressWarnings("unchecked")
@Override @Override
public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) { public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message) {
this.resolvedParameters.add(parameter); this.resolvedParameters.add(parameter);

3
spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/TestReturnValueHandler.java

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.messaging.handler.invocation.reactive; package org.springframework.messaging.handler.invocation.reactive;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -44,7 +45,7 @@ public class TestReturnValueHandler implements HandlerMethodReturnValueHandler {
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public Mono<Void> handleReturnValue(@Nullable Object value, MethodParameter returnType, Message<?> message) { public Mono<Void> handleReturnValue(@Nullable Object value, MethodParameter returnType, Message<?> message) {
return value instanceof Publisher ? return value instanceof Publisher ?
new ChannelSendOperator((Publisher) value, this::saveValue) : new ChannelSendOperator((Publisher) value, this::saveValue) :

3
spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java

@ -237,6 +237,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
private String withoutView; private String withoutView;
@SuppressWarnings("unused")
public String getWithView1() { public String getWithView1() {
return withView1; return withView1;
} }
@ -245,6 +246,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
this.withView1 = withView1; this.withView1 = withView1;
} }
@SuppressWarnings("unused")
public String getWithView2() { public String getWithView2() {
return withView2; return withView2;
} }
@ -253,6 +255,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
this.withView2 = withView2; this.withView2 = withView2;
} }
@SuppressWarnings("unused")
public String getWithoutView() { public String getWithoutView() {
return withoutView; return withoutView;
} }

3
spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java

@ -180,8 +180,8 @@ public class SimpleBrokerMessageHandlerTests {
this.messageHandler::start); this.messageHandler::start);
} }
@SuppressWarnings("unchecked")
@Test @Test
@SuppressWarnings("rawtypes")
public void startAndStopWithHeartbeatValue() { public void startAndStopWithHeartbeatValue() {
ScheduledFuture future = mock(ScheduledFuture.class); ScheduledFuture future = mock(ScheduledFuture.class);
given(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), eq(15000L))).willReturn(future); given(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), eq(15000L))).willReturn(future);
@ -199,7 +199,6 @@ public class SimpleBrokerMessageHandlerTests {
verifyNoMoreInteractions(future); verifyNoMoreInteractions(future);
} }
@SuppressWarnings("unchecked")
@Test @Test
public void startWithOneZeroHeartbeatValue() { public void startWithOneZeroHeartbeatValue() {
this.messageHandler.setTaskScheduler(this.taskScheduler); this.messageHandler.setTaskScheduler(this.taskScheduler);

35
spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.messaging.simp.stomp; package org.springframework.messaging.simp.stomp;
import java.util.ArrayList; import java.util.ArrayList;
@ -46,11 +47,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
/** /**
* Unit tests for StompBrokerRelayMessageHandler. * Unit tests for {@link StompBrokerRelayMessageHandler}.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class StompBrokerRelayMessageHandlerTests { class StompBrokerRelayMessageHandlerTests {
private StompBrokerRelayMessageHandler brokerRelay; private StompBrokerRelayMessageHandler brokerRelay;
@ -60,7 +61,7 @@ public class StompBrokerRelayMessageHandlerTests {
@BeforeEach @BeforeEach
public void setup() { void setup() {
this.outboundChannel = new StubMessageChannel(); this.outboundChannel = new StubMessageChannel();
@ -80,7 +81,7 @@ public class StompBrokerRelayMessageHandlerTests {
@Test @Test
public void virtualHost() throws Exception { void virtualHost() {
this.brokerRelay.setVirtualHost("ABC"); this.brokerRelay.setVirtualHost("ABC");
@ -101,7 +102,7 @@ public class StompBrokerRelayMessageHandlerTests {
} }
@Test @Test
public void loginAndPasscode() throws Exception { void loginAndPasscode() {
this.brokerRelay.setSystemLogin("syslogin"); this.brokerRelay.setSystemLogin("syslogin");
this.brokerRelay.setSystemPasscode("syspasscode"); this.brokerRelay.setSystemPasscode("syspasscode");
@ -125,7 +126,7 @@ public class StompBrokerRelayMessageHandlerTests {
} }
@Test @Test
public void destinationExcluded() throws Exception { void destinationExcluded() {
this.brokerRelay.start(); this.brokerRelay.start();
@ -141,7 +142,7 @@ public class StompBrokerRelayMessageHandlerTests {
} }
@Test @Test
public void messageFromBrokerIsEnriched() throws Exception { void messageFromBrokerIsEnriched() {
this.brokerRelay.start(); this.brokerRelay.start();
this.brokerRelay.handleMessage(connectMessage("sess1", "joe")); this.brokerRelay.handleMessage(connectMessage("sess1", "joe"));
@ -161,7 +162,7 @@ public class StompBrokerRelayMessageHandlerTests {
// SPR-12820 // SPR-12820
@Test @Test
public void connectWhenBrokerNotAvailable() throws Exception { void connectWhenBrokerNotAvailable() {
this.brokerRelay.start(); this.brokerRelay.start();
this.brokerRelay.stopInternal(); this.brokerRelay.stopInternal();
@ -176,7 +177,7 @@ public class StompBrokerRelayMessageHandlerTests {
} }
@Test @Test
public void sendAfterBrokerUnavailable() throws Exception { void sendAfterBrokerUnavailable() {
this.brokerRelay.start(); this.brokerRelay.start();
assertThat(this.brokerRelay.getConnectionCount()).isEqualTo(1); assertThat(this.brokerRelay.getConnectionCount()).isEqualTo(1);
@ -197,7 +198,8 @@ public class StompBrokerRelayMessageHandlerTests {
} }
@Test @Test
public void systemSubscription() throws Exception { @SuppressWarnings("rawtypes")
void systemSubscription() {
MessageHandler handler = mock(MessageHandler.class); MessageHandler handler = mock(MessageHandler.class);
this.brokerRelay.setSystemSubscriptions(Collections.singletonMap("/topic/foo", handler)); this.brokerRelay.setSystemSubscriptions(Collections.singletonMap("/topic/foo", handler));
@ -247,18 +249,7 @@ public class StompBrokerRelayMessageHandlerTests {
private static ListenableFutureTask<Void> getVoidFuture() { private static ListenableFutureTask<Void> getVoidFuture() {
ListenableFutureTask<Void> futureTask = new ListenableFutureTask<>(new Callable<Void>() { ListenableFutureTask<Void> futureTask = new ListenableFutureTask<>(new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() {
return null;
}
});
futureTask.run();
return futureTask;
}
private static ListenableFutureTask<Boolean> getBooleanFuture() {
ListenableFutureTask<Boolean> futureTask = new ListenableFutureTask<>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return null; return null;
} }
}); });

27
spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java

@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -39,25 +38,17 @@ import static org.mockito.Mockito.mock;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class MultiServerUserRegistryTests { class MultiServerUserRegistryTests {
private SimpUserRegistry localRegistry; private final SimpUserRegistry localRegistry = Mockito.mock(SimpUserRegistry.class);
private MultiServerUserRegistry registry; private final MultiServerUserRegistry registry = new MultiServerUserRegistry(this.localRegistry);
private MessageConverter converter; private final MessageConverter converter = new MappingJackson2MessageConverter();
@BeforeEach
public void setup() throws Exception {
this.localRegistry = Mockito.mock(SimpUserRegistry.class);
this.registry = new MultiServerUserRegistry(this.localRegistry);
this.converter = new MappingJackson2MessageConverter();
}
@Test @Test
public void getUserFromLocalRegistry() throws Exception { void getUserFromLocalRegistry() {
SimpUser user = Mockito.mock(SimpUser.class); SimpUser user = Mockito.mock(SimpUser.class);
Set<SimpUser> users = Collections.singleton(user); Set<SimpUser> users = Collections.singleton(user);
given(this.localRegistry.getUsers()).willReturn(users); given(this.localRegistry.getUsers()).willReturn(users);
@ -69,7 +60,7 @@ public class MultiServerUserRegistryTests {
} }
@Test @Test
public void getUserFromRemoteRegistry() throws Exception { void getUserFromRemoteRegistry() {
// Prepare broadcast message from remote server // Prepare broadcast message from remote server
TestSimpUser testUser = new TestSimpUser("joe"); TestSimpUser testUser = new TestSimpUser("joe");
TestSimpSession testSession = new TestSimpSession("remote-sess"); TestSimpSession testSession = new TestSimpSession("remote-sess");
@ -100,7 +91,7 @@ public class MultiServerUserRegistryTests {
} }
@Test @Test
public void findSubscriptionsFromRemoteRegistry() throws Exception { void findSubscriptionsFromRemoteRegistry() {
// Prepare broadcast message from remote server // Prepare broadcast message from remote server
TestSimpUser user1 = new TestSimpUser("joe"); TestSimpUser user1 = new TestSimpUser("joe");
TestSimpUser user2 = new TestSimpUser("jane"); TestSimpUser user2 = new TestSimpUser("jane");
@ -133,7 +124,7 @@ public class MultiServerUserRegistryTests {
} }
@Test // SPR-13800 @Test // SPR-13800
public void getSessionsWhenUserIsConnectedToMultipleServers() throws Exception { void getSessionsWhenUserIsConnectedToMultipleServers() {
// Add user to local registry // Add user to local registry
TestSimpUser localUser = new TestSimpUser("joe"); TestSimpUser localUser = new TestSimpUser("joe");
TestSimpSession localSession = new TestSimpSession("sess123"); TestSimpSession localSession = new TestSimpSession("sess123");
@ -169,7 +160,7 @@ public class MultiServerUserRegistryTests {
} }
@Test @Test
public void purgeExpiredRegistries() throws Exception { void purgeExpiredRegistries() {
// Prepare broadcast message from remote server // Prepare broadcast message from remote server
TestSimpUser testUser = new TestSimpUser("joe"); TestSimpUser testUser = new TestSimpUser("joe");
testUser.addSessions(new TestSimpSession("remote-sub")); testUser.addSessions(new TestSimpSession("remote-sub"));

40
spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java

@ -18,7 +18,6 @@ package org.springframework.messaging.simp.user;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -41,31 +40,22 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.springframework.messaging.simp.SimpMessageHeaderAccessor.ORIGINAL_DESTINATION; import static org.springframework.messaging.simp.SimpMessageHeaderAccessor.ORIGINAL_DESTINATION;
/** /**
* Unit tests for * Unit tests for {@link UserDestinationMessageHandler}.
* {@link org.springframework.messaging.simp.user.UserDestinationMessageHandler}.
*/ */
public class UserDestinationMessageHandlerTests { class UserDestinationMessageHandlerTests {
private static final String SESSION_ID = "123"; private static final String SESSION_ID = "123";
private UserDestinationMessageHandler handler; private final SimpUserRegistry registry = mock(SimpUserRegistry.class);
private SimpUserRegistry registry; private final SubscribableChannel brokerChannel = mock(SubscribableChannel.class);
private SubscribableChannel brokerChannel; private final UserDestinationMessageHandler handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, new DefaultUserDestinationResolver(this.registry));
@BeforeEach
public void setup() {
this.registry = mock(SimpUserRegistry.class);
this.brokerChannel = mock(SubscribableChannel.class);
UserDestinationResolver resolver = new DefaultUserDestinationResolver(this.registry);
this.handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, resolver);
}
@Test @Test
public void handleSubscribe() { @SuppressWarnings("rawtypes")
void handleSubscribe() {
given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);
this.handler.handleMessage(createWith(SimpMessageType.SUBSCRIBE, "joe", SESSION_ID, "/user/queue/foo")); this.handler.handleMessage(createWith(SimpMessageType.SUBSCRIBE, "joe", SESSION_ID, "/user/queue/foo"));
@ -77,7 +67,8 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void handleUnsubscribe() { @SuppressWarnings("rawtypes")
void handleUnsubscribe() {
given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);
this.handler.handleMessage(createWith(SimpMessageType.UNSUBSCRIBE, "joe", "123", "/user/queue/foo")); this.handler.handleMessage(createWith(SimpMessageType.UNSUBSCRIBE, "joe", "123", "/user/queue/foo"));
@ -89,7 +80,8 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void handleMessage() { @SuppressWarnings("rawtypes")
void handleMessage() {
TestSimpUser simpUser = new TestSimpUser("joe"); TestSimpUser simpUser = new TestSimpUser("joe");
simpUser.addSessions(new TestSimpSession("123")); simpUser.addSessions(new TestSimpSession("123"));
given(this.registry.getUser("joe")).willReturn(simpUser); given(this.registry.getUser("joe")).willReturn(simpUser);
@ -105,7 +97,8 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void handleMessageWithoutActiveSession() { @SuppressWarnings("rawtypes")
void handleMessageWithoutActiveSession() {
this.handler.setBroadcastDestination("/topic/unresolved"); this.handler.setBroadcastDestination("/topic/unresolved");
given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);
this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", "/user/joe/queue/foo")); this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", "/user/joe/queue/foo"));
@ -125,7 +118,8 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void handleMessageFromBrokerWithActiveSession() { @SuppressWarnings("rawtypes")
void handleMessageFromBrokerWithActiveSession() {
TestSimpUser simpUser = new TestSimpUser("joe"); TestSimpUser simpUser = new TestSimpUser("joe");
simpUser.addSessions(new TestSimpSession("123")); simpUser.addSessions(new TestSimpSession("123"));
given(this.registry.getUser("joe")).willReturn(simpUser); given(this.registry.getUser("joe")).willReturn(simpUser);
@ -153,7 +147,7 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void handleMessageFromBrokerWithoutActiveSession() { void handleMessageFromBrokerWithoutActiveSession() {
this.handler.setBroadcastDestination("/topic/unresolved"); this.handler.setBroadcastDestination("/topic/unresolved");
given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true); given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);
@ -170,7 +164,7 @@ public class UserDestinationMessageHandlerTests {
} }
@Test @Test
public void ignoreMessage() { void ignoreMessage() {
// no destination // no destination
this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", null)); this.handler.handleMessage(createWith(SimpMessageType.MESSAGE, "joe", "123", null));

3
spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java

@ -89,8 +89,8 @@ public class UserRegistryMessageHandlerTests {
assertThat(runnable).isNotNull(); assertThat(runnable).isNotNull();
} }
@SuppressWarnings("unchecked")
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void brokerUnavailableEvent() throws Exception { public void brokerUnavailableEvent() throws Exception {
ScheduledFuture future = mock(ScheduledFuture.class); ScheduledFuture future = mock(ScheduledFuture.class);
@ -106,6 +106,7 @@ public class UserRegistryMessageHandlerTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void broadcastRegistry() throws Exception { public void broadcastRegistry() throws Exception {
given(this.brokerChannel.send(any())).willReturn(true); given(this.brokerChannel.send(any())).willReturn(true);

Loading…
Cancel
Save