INT-1263, more MessageHistory changes FTP, SFTP etc.

This commit is contained in:
Oleg Zhurakousky
2010-09-23 09:45:01 -04:00
parent 47befb16f3
commit 32efbae90d
25 changed files with 213 additions and 112 deletions

View File

@@ -33,5 +33,9 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-test</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -67,6 +67,10 @@ public class ApplicationEventInboundChannelAdapter extends MessageProducerSuppor
private void sendEventAsMessage(ApplicationEvent event) {
this.sendMessage(MessageBuilder.withPayload(event).build());
}
public String getComponentType(){
return "event:inbound-channel-adapter";
}
@Override
protected void doStart() {

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import java.util.Set;
import junit.framework.Assert;
@@ -36,6 +37,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.event.ApplicationEventInboundChannelAdapter;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -98,7 +100,10 @@ public class EventInboundChannelAdapterParserTests {
context.publishEvent(new SampleEvent("hello"));
Message<?> message = channel.receive(0);
MessageHistory history = MessageHistory.read(message);
assertTrue(history.containsComponent("eventAdapterSimple"));
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "eventAdapterSimple", 0);
assertNotNull(componentHistoryRecord);
assertEquals("event:inbound-channel-adapter", componentHistoryRecord.get("type"));
assertNotNull(message);
assertEquals(SampleEvent.class, message.getPayload().getClass());
}

View File

@@ -50,8 +50,7 @@ public class ChannelPublishingJmsMessageListener extends MessagingGatewaySupport
implements SessionAwareMessageListener<javax.jms.Message>, InitializingBean {
private volatile boolean expectReply;
private volatile String componentType = "jms:inbound-gateway";
private volatile MessageConverter messageConverter = new SimpleMessageConverter();
private volatile boolean extractRequestPayload = true;
@@ -73,11 +72,13 @@ public class ChannelPublishingJmsMessageListener extends MessagingGatewaySupport
private volatile JmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
public String getComponentType(){
return componentType;
}
void setComponentType(String componentType){
this.componentType = componentType;
if (expectReply){
return "jms:inbound-gateway";
} else {
return "jms:message-driven-channel-adapter";
}
}
/**
* Specify whether a JMS reply Message is expected.
*/

View File

@@ -54,7 +54,6 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
this.listenerContainer.afterPropertiesSet();
}
listener.setComponentName(this.getComponentName());
listener.setComponentType("jms:message-driven-channel-adapter");
}
@Override

View File

@@ -26,13 +26,11 @@ import java.util.Properties;
import javax.jms.DeliveryMode;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.HistoryWritingMessagePostProcessor;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
import org.springframework.integration.test.util.TestUtils;

View File

@@ -99,5 +99,9 @@ public class RmiInboundGateway extends RemotingInboundGatewaySupport implements
}
super.onInit();
}
public String getComponentType(){
return "rmi:inbound-gateway";
}
}

View File

@@ -34,11 +34,13 @@ import org.springframework.integration.rmi.RmiInboundGateway;
public class RmiInboundGatewayParserTests {
@Test
public void gatewayWithDefaults() {
public void gatewayWithDefaultsAndHistory() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
MessageChannel channel = (MessageChannel) context.getBean("testChannel");
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithDefaults");
assertEquals("gatewayWithDefaults", gateway.getComponentName());
assertEquals("rmi:inbound-gateway", gateway.getComponentType());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(true, accessor.getPropertyValue("expectReply"));
assertEquals(channel, accessor.getPropertyValue("requestChannel"));

View File

@@ -9,6 +9,8 @@
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/rmi
http://www.springframework.org/schema/integration/rmi/spring-integration-rmi.xsd">
<message-history/>
<channel id="testChannel"/>

View File

@@ -1,19 +1,18 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import org.springframework.beans.factory.InitializingBean;

View File

@@ -1,19 +1,18 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import com.jcraft.jsch.ChannelSftp;

View File

@@ -1,19 +1,18 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import com.jcraft.jsch.ChannelSftp;

View File

@@ -1,19 +1,18 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import com.jcraft.jsch.ChannelSftp;

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;

View File

@@ -1,19 +1,18 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
/**

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.config;

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.config;

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2010 the original author or authors
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.config;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.impl;
import com.jcraft.jsch.ChannelSftp;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.impl;
import com.jcraft.jsch.ChannelSftp;
@@ -96,4 +111,7 @@ public class SftpInboundRemoteFileSystemSynchronizingMessageSource extends Abstr
this.checkThatRemotePathExists(this.remotePath);
this.synchronizer.setClientPool(this.clientPool);
}
public String getComponentType(){
return "sftp:inbound-channel-adapter";
}
}

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp.impl;
import com.jcraft.jsch.ChannelSftp;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import org.springframework.integration.annotation.ServiceActivator;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -77,8 +77,6 @@ public class XsltTransformerTests {
build();
input.send(message);
Message<?> resultMessage = output.receive();
MessageHistory history = MessageHistory.read(resultMessage);
assertTrue(history.containsComponent("paramHeadersWithEndWildCharacter"));
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
@@ -92,8 +90,6 @@ public class XsltTransformerTests {
build();
input.send(message);
Message<?> resultMessage = output.receive();
MessageHistory history = MessageHistory.read(resultMessage);
assertTrue(history.containsComponent("paramHeadersWithIndividualParameters"));
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
@@ -109,8 +105,6 @@ public class XsltTransformerTests {
build();
input.send(message);
Message<?> resultMessage = output.receive();
MessageHistory history = MessageHistory.read(resultMessage);
assertTrue(history.containsComponent("paramHeadersComboChannel"));
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));