INT-2275: any outbound-channel-adapter in <chain>

Add re-init logic for nested chains
Add logic about nested element for AbstractChannelAdapterParser
Refactor of DefaultOutboundChannelAdapterParser
Test for non-last nested chain with some outbound-channel-adapter
Improve XSD for chain-type
Manual outbound-channel-adapter ability for chain
Integration tests for all outbound-channel-adapter within <chain>
Remove redundant 'return-value-required' attribute from <stored-proc-outbound-channel-adapter>
Add support 'expectReply' for FileWritingMessageHandler

INT-2275 polishing & refactor FileOutbound*Parser

HttpRequestExecutingMessageHandlerTests polishing

INT-2275: polishing JavaDoc
This commit is contained in:
Artem Bilan
2012-01-03 23:26:16 +02:00
committed by Oleg Zhurakousky
parent 4d5b8d5be1
commit 45c429ee2b
58 changed files with 1302 additions and 318 deletions

View File

@@ -24,6 +24,13 @@
object-name="test.publisher:name=publisher"
default-notification-type="default.type"/>
<si:chain input-channel="publishingWithinChainChannel">
<jmx:notification-publishing-channel-adapter
object-name="test.publisher:name=publisher-chain"
default-notification-type="default.type"/>
</si:chain>
<bean id="testListener" class="org.springframework.integration.jmx.config.TestListener"/>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -35,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Artem Bilan
* @since 2.0
*/
@ContextConfiguration
@@ -47,6 +48,9 @@ public class NotificationPublishingChannelAdapterParserTests {
@Autowired
private TestListener listener;
@Autowired
private MessageChannel publishingWithinChainChannel;
@After
public void clearListener() {
listener.lastNotification = null;
@@ -54,7 +58,7 @@ public class NotificationPublishingChannelAdapterParserTests {
@Test
public void publishStringMessag() throws Exception {
public void publishStringMessage() throws Exception {
assertNull(listener.lastNotification);
Message<?> message = MessageBuilder.withPayload("XYZ")
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
@@ -90,7 +94,18 @@ public class NotificationPublishingChannelAdapterParserTests {
assertEquals("default.type", notification.getType());
}
@Test //INT-2275
public void publishStringMessageWithinChain() throws Exception {
assertNull(listener.lastNotification);
Message<?> message = MessageBuilder.withPayload("XYZ")
.setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build();
publishingWithinChainChannel.send(message);
assertNotNull(listener.lastNotification);
Notification notification = listener.lastNotification;
assertEquals("XYZ", notification.getMessage());
assertEquals("test.type", notification.getType());
assertNull(notification.getUserData());
}
private static class TestData {
}

View File

@@ -20,6 +20,22 @@
object-name="org.springframework.integration.jmx.config:type=TestBean,name=testBeanAdapter"
operation-name="test"/>
<jmx:operation-invoking-channel-adapter id="operationWithNonNullReturn"
object-name="org.springframework.integration.jmx.config:type=TestBean,name=testBeanAdapter"
operation-name="testWithReturn"/>
<bean id="testBeanAdapter" class="org.springframework.integration.jmx.config.TestBean"/>
<si:chain input-channel="operationInvokingWithinChain">
<jmx:operation-invoking-channel-adapter
object-name="org.springframework.integration.jmx.config:type=TestBean,name=testBeanAdapter"
operation-name="test"/>
</si:chain>
<si:chain input-channel="operationWithinChainWithNonNullReturn">
<jmx:operation-invoking-channel-adapter
object-name="org.springframework.integration.jmx.config:type=TestBean,name=testBeanAdapter"
operation-name="testWithReturn"/>
</si:chain>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -17,6 +17,8 @@
package org.springframework.integration.jmx.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Test;
@@ -24,6 +26,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.jmx.JmxHeaders;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
@@ -33,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Artem Bilan
* @since 2.0
*/
@ContextConfiguration
@@ -42,6 +46,15 @@ public class OperationInvokingChannelAdapterParserTests {
@Autowired
private MessageChannel input;
@Autowired
private MessageChannel operationWithNonNullReturn;
@Autowired
private MessageChannel operationInvokingWithinChain;
@Autowired
private MessageChannel operationWithinChainWithNonNullReturn;
@Autowired
private TestBean testBean;
@@ -59,7 +72,19 @@ public class OperationInvokingChannelAdapterParserTests {
input.send(new GenericMessage<String>("test3"));
assertEquals(3, testBean.messages.size());
}
@Test
public void testOutboundAdapterWithNonNullReturn() throws Exception {
try {
operationWithNonNullReturn.send(new GenericMessage<String>("test1"));
fail("Expect MessagingException about non-null return");
}
catch (Exception e) {
assertTrue(e instanceof MessagingException);
// TODO Add check exception's message about 'must have a void return' after <jmx:operation-invoking-channel-adapter/> refactoring
}
}
@Test
// Headers should be ignored
public void adapterWitJmxHeaders() throws Exception {
@@ -69,7 +94,25 @@ public class OperationInvokingChannelAdapterParserTests {
input.send(this.createMessage("3"));
assertEquals(3, testBean.messages.size());
}
@Test //INT-2275
public void testInvokeOperationWithinChain() throws Exception {
operationInvokingWithinChain.send(new GenericMessage<String>("test1"));
assertEquals(1, testBean.messages.size());
}
@Test //INT-2275
public void testOperationWithinChainWithNonNullReturn() throws Exception {
try {
operationWithinChainWithNonNullReturn.send(new GenericMessage<String>("test1"));
fail("Expect MessagingException about non-null return");
}
catch (Exception e) {
assertTrue(e instanceof MessagingException);
// TODO Add check exception's message about 'must have a void return' after <jmx:operation-invoking-channel-adapter/> refactoring
}
}
private Message<?> createMessage(String payload){
return MessageBuilder.withPayload(payload)
.setHeader(JmxHeaders.OBJECT_NAME, "org.springframework.integration.jmx.config:type=TestBean,name=foo")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -26,6 +26,7 @@ import org.springframework.jmx.support.ObjectNameManager;
/**
* @author Mark Fisher
* @author Artem Bilan
* @since 2.0
*/
public class TestListener implements NotificationListener, BeanFactoryAware {
@@ -37,6 +38,8 @@ public class TestListener implements NotificationListener, BeanFactoryAware {
try {
server.addNotificationListener(
ObjectNameManager.getInstance("test.publisher:name=publisher"), this, null, null);
server.addNotificationListener(
ObjectNameManager.getInstance("test.publisher:name=publisher-chain"), this, null, null);
}
catch (Exception e) {
throw new IllegalArgumentException(e);