INT-3470: Fix SF 4.1 Compatibility

JIRA: https://jira.spring.io/browse/INT-3470

According to the commit https://github.com/spring-projects/spring-framework/commit/c06ac06,
the `MessagingException` is now `NestedRuntimeException` including nested StackTrace.
Hence test-cases have to be changed to the `Mathers.containsString` instead of `equals` for the `e.getMessage()`

**Cherry-pick to the 4.0.x**

Conflicts:
	spring-integration-amqp/src/test/java/org/springframework/integration/amqp/channel/DispatcherHasNoSubscribersTests.java
	spring-integration-core/src/test/java/org/springframework/integration/handler/advice/AdvisedMessageHandlerTests.java
This commit is contained in:
Artem Bilan
2014-08-11 11:19:02 +03:00
parent bd58077528
commit 705be107ca
9 changed files with 65 additions and 27 deletions

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.
@@ -13,14 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.channel;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.messaging.MessageChannel;
@@ -31,6 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*
*/
@@ -57,8 +61,10 @@ public class DispatcherHasNoSubscribersTests {
try {
noSubscribersChannel.send(new GenericMessage<String>("Hello, world!"));
fail("Exception expected");
} catch (MessagingException e) {
assertEquals("Dispatcher has no subscribers for channel 'foo.noSubscribersChannel'.", e.getMessage());
}
catch (MessagingException e) {
assertThat(e.getMessage(),
containsString("Dispatcher has no subscribers for channel 'foo.noSubscribersChannel'."));
}
}
@@ -67,8 +73,10 @@ public class DispatcherHasNoSubscribersTests {
try {
subscribedChannel.send(new GenericMessage<String>("Hello, world!"));
fail("Exception expected");
} catch (MessagingException e) {
assertEquals("Dispatcher has no subscribers for channel 'foo.noSubscribersChannel'.", e.getMessage());
}
catch (MessagingException e) {
assertThat(e.getMessage(),
containsString("Dispatcher has no subscribers for channel 'foo.noSubscribersChannel'."));
}
}
@@ -79,8 +87,10 @@ public class DispatcherHasNoSubscribersTests {
try {
channel.send(new GenericMessage<String>("Hello, world!"));
fail("Exception expected");
} catch (MessagingException e) {
assertEquals("Dispatcher has no subscribers for channel 'bar'.", e.getMessage());
}
catch (MessagingException e) {
assertThat(e.getMessage(),
containsString("Dispatcher has no subscribers for channel 'bar'."));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.channel.registry;
import static org.hamcrest.Matchers.instanceOf;
@@ -179,7 +180,7 @@ public class HeaderChannelRegistryTests {
}
catch (DestinationResolutionException e){
assertThat(e.getMessage(),
Matchers.equalTo("failed to look up MessageChannel with name 'foo' in the BeanFactory."));
Matchers.containsString("failed to look up MessageChannel with name 'foo' in the BeanFactory."));
}
}
@@ -201,7 +202,8 @@ public class HeaderChannelRegistryTests {
}
catch (DestinationResolutionException e){
assertThat(e.getMessage(),
Matchers.equalTo("failed to look up MessageChannel with name 'foo' in the BeanFactory (and there is no HeaderChannelRegistry present)."));
Matchers.containsString("failed to look up MessageChannel with name 'foo' in the BeanFactory " +
"(and there is no HeaderChannelRegistry present)."));
}
}

View File

@@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.handler.advice;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

View File

@@ -16,10 +16,12 @@
package org.springframework.integration.transformer;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -414,7 +416,7 @@ public class ContentEnricherTests {
try {
enricher.handleMessage(requestMessage);
} catch (MessageHandlingException e) {
assertEquals("Failed to clone payload object", e.getMessage());
assertThat(e.getMessage(), containsString("Failed to clone payload object"));
return;
}