Fix test class name and protect debug log message

This commit is contained in:
Rossen Stoyanchev 2014-07-10 15:55:27 -04:00
parent 670c216d38
commit f8e4547228
2 changed files with 8 additions and 14 deletions

View File

@ -147,7 +147,9 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
message = interceptor.preSend(message, channel);
if (message == null) {
String name = interceptor.getClass().getSimpleName();
logger.debug(name + " returned null from preSend, i.e. precluding the send.");
if (logger.isDebugEnabled()) {
logger.debug(name + " returned null from preSend, i.e. precluding the send.");
}
triggerAfterSendCompletion(message, channel, false, null);
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -28,19 +28,17 @@ import org.springframework.core.task.TaskExecutor;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.MessageBuilder;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
/**
* Tests for {@link ExecutorSubscribableChannel}.
* Unit tests for {@link ExecutorSubscribableChannel}.
*
* @author Phillip Webb
*/
public class PublishSubscribeChannelTests {
public class ExecutorSubscribableChannelTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@ -117,20 +115,14 @@ public class PublishSubscribeChannelTests {
this.channel.send(message);
}
catch (MessageDeliveryException actualException) {
assertThat((RuntimeException) actualException.getCause(), equalTo(ex));
assertThat(actualException.getCause(), equalTo(ex));
}
verifyZeroInteractions(secondHandler);
}
@Test
public void concurrentModification() throws Exception {
this.channel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
channel.unsubscribe(handler);
}
});
this.channel.subscribe(message1 -> channel.unsubscribe(handler));
this.channel.subscribe(this.handler);
this.channel.send(this.message);
verify(this.handler).handleMessage(this.message);