Fix failing tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -29,29 +27,33 @@ import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext(classMode= DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class GatewayInvokingMessageHandlerTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("inputA")
|
||||
SubscribableChannel channel;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("simpleGateway")
|
||||
SimpleGateway gateway;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayWithError")
|
||||
SimpleGateway gatewayWithError;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayWithErrorAsync")
|
||||
SimpleGateway gatewayWithErrorAsync;
|
||||
@@ -77,7 +79,7 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateGatewayInTheChainViaAnotherGateway() {
|
||||
public void validateGatewayInTheChainViaAnotherGateway() {
|
||||
output.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Assert.assertEquals("echo:echo:echo:hello", message.getPayload());
|
||||
@@ -88,9 +90,9 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
String result = gateway.process("hello");
|
||||
Assert.assertEquals("echo:echo:echo:hello", result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void validateGatewayWithErrorMessageReturned() {
|
||||
public void validateGatewayWithErrorMessageReturned() {
|
||||
try {
|
||||
String result = gatewayWithErrorChannelAndTransformer.process("echoWithRuntimeExceptionChannel");
|
||||
Assert.assertNotNull(result);
|
||||
@@ -99,7 +101,7 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
catch (Exception e) {
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
gatewayWithError.process("echoWithRuntimeExceptionChannel");
|
||||
Assert.fail();
|
||||
@@ -107,7 +109,7 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
catch (SampleRuntimeException e) {
|
||||
Assert.assertEquals("echoWithRuntimeExceptionChannel", e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
gatewayWithError.process("echoWithMessagingExceptionChannel");
|
||||
Assert.fail();
|
||||
@@ -115,7 +117,7 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
catch (MessageHandlingException e) {
|
||||
Assert.assertEquals("echoWithMessagingExceptionChannel", e.getFailedMessage().getPayload());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
String result = gatewayWithErrorChannelAndTransformer.process("echoWithMessagingExceptionChannel");
|
||||
Assert.assertNotNull(result);
|
||||
@@ -125,9 +127,9 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void validateGatewayWithErrorAsync() {
|
||||
public void validateGatewayWithErrorAsync() {
|
||||
try {
|
||||
gatewayWithErrorAsync.process("echoWithErrorAsyncChannel");
|
||||
Assert.fail();
|
||||
@@ -136,9 +138,9 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
Assert.assertEquals(SampleRuntimeException.class, e.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void validateGatewayWithErrorFlowReturningMessage() {
|
||||
public void validateGatewayWithErrorFlowReturningMessage() {
|
||||
try {
|
||||
Object result = gatewayWithErrorChannelAndTransformer.process("echoWithErrorAsyncChannel");
|
||||
Assert.assertEquals("Error happened in message: echoWithErrorAsyncChannel", result);
|
||||
@@ -151,10 +153,10 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
|
||||
public static class SampleErrorTransformer {
|
||||
public Message<?> toMessage(Throwable object) throws Exception {
|
||||
MessageHandlingException ex = (MessageHandlingException) object;
|
||||
MessageHandlingException ex = (MessageHandlingException) object;
|
||||
return MessageBuilder.withPayload("Error happened in message: " + ex.getFailedMessage().getPayload()).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +197,7 @@ public class GatewayInvokingMessageHandlerTests {
|
||||
public static class SampleRuntimeException extends RuntimeException {
|
||||
public SampleRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -29,6 +29,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -47,6 +49,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext(classMode= DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class SplitterIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user