Some various upgrades, fixes and refactoring
* Upgrade to SA and SF snapshots * Address TODOs regarding those upgrades * Resolve some other TODOs * Replace `PropertyPlaceholderConfigurer` beans with the `<context:property-placeholder>` * Upgrade to Spring Social Twitter 1.1.2 and resolve deprecations via mocks (https://github.com/spring-projects/spring-social-twitter/issues/91) * Upgrade to Curator `3.1.0` and resolve deprecation in the `ZookeeperMetadataStore`
This commit is contained in:
23
build.gradle
23
build.gradle
@@ -88,7 +88,7 @@ subprojects { subproject ->
|
||||
|
||||
|
||||
ext {
|
||||
activeMqVersion = '5.12.2'
|
||||
activeMqVersion = '5.13.2'
|
||||
aspectjVersion = '1.8.9'
|
||||
apacheSshdVersion = '0.14.0'
|
||||
boonVersion = '0.33'
|
||||
@@ -96,11 +96,11 @@ subprojects { subproject ->
|
||||
commonsDbcpVersion = '1.4'
|
||||
commonsIoVersion = '2.4'
|
||||
commonsNetVersion = '3.4'
|
||||
curatorVersion = '2.8.0'
|
||||
curatorVersion = '3.1.0'
|
||||
derbyVersion = '10.11.1.1'
|
||||
eclipseLinkVersion = '2.5.2'
|
||||
ftpServerVersion = '1.0.6'
|
||||
groovyVersion = '2.4.5'
|
||||
groovyVersion = '2.4.6'
|
||||
guavaVersion = '19.0'
|
||||
hamcrestVersion = '1.3'
|
||||
hazelcastVersion = '3.6.1'
|
||||
@@ -127,28 +127,26 @@ subprojects { subproject ->
|
||||
openJpaVersion = '2.4.0'
|
||||
pahoMqttClientVersion = '1.0.2'
|
||||
postgresVersion = '9.1-901-1.jdbc4'
|
||||
reactorVersion = '2.0.7.RELEASE'
|
||||
reactorVersion = '2.0.8.RELEASE'
|
||||
romeToolsVersion = '1.5.0'
|
||||
saajApiVersion = '1.3.5'
|
||||
saajImplVersion = '1.3.23'
|
||||
servletApiVersion = '3.1.0'
|
||||
slf4jVersion = "1.7.21"
|
||||
tomcatVersion = "8.0.33"
|
||||
smackVersion = '4.1.6'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.0.M2'
|
||||
smackVersion = '4.1.7'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.0.BUILD-SNAPSHOT'
|
||||
// springCloudClusterVersion = '1.0.0.BUILD-SNAPSHOT'
|
||||
springDataJpaVersion = '1.10.1.RELEASE'
|
||||
springDataMongoVersion = '1.9.1.RELEASE'
|
||||
springDataRedisVersion = '1.7.1.RELEASE'
|
||||
springGemfireVersion = '1.8.1.RELEASE'
|
||||
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '4.0.3.RELEASE'
|
||||
springSocialTwitterVersion = '1.1.1.RELEASE'
|
||||
springSocialTwitterVersion = '1.1.2.RELEASE'
|
||||
springRetryVersion = '1.1.2.RELEASE'
|
||||
springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.0.RC1'
|
||||
springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.0.BUILD-SNAPSHOT'
|
||||
springWsVersion = '2.3.0.RELEASE'
|
||||
xmlUnitVersion = '1.6'
|
||||
xstreamVersion = '1.4.7'
|
||||
zookeeperVersion = '3.4.7'
|
||||
zookeeperVersion = '3.4.8'
|
||||
}
|
||||
|
||||
eclipse {
|
||||
@@ -682,9 +680,6 @@ project('spring-integration-ws') {
|
||||
testCompile "javax.mail:javax.mail-api:$javaxMailVersion"
|
||||
testRuntime "com.sun.mail:mailapi:$javaxMailVersion"
|
||||
}
|
||||
|
||||
// suppress saaj path warnings
|
||||
[compileJava,compileTestJava]*.options*.compilerArgs = ["${xLintArg},-path"]
|
||||
}
|
||||
|
||||
project('spring-integration-xml') {
|
||||
|
||||
@@ -398,7 +398,6 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
}
|
||||
|
||||
private SimpleMessageListenerContainer createContainer() throws Exception {
|
||||
//if (!messageDriven) TODO: no container attributes would apply if not message-driven
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
|
||||
if (this.acknowledgeMode != null) {
|
||||
container.setAcknowledgeMode(this.acknowledgeMode);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class AmqpInboundGatewayParserTests {
|
||||
Address expected = new Address("fooExchange/barRoutingKey");
|
||||
assertEquals(expected.getExchangeName(), defaultReplyTo.getExchangeName());
|
||||
assertEquals(expected.getRoutingKey(), defaultReplyTo.getRoutingKey());
|
||||
//TODO Address.equals() when IO goes to Spring AMQP 1.5.0.RELEASE
|
||||
assertEquals(expected, defaultReplyTo);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DefaultAmqpHeaderMapperTests {
|
||||
headerMap.put(AmqpHeaders.CONTENT_ENCODING, "test.contentEncoding");
|
||||
headerMap.put(AmqpHeaders.CONTENT_LENGTH, 99L);
|
||||
headerMap.put(AmqpHeaders.CONTENT_TYPE, "test.contentType");
|
||||
byte[] testCorrelationId = new byte[] {1, 2, 3};
|
||||
byte[] testCorrelationId = new byte[] { 1, 2, 3 };
|
||||
headerMap.put(AmqpHeaders.CORRELATION_ID, testCorrelationId);
|
||||
headerMap.put(AmqpHeaders.DELAY, 1234);
|
||||
headerMap.put(AmqpHeaders.DELIVERY_MODE, MessageDeliveryMode.NON_PERSISTENT);
|
||||
@@ -158,7 +158,7 @@ public class DefaultAmqpHeaderMapperTests {
|
||||
amqpProperties.setContentEncoding("test.contentEncoding");
|
||||
amqpProperties.setContentLength(99L);
|
||||
amqpProperties.setContentType("test.contentType");
|
||||
byte[] testCorrelationId = new byte[] {1, 2, 3};
|
||||
byte[] testCorrelationId = new byte[] { 1, 2, 3 };
|
||||
amqpProperties.setCorrelationId(testCorrelationId);
|
||||
amqpProperties.setReceivedDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
|
||||
amqpProperties.setDeliveryTag(1234L);
|
||||
@@ -200,20 +200,15 @@ public class DefaultAmqpHeaderMapperTests {
|
||||
assertEquals("test.replyTo2", headerMap.get(AmqpHeaders.SPRING_REPLY_TO_STACK));
|
||||
}
|
||||
|
||||
@Test // INT-3586 requires Spring AMQP 1.4.2
|
||||
@Test
|
||||
public void testToHeadersConsumerMetadata() {
|
||||
try {
|
||||
DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
|
||||
MessageProperties amqpProperties = new MessageProperties();
|
||||
amqpProperties.setConsumerTag("consumerTag");
|
||||
amqpProperties.setConsumerQueue("consumerQueue");
|
||||
Map<String, Object> headerMap = headerMapper.toHeadersFromRequest(amqpProperties);
|
||||
assertEquals("consumerTag", headerMap.get(AmqpHeaders.CONSUMER_TAG));
|
||||
assertEquals("consumerQueue", headerMap.get(AmqpHeaders.CONSUMER_QUEUE));
|
||||
}
|
||||
catch (NoSuchMethodError e) {
|
||||
// TODO: temporary for Spring IO Compatibility build - until Spring IO 1.1.x moves to amqp 1.4.2
|
||||
}
|
||||
DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.inboundMapper();
|
||||
MessageProperties amqpProperties = new MessageProperties();
|
||||
amqpProperties.setConsumerTag("consumerTag");
|
||||
amqpProperties.setConsumerQueue("consumerQueue");
|
||||
Map<String, Object> headerMap = headerMapper.toHeadersFromRequest(amqpProperties);
|
||||
assertEquals("consumerTag", headerMap.get(AmqpHeaders.CONSUMER_TAG));
|
||||
assertEquals("consumerQueue", headerMap.get(AmqpHeaders.CONSUMER_QUEUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -490,7 +490,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
"] has no eligible methods for handling Messages.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
//TODO backward compatibility
|
||||
//TODO backward compatibility. Remove in 5.0
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,9 @@
|
||||
<selector ref="selector6"/>
|
||||
</selector-chain>
|
||||
</selector-chain>
|
||||
|
||||
<!-- TODO INT-547
|
||||
|
||||
<selector id="pojoSelector" ref="pojoSelectorBean" method="accept"/>
|
||||
-->
|
||||
|
||||
|
||||
<beans:bean id="pojoSelectorBean" class="org.springframework.integration.config.SelectorChainParserTests$StubPojoSelector"/>
|
||||
|
||||
<beans:bean id="selector1" class="org.springframework.integration.config.SelectorChainParserTests$StubMessageSelector"/>
|
||||
|
||||
@@ -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.
|
||||
@@ -56,6 +56,7 @@ public class SelectorChainParserTests {
|
||||
assertEquals(selector1, selectors.get(0));
|
||||
assertEquals(selector2, selectors.get(1));
|
||||
assertTrue(chain.accept(new GenericMessage<String>("test")));
|
||||
assertTrue(this.context.containsBean("pojoSelector"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -213,7 +213,6 @@ public class MessagingGatewayTests {
|
||||
}
|
||||
}).when(requestChannel).send(Mockito.any(Message.class), Mockito.anyLong());
|
||||
|
||||
// TODO: commenting the next line causes the test to hang
|
||||
this.messagingGateway.setReplyTimeout(100L);
|
||||
Message<?> receiveMessage = this.messagingGateway.sendAndReceiveMessage("test");
|
||||
assertSame(messageMock, receiveMessage);
|
||||
|
||||
@@ -286,8 +286,7 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
@Test
|
||||
public void testProcessMessageBadExpression() throws Exception {
|
||||
// TODO: should this be MessageHandlingException or NumberFormatException?
|
||||
expected.expect(new ExceptionCauseMatcher(Exception.class));
|
||||
expected.expect(MessageHandlingException.class);
|
||||
AnnotatedTestService service = new AnnotatedTestService();
|
||||
Method method = service.getClass().getMethod("integerMethod", Integer.class);
|
||||
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(service, method);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- under test -->
|
||||
<bean id="pollableFileSource" class="org.springframework.integration.file.FileReadingMessageSource"
|
||||
@@ -23,6 +23,4 @@
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- under test -->
|
||||
<bean id="pollableFileSource" class="org.springframework.integration.file.FileReadingMessageSource"
|
||||
@@ -21,6 +21,4 @@
|
||||
value="#{T(System).getProperty('java.io.tmpdir') + T(java.io.File).separator + 'FileReadingMessageSourcePersistentFilterIntegrationTests.meta'}"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:file="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:si="http://www.springframework.org/schema/integration" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/util
|
||||
http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<!-- under test -->
|
||||
<file:inbound-channel-adapter
|
||||
@@ -28,9 +33,12 @@
|
||||
<bean class="org.springframework.integration.file.filters.CompositeFileListFilter" id="compositeFilter">
|
||||
<constructor-arg>
|
||||
<util:list>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean" p:preventDuplicates="true"/>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean" p:preventDuplicates="false"/>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean" p:filenamePattern="test*"/>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean"
|
||||
p:preventDuplicates="true"/>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean"
|
||||
p:preventDuplicates="false"/>
|
||||
<bean class="org.springframework.integration.file.config.FileListFilterFactoryBean"
|
||||
p:filenamePattern="test*"/>
|
||||
</util:list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
@@ -39,18 +47,17 @@
|
||||
<si:transactional synchronization-factory="syncFactory"/>
|
||||
</si:poller>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
<si:channel id="resultChannel">
|
||||
<si:queue />
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>
|
||||
|
||||
|
||||
<bean id="syncFactory" class="org.springframework.integration.transaction.DefaultTransactionSynchronizationFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.transaction.ExpressionEvaluatingTransactionSynchronizationProcessor">
|
||||
<property name="afterCommitExpression" value="#{new org.springframework.expression.spel.standard.SpelExpressionParser().parseExpression('payload.delete()')}"/>
|
||||
<property name="afterCommitExpression"
|
||||
value="#{new org.springframework.expression.spel.standard.SpelExpressionParser().parseExpression('payload.delete()')}"/>
|
||||
<property name="afterCommitChannel" ref="resultChannel"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
|
||||
@@ -3,12 +3,17 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
<inbound-channel-adapter id="inputDirPoller"
|
||||
directory="${java.io.tmpdir}"
|
||||
@@ -42,8 +47,6 @@
|
||||
</beans:constructor-arg>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
<beans:bean id="testComparator"
|
||||
class="org.springframework.integration.file.config.FileInboundChannelAdapterParserTests$TestComparator"/>
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
<context:property-placeholder/>
|
||||
|
||||
<inbound-channel-adapter id="adapterWithPattern"
|
||||
directory="file:${java.io.tmpdir}"
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
<context:property-placeholder/>
|
||||
|
||||
<integration:channel id="channel">
|
||||
<integration:queue/>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
<inbound-channel-adapter id="inputDirPoller"
|
||||
directory="${java.io.tmpdir}/FileInboundChannelAdapterWithQueueSizeTests"
|
||||
@@ -23,8 +29,6 @@
|
||||
</beans:constructor-arg>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
<beans:bean id="testComparator"
|
||||
class="org.springframework.integration.file.config.FileInboundChannelAdapterParserTests$TestComparator" />
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration/file"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
<context:property-placeholder/>
|
||||
|
||||
<inbound-channel-adapter id="adapterWithRegexPattern"
|
||||
directory="file:${java.io.tmpdir}"
|
||||
|
||||
@@ -21,6 +21,4 @@
|
||||
<bean id="filter1" class="org.springframework.integration.file.locking.NioFileLocker"/>
|
||||
<bean id="filter2" class="org.springframework.integration.file.locking.NioFileLocker"/>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
http://www.springframework.org/schema/integration/file
|
||||
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
<inbound-channel-adapter id="fileSource"
|
||||
directory="#{directory.root}"
|
||||
auto-startup="true"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.file.recursive;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
|
||||
@@ -67,15 +68,13 @@ public class FileInboundChannelAdapterWithRecursiveDirectoryTests {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test(timeout = 10000)
|
||||
public void shouldReturnFilesMultipleLevels() throws IOException {
|
||||
|
||||
//when
|
||||
File folder = directory.newFolder("foo");
|
||||
File siblingFile = directory.newFile("bar");
|
||||
File childFile = new File(folder, "baz");
|
||||
assertTrue(childFile.createNewFile());
|
||||
|
||||
List<Message> received = Arrays.asList((Message) files.receive(), files.receive());
|
||||
//verify
|
||||
//TODO assertThat(received, hasItems(hasPayload(siblingFile), hasPayload(childFile)));
|
||||
assertThat(received, containsInAnyOrder(hasPayload(siblingFile), hasPayload(childFile)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -28,6 +28,7 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.test.matcher.HeaderMatcher;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.file.FileHeaders;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
@@ -35,6 +36,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFilePayloadTransformer<?>> {
|
||||
|
||||
@@ -72,17 +74,14 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
|
||||
message = MessageBuilder.fromMessage(message).setHeader(anyKey, anyValue).build();
|
||||
Message<?> result = transformer.transform(message);
|
||||
assertThat(result, is(notNullValue()));
|
||||
// TODO: refactor to header matcher
|
||||
assertThat(result.getHeaders().get(anyKey, String.class), is(anyValue));
|
||||
assertThat(result, HeaderMatcher.hasHeader(anyKey, anyValue));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform_withFilePayload_filenameInHeaders() throws Exception {
|
||||
Message<?> result = transformer.transform(message);
|
||||
assertThat(result, is(notNullValue()));
|
||||
// TODO: refactor to header matcher
|
||||
assertThat(result.getHeaders().get(FileHeaders.FILENAME, String.class),
|
||||
is(sourceFile.getName()));
|
||||
assertThat(result, HeaderMatcher.hasHeader(FileHeaders.FILENAME, sourceFile.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -20,6 +20,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.messaging.Message;
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FileToByteArrayTransformerTests extends
|
||||
AbstractFilePayloadTransformerTests<FileToByteArrayTransformer> {
|
||||
@@ -42,9 +44,9 @@ public class FileToByteArrayTransformerTests extends
|
||||
public void transform_withFilePayload_convertedToByteArray() throws Exception {
|
||||
Message<?> result = transformer.transform(message);
|
||||
assertThat(result, is(notNullValue()));
|
||||
// TODO: refactor to payload matcher
|
||||
assertThat(result.getPayload(), is(instanceOf(byte[].class)));
|
||||
assertThat((byte[]) result.getPayload(), is(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING)));
|
||||
|
||||
assertThat(result, hasPayload(is(instanceOf(byte[].class))));
|
||||
assertThat(result, hasPayload(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -18,9 +18,10 @@ package org.springframework.integration.file.transformer;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class FileToStringTransformerTests extends
|
||||
AbstractFilePayloadTransformerTests<FileToStringTransformer> {
|
||||
@@ -43,9 +45,8 @@ public class FileToStringTransformerTests extends
|
||||
public void transform_withFilePayload_convertedToString() throws Exception {
|
||||
Message<?> result = transformer.transform(message);
|
||||
assertThat(result, is(notNullValue()));
|
||||
// TODO: refactor to payload matcher
|
||||
assertThat(result.getPayload(), is(instanceOf(String.class)));
|
||||
assertThat((String) result.getPayload(), is(SAMPLE_CONTENT));
|
||||
assertThat(result, hasPayload(instanceOf(String.class)));
|
||||
assertThat(result, hasPayload(SAMPLE_CONTENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,9 +54,8 @@ public class FileToStringTransformerTests extends
|
||||
transformer.setCharset("ISO-8859-1");
|
||||
Message<?> result = transformer.transform(message);
|
||||
assertThat(result, is(notNullValue()));
|
||||
// TODO: refactor to payload matcher
|
||||
assertThat(result.getPayload(), is(instanceOf(String.class)));
|
||||
assertThat((String) result.getPayload(), is(not(SAMPLE_CONTENT)));
|
||||
assertThat(result, hasPayload(instanceOf(String.class)));
|
||||
assertThat(result, hasPayload(not(SAMPLE_CONTENT)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ public class SimpleMultipartFileReader implements MultipartFileReader<Object> {
|
||||
public Object readMultipartFile(MultipartFile multipartFile) throws IOException {
|
||||
if (multipartFile.getContentType() != null && multipartFile.getContentType().startsWith("text")) {
|
||||
MediaType contentType = MediaType.parseMediaType(multipartFile.getContentType());
|
||||
// TODO there is no yet in the SF-4.3.RC1 a MediaType.getCharset() method
|
||||
Charset charset = contentType.getCharSet();
|
||||
Charset charset = contentType.getCharset();
|
||||
if (charset == null) {
|
||||
charset = this.defaultCharset;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -37,8 +36,6 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerExecutionChain;
|
||||
@@ -53,11 +50,6 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||
@DirtiesContext
|
||||
public class CrossOriginTests {
|
||||
|
||||
// SPR-13130
|
||||
private static boolean isSpring43 =
|
||||
ClassUtils.isPresent("org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping$HttpOptionsHandler",
|
||||
CrossOriginTests.class.getClassLoader());
|
||||
|
||||
@Autowired
|
||||
private IntegrationRequestMappingHandlerMapping handlerMapping;
|
||||
|
||||
@@ -101,10 +93,10 @@ public class CrossOriginTests {
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, false);
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(new String[]{"GET"}, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[] { "GET" }, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray());
|
||||
assertTrue(config.getAllowCredentials());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray());
|
||||
assertNull(config.getExposedHeaders());
|
||||
assertEquals(new Long(1800), config.getMaxAge());
|
||||
}
|
||||
@@ -115,10 +107,10 @@ public class CrossOriginTests {
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, false);
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(new String[]{"DELETE"}, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[]{"http://site1.com", "http://site2.com"}, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[]{"header1", "header2"}, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[]{"header3", "header4"}, config.getExposedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "DELETE" }, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[] { "http://site1.com", "http://site2.com" }, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[] { "header1", "header2" }, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "header3", "header4" }, config.getExposedHeaders().toArray());
|
||||
assertEquals(new Long(123), config.getMaxAge());
|
||||
assertEquals(false, config.getAllowCredentials());
|
||||
}
|
||||
@@ -131,10 +123,10 @@ public class CrossOriginTests {
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(new String[]{"GET"}, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[] { "GET" }, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray());
|
||||
assertTrue(config.getAllowCredentials());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray());
|
||||
assertNull(config.getExposedHeaders());
|
||||
assertEquals(new Long(1800), config.getMaxAge());
|
||||
}
|
||||
@@ -148,9 +140,9 @@ public class CrossOriginTests {
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray());
|
||||
assertTrue(config.getAllowCredentials());
|
||||
assertNull(config.getExposedHeaders());
|
||||
assertNull(config.getMaxAge());
|
||||
@@ -164,9 +156,9 @@ public class CrossOriginTests {
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(this.request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertNotNull(config);
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[]{"*"}, config.getAllowedHeaders().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedMethods().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray());
|
||||
assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray());
|
||||
assertTrue(config.getAllowCredentials());
|
||||
assertNull(config.getExposedHeaders());
|
||||
assertNull(config.getMaxAge());
|
||||
@@ -176,23 +168,13 @@ public class CrossOriginTests {
|
||||
public void testOptionsHeaderHandling() throws Exception {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/default");
|
||||
request.addHeader(HttpHeaders.ORIGIN, "http://domain2.com");
|
||||
try {
|
||||
HandlerExecutionChain handler = this.handlerMapping.getHandler(request);
|
||||
if (isSpring43) {
|
||||
// SPR-13130
|
||||
assertNotNull(handler);
|
||||
Object handlerMethod = handler.getHandler();
|
||||
assertNotNull(handlerMethod);
|
||||
assertThat(handlerMethod, instanceOf(HandlerMethod.class));
|
||||
assertThat(((HandlerMethod) handlerMethod).getBeanType().getName(),
|
||||
containsString("HttpOptionsHandler"));
|
||||
return;
|
||||
}
|
||||
fail("HttpRequestMethodNotSupportedException expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, instanceOf(HttpRequestMethodNotSupportedException.class));
|
||||
}
|
||||
HandlerExecutionChain handler = this.handlerMapping.getHandler(request);
|
||||
assertNotNull(handler);
|
||||
Object handlerMethod = handler.getHandler();
|
||||
assertNotNull(handlerMethod);
|
||||
assertThat(handlerMethod, instanceOf(HandlerMethod.class));
|
||||
assertThat(((HandlerMethod) handlerMethod).getBeanType().getName(),
|
||||
containsString("HttpOptionsHandler"));
|
||||
}
|
||||
|
||||
private CorsConfiguration getCorsConfiguration(HandlerExecutionChain chain, boolean isPreFlightRequest) {
|
||||
|
||||
@@ -4,19 +4,14 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/http
|
||||
http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<mvc:annotation-driven/>
|
||||
|
||||
<!-- TODO SF-4.3.RC1 compatibility. TODO SF-4.3.RC1 compatibility. See https://jira.spring.io/browse/SPR-14140 -->
|
||||
<context:property-placeholder/>
|
||||
|
||||
<graph-controller path="/foo"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -34,10 +34,8 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -147,12 +145,6 @@ public class IntegrationGraphControllerTests {
|
||||
@EnableIntegrationGraphController(path = "/testIntegration")
|
||||
public static class ContextConfiguration {
|
||||
|
||||
// TODO SF-4.3.RC1 compatibility. See https://jira.spring.io/browse/SPR-14140
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -79,7 +80,9 @@ import org.springframework.web.client.RestTemplate;
|
||||
public class HttpRequestExecutingMessageHandlerTests {
|
||||
|
||||
public static ParameterizedTypeReference<List<String>> testParameterizedTypeReference() {
|
||||
return new ParameterizedTypeReference<List<String>>() { };
|
||||
return new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -637,8 +640,8 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
@Test
|
||||
public void contentTypeIsNotSetForGetRequest() throws Exception {
|
||||
// GET
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler(
|
||||
"http://www.springsource.org/spring-integration");
|
||||
HttpRequestExecutingMessageHandler handler =
|
||||
new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
@@ -646,59 +649,54 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<?> message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
Exception exception = null;
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
fail("An Exception expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
assertEquals("intentional", e.getCause().getMessage());
|
||||
assertNull(template.lastRequestEntity.get().getHeaders().getContentType());
|
||||
}
|
||||
assertEquals("intentional", exception.getCause().getMessage());
|
||||
HttpEntity<?> request = template.lastRequestEntity.get();
|
||||
assertNull(request.getHeaders().getContentType());
|
||||
|
||||
/*
|
||||
* TODO: reconsider the inclusion of content-type for various HttpMethods (only
|
||||
* ignoring for GET as of 2.0.5) uncomment code below accordingly (see INT-1951)
|
||||
*/
|
||||
//HEAD
|
||||
handler.setHttpMethod(HttpMethod.HEAD);
|
||||
|
||||
/*
|
||||
* //HEAD handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.HEAD);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*
|
||||
* //DELETE handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.DELETE);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*
|
||||
* //TRACE handler = new HttpRequestExecutingMessageHandler(
|
||||
* "http://www.springsource.org/spring-integration"); template = new
|
||||
* MockRestTemplate(); new
|
||||
* DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
* handler.setHttpMethod(HttpMethod.TRACE);
|
||||
*
|
||||
* message = MessageBuilder.withPayload(mock(Source.class)).build(); exception =
|
||||
* null; try { handler.handleMessage(message); } catch (Exception e) { exception =
|
||||
* e; } assertEquals("intentional", exception.getCause().getMessage()); request =
|
||||
* template.lastRequestEntity.get();
|
||||
* assertNull(request.getHeaders().getContentType());
|
||||
*/
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
fail("An Exception expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertEquals("intentional", e.getCause().getMessage());
|
||||
assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType());
|
||||
}
|
||||
|
||||
|
||||
//DELETE
|
||||
handler.setHttpMethod(HttpMethod.DELETE);
|
||||
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
fail("An Exception expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertEquals("intentional", e.getCause().getMessage());
|
||||
assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType());
|
||||
}
|
||||
|
||||
//TRACE
|
||||
handler.setHttpMethod(HttpMethod.TRACE);
|
||||
|
||||
message = MessageBuilder.withPayload(mock(Source.class)).build();
|
||||
try {
|
||||
handler.handleMessage(message);
|
||||
fail("An Exception expected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertEquals("intentional", e.getCause().getMessage());
|
||||
assertEquals(MediaType.TEXT_XML, template.lastRequestEntity.get().getHeaders().getContentType());
|
||||
}
|
||||
}
|
||||
|
||||
@Test // INT-2275
|
||||
|
||||
@@ -1,72 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY" />
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY"/>
|
||||
|
||||
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
|
||||
<jdbc:script location="${int.drop.script}" />
|
||||
<jdbc:script location="${int.schema.script}" />
|
||||
<jdbc:script location="${int.drop.script}"/>
|
||||
<jdbc:script location="${int.schema.script}"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<int-jdbc:message-store id="messageStore" data-source="dataSource" />
|
||||
<int-jdbc:message-store id="messageStore" data-source="dataSource"/>
|
||||
|
||||
<channel id="input" xmlns="http://www.springframework.org/schema/integration">
|
||||
<queue ref="storeQueue" />
|
||||
<queue ref="storeQueue"/>
|
||||
</channel>
|
||||
|
||||
<bean id="storeQueue" class="org.springframework.integration.store.MessageGroupQueue">
|
||||
<constructor-arg ref="messageStore" />
|
||||
<constructor-arg value="JdbcMessageStoreChannelIntegrationTests" />
|
||||
<constructor-arg ref="lock" />
|
||||
<constructor-arg ref="messageStore"/>
|
||||
<constructor-arg value="JdbcMessageStoreChannelIntegrationTests"/>
|
||||
<constructor-arg ref="lock"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="output" />
|
||||
<int:channel id="output"/>
|
||||
|
||||
<int:logging-channel-adapter channel="output" />
|
||||
<int:logging-channel-adapter channel="output"/>
|
||||
|
||||
<service-activator id="service-activator"
|
||||
input-channel="input" output-channel="output"
|
||||
xmlns="http://www.springframework.org/schema/integration">
|
||||
input-channel="input" output-channel="output"
|
||||
xmlns="http://www.springframework.org/schema/integration">
|
||||
<beans:bean
|
||||
class="org.springframework.integration.jdbc.JdbcMessageStoreChannelIntegrationTests$Service" />
|
||||
class="org.springframework.integration.jdbc.JdbcMessageStoreChannelIntegrationTests$Service"/>
|
||||
<poller fixed-rate="200">
|
||||
<advice-chain>
|
||||
<ref bean="txAdvice" />
|
||||
<ref bean="lock" />
|
||||
<ref bean="txAdvice"/>
|
||||
<ref bean="lock"/>
|
||||
</advice-chain>
|
||||
</poller>
|
||||
</service-activator>
|
||||
|
||||
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor" />
|
||||
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor"/>
|
||||
<tx:advice id="txAdvice">
|
||||
<tx:attributes>
|
||||
<tx:method name="*" />
|
||||
<tx:method name="*"/>
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<bean id="placeholderProperties"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location"
|
||||
value="classpath:int-${ENVIRONMENT:derby}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
|
||||
system-properties-mode="OVERRIDE"
|
||||
ignore-unresolvable="true"
|
||||
order="1"/>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<int:header-enricher input-channel="routingSlip" output-channel="input">
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY" />
|
||||
|
||||
@@ -50,14 +51,10 @@
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<bean id="placeholderProperties"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location"
|
||||
value="classpath:int-${ENVIRONMENT:derby}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
|
||||
system-properties-mode="OVERRIDE"
|
||||
ignore-unresolvable="true"
|
||||
order="1"/>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
|
||||
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
|
||||
@@ -42,12 +46,10 @@
|
||||
</poller>
|
||||
</service-activator>
|
||||
|
||||
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:int-${ENVIRONMENT:derby}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
|
||||
system-properties-mode="OVERRIDE"
|
||||
ignore-unresolvable="true"
|
||||
order="1"/>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY"/>
|
||||
|
||||
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
|
||||
<jdbc:script location="${int.drop.script}" />
|
||||
<jdbc:script location="${int.schema.script}" />
|
||||
<jdbc:script location="${int.drop.script}"/>
|
||||
<jdbc:script location="${int.schema.script}"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:int-${ENVIRONMENT:derby}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
|
||||
system-properties-mode="OVERRIDE"
|
||||
ignore-unresolvable="true"
|
||||
order="1"/>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
|
||||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<tx:annotation-driven/>
|
||||
<int:annotation-config/>
|
||||
@@ -28,12 +30,10 @@
|
||||
|
||||
<int-jdbc:message-store id="messageStore" data-source="dataSource" region="MessageStoreMultipleChannelTests"/>
|
||||
|
||||
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:int-${ENVIRONMENT:derby}.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
|
||||
system-properties-mode="OVERRIDE"
|
||||
ignore-unresolvable="true"
|
||||
order="1"/>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
|
||||
@@ -66,8 +66,7 @@ public class MessagingGatewaySupportRegistrationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableIntegration
|
||||
// TODO INT-3869
|
||||
@EnableIntegrationMBeanExport(server = "server")
|
||||
@EnableIntegrationMBeanExport
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -101,7 +100,7 @@ public class MessagingGatewaySupportRegistrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MBeanServerFactoryBean server() {
|
||||
public static MBeanServerFactoryBean server() {
|
||||
MBeanServerFactoryBean fb = new MBeanServerFactoryBean();
|
||||
fb.setLocateExistingServerIfPossible(true);
|
||||
return fb;
|
||||
|
||||
@@ -3,18 +3,11 @@
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:sftp="http://www.springframework.org/schema/integration/sftp"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath:org/springframework/integration/sftp/config/sftp.properties"/>
|
||||
@@ -38,69 +31,69 @@
|
||||
</beans:bean>
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-regex="f[o]+\.txt"
|
||||
remote-directory-expression="'/foo'"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="false"
|
||||
remote-file-separator="."
|
||||
local-filename-generator-expression="#this.toUpperCase() + '.a'"
|
||||
temporary-file-suffix=".bar"
|
||||
comparator="comparator"
|
||||
local-filter="acceptAllFilter"
|
||||
delete-remote-files="${delete.remote.files}"
|
||||
preserve-timestamp="true">
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-regex="f[o]+\.txt"
|
||||
remote-directory-expression="'/foo'"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="false"
|
||||
remote-file-separator="."
|
||||
local-filename-generator-expression="#this.toUpperCase() + '.a'"
|
||||
temporary-file-suffix=".bar"
|
||||
comparator="comparator"
|
||||
local-filter="acceptAllFilter"
|
||||
delete-remote-files="${delete.remote.files}"
|
||||
preserve-timestamp="true">
|
||||
<poller fixed-rate="1000">
|
||||
<transactional synchronization-factory="syncFactory"/>
|
||||
</poller>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<beans:bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
|
||||
<beans:bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>
|
||||
|
||||
<transaction-synchronization-factory id="syncFactory">
|
||||
<after-commit expression="'foo'" channel="successChannel"/>
|
||||
<after-rollback expression="'bar'" channel="failureChannel"/>
|
||||
</transaction-synchronization-factory>
|
||||
|
||||
<channel id="successChannel" />
|
||||
<channel id="successChannel"/>
|
||||
|
||||
<channel id="failureChannel" />
|
||||
<channel id="failureChannel"/>
|
||||
|
||||
<beans:bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
|
||||
<beans:constructor-arg value="java.util.Comparator"/>
|
||||
</beans:bean>
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapter"
|
||||
channel="requestChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
filter="filter"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
channel="requestChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
filter="filter"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterWithPattern"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-pattern="pattern"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-pattern="pattern"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:local-test-dir"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterNoLocalDir"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-pattern="pattern"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:foo"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-pattern="pattern"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:foo"
|
||||
auto-create-local-directory="true"
|
||||
delete-remote-files="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
@@ -109,16 +102,16 @@
|
||||
</beans:bean>
|
||||
|
||||
<sftp:inbound-channel-adapter id="autoChannel"
|
||||
session-factory="sftpSessionFactory"
|
||||
filter="filter"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:foo"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
session-factory="sftpSessionFactory"
|
||||
filter="filter"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:foo"
|
||||
auto-create-local-directory="false"
|
||||
delete-remote-files="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<bridge input-channel="autoChannel" output-channel="nullChannel" />
|
||||
<bridge input-channel="autoChannel" output-channel="nullChannel"/>
|
||||
|
||||
<beans:bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
|
||||
package org.springframework.integration.sftp.config;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
@@ -29,7 +31,6 @@ import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -79,11 +80,13 @@ public class InboundChannelAdapterParserTests {
|
||||
(SftpInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
|
||||
assertNotNull(source);
|
||||
|
||||
PriorityBlockingQueue<?> blockingQueue = TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class);
|
||||
PriorityBlockingQueue<?> blockingQueue =
|
||||
TestUtils.getPropertyValue(adapter, "source.fileSource.toBeReceived", PriorityBlockingQueue.class);
|
||||
Comparator<?> comparator = blockingQueue.comparator();
|
||||
|
||||
assertNotNull(comparator);
|
||||
SftpInboundFileSynchronizer synchronizer = (SftpInboundFileSynchronizer) TestUtils.getPropertyValue(source, "synchronizer");
|
||||
SftpInboundFileSynchronizer synchronizer =
|
||||
TestUtils.getPropertyValue(source, "synchronizer", SftpInboundFileSynchronizer.class);
|
||||
assertEquals("'/foo'", TestUtils.getPropertyValue(synchronizer, "remoteDirectoryExpression", Expression.class)
|
||||
.getExpressionString());
|
||||
assertNotNull(TestUtils.getPropertyValue(synchronizer, "localFilenameGeneratorExpression"));
|
||||
@@ -93,9 +96,12 @@ public class InboundChannelAdapterParserTests {
|
||||
assertNotNull(remoteFileSeparator);
|
||||
assertEquals(".", remoteFileSeparator);
|
||||
PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class);
|
||||
assertNotNull(requestChannel.receive(2000));
|
||||
assertNotNull(requestChannel.receive(10000));
|
||||
FileListFilter<?> acceptAllFilter = context.getBean("acceptAllFilter", FileListFilter.class);
|
||||
assertTrue(TestUtils.getPropertyValue(source, "fileSource.scanner.filter.fileFilters", Collection.class).contains(acceptAllFilter));
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<FileListFilter<?>> filters =
|
||||
TestUtils.getPropertyValue(source, "fileSource.scanner.filter.fileFilters", Collection.class);
|
||||
assertThat(filters, hasItem(acceptAllFilter));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -121,15 +127,6 @@ public class InboundChannelAdapterParserTests {
|
||||
new ClassPathXmlApplicationContext("InboundChannelAdapterParserTests-context-fail.xml", this.getClass()).close();
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void testLocalFilesAreFound() throws Exception {
|
||||
assertTrue(new File("target").exists());
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"InboundChannelAdapterParserTests-context.xml", this.getClass());
|
||||
assertTrue(new File("target").exists());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalDirAutoCreated() throws Exception {
|
||||
assertFalse(new File("foo").exists());
|
||||
|
||||
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -89,7 +88,8 @@ public class SearchReceivingMessageSourceTests {
|
||||
@Test
|
||||
public void testSearchReceivingMessageSourceInit() {
|
||||
|
||||
final SearchReceivingMessageSource messageSource = new SearchReceivingMessageSource(new TwitterTemplate("test"), "foo");
|
||||
final SearchReceivingMessageSource messageSource =
|
||||
new SearchReceivingMessageSource(new TwitterTemplate("test"), "foo");
|
||||
messageSource.setComponentName("twitterSearchMessageSource");
|
||||
|
||||
final Object metadataStore = TestUtils.getPropertyValue(messageSource, "metadataStore");
|
||||
@@ -153,18 +153,11 @@ public class SearchReceivingMessageSourceTests {
|
||||
|
||||
final SearchOperations so = mock(SearchOperations.class);
|
||||
|
||||
final Tweet tweet1 = new Tweet(1L, "1", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L,
|
||||
"languageCode", "source");
|
||||
final Tweet tweet2 = new Tweet(2L, "2", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L,
|
||||
"languageCode", "source");
|
||||
final Tweet tweet3 = new Tweet(3L, "3", "first", new Date(), "fromUser", "profileImageUrl", 888L, 999L,
|
||||
"languageCode", "source");
|
||||
|
||||
final List<Tweet> tweets = new ArrayList<Tweet>();
|
||||
|
||||
tweets.add(tweet1);
|
||||
tweets.add(tweet2);
|
||||
tweets.add(tweet3);
|
||||
tweets.add(mock(Tweet.class));
|
||||
tweets.add(mock(Tweet.class));
|
||||
tweets.add(mock(Tweet.class));
|
||||
|
||||
final SearchResults results = new SearchResults(tweets, new SearchMetadata(111, 111));
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -29,8 +30,6 @@ import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -61,8 +60,6 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate;
|
||||
*/
|
||||
public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTests {
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SourcePollingChannelAdapter twitterSearchAdapter;
|
||||
|
||||
private AbstractTwitterMessageSource<?> twitterMessageSource;
|
||||
@@ -143,21 +140,26 @@ public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTe
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml")
|
||||
@ImportResource("org/springframework/integration/twitter/inbound/SearchReceivingMessageSourceWithRedisTests-context.xml")
|
||||
static class SearchReceivingMessageSourceWithRedisTestsConfig {
|
||||
|
||||
@Bean(name = "twitterTemplate")
|
||||
public TwitterTemplate twitterTemplate() {
|
||||
final TwitterTemplate twitterTemplate = mock(TwitterTemplate.class);
|
||||
TwitterTemplate twitterTemplate = mock(TwitterTemplate.class);
|
||||
|
||||
final SearchOperations so = mock(SearchOperations.class);
|
||||
SearchOperations so = mock(SearchOperations.class);
|
||||
|
||||
final Tweet tweet3 = new Tweet(3L, "3", "first", new GregorianCalendar(2013, 2, 20).getTime(), "fromUser",
|
||||
"profileImageUrl", 888L, 999L, "languageCode", "source");
|
||||
final Tweet tweet1 = new Tweet(1L, "1", "first", new GregorianCalendar(2013, 0, 20).getTime(), "fromUser",
|
||||
"profileImageUrl", 888L, 999L, "languageCode", "source");
|
||||
final Tweet tweet2 = new Tweet(2L, "2", "first", new GregorianCalendar(2013, 1, 20).getTime(), "fromUser",
|
||||
"profileImageUrl", 888L, 999L, "languageCode", "source");
|
||||
Tweet tweet3 = mock(Tweet.class);
|
||||
given(tweet3.getId()).willReturn(3L);
|
||||
given(tweet3.getCreatedAt()).willReturn(new GregorianCalendar(2013, 2, 20).getTime());
|
||||
|
||||
Tweet tweet1 = mock(Tweet.class);
|
||||
given(tweet1.getId()).willReturn(1L);
|
||||
given(tweet1.getCreatedAt()).willReturn(new GregorianCalendar(2013, 0, 20).getTime());
|
||||
|
||||
final Tweet tweet2 = mock(Tweet.class);
|
||||
given(tweet2.getId()).willReturn(2L);
|
||||
given(tweet2.getCreatedAt()).willReturn(new GregorianCalendar(2013, 1, 20).getTime());
|
||||
|
||||
final List<Tweet> tweets = new ArrayList<Tweet>();
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -58,6 +57,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
@@ -77,7 +77,7 @@ public class TwitterSearchOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testStringQuery() {
|
||||
Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz");
|
||||
Tweet tweet = mock(Tweet.class);
|
||||
SearchMetadata searchMetadata = mock(SearchMetadata.class);
|
||||
final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata);
|
||||
doAnswer(new Answer<SearchResults>() {
|
||||
@@ -104,7 +104,7 @@ public class TwitterSearchOutboundGatewayTests {
|
||||
public void testStringQueryCustomLimit() {
|
||||
this.gateway.setSearchArgsExpression(new SpelExpressionParser()
|
||||
.parseExpression("{payload, 30}"));
|
||||
Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz");
|
||||
Tweet tweet = mock(Tweet.class);
|
||||
SearchMetadata searchMetadata = mock(SearchMetadata.class);
|
||||
final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata);
|
||||
doAnswer(new Answer<SearchResults>() {
|
||||
@@ -131,7 +131,7 @@ public class TwitterSearchOutboundGatewayTests {
|
||||
public void testStringQueryCustomExpression() {
|
||||
this.gateway.setSearchArgsExpression(new SpelExpressionParser()
|
||||
.parseExpression("{'bar', 1, 2, 3}"));
|
||||
Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz");
|
||||
Tweet tweet = mock(Tweet.class);
|
||||
SearchMetadata searchMetadata = mock(SearchMetadata.class);
|
||||
final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata);
|
||||
doAnswer(new Answer<SearchResults>() {
|
||||
@@ -158,7 +158,7 @@ public class TwitterSearchOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testSearchParamsQuery() {
|
||||
Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz");
|
||||
Tweet tweet = mock(Tweet.class);
|
||||
SearchMetadata searchMetadata = mock(SearchMetadata.class);
|
||||
final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata);
|
||||
final SearchParameters parameters = new SearchParameters("bar");
|
||||
@@ -185,7 +185,7 @@ public class TwitterSearchOutboundGatewayTests {
|
||||
public void testSearchParamsQueryCustomExpression() {
|
||||
this.gateway.setSearchArgsExpression(new SpelExpressionParser()
|
||||
.parseExpression("new SearchParameters('foo' + payload).count(5).sinceId(11)"));
|
||||
Tweet tweet = new Tweet(1L, "1", "foo", new Date(), "bar", "baz", 0L, 0L, "qux", "fiz");
|
||||
Tweet tweet = mock(Tweet.class);
|
||||
SearchMetadata searchMetadata = mock(SearchMetadata.class);
|
||||
final SearchResults searchResults = new SearchResults(Collections.singletonList(tweet), searchMetadata);
|
||||
doAnswer(new Answer<SearchResults>() {
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<beans:property name="location" value="classpath:test.properties"/>
|
||||
</beans:bean>
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<beans:property name="location" value="classpath:test.properties"/>
|
||||
</beans:bean>
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
@@ -30,7 +25,7 @@
|
||||
<channel id="inboundPresenceChannel"/>
|
||||
|
||||
<service-activator input-channel="inboundPresenceChannel" output-channel="stdOutChannel"
|
||||
expression="'Presence event from: ' + payload.getFrom() + ' - ' + payload.getMode()"/>
|
||||
expression="'Presence event from: ' + payload.getFrom() + ' - ' + payload.getMode()"/>
|
||||
|
||||
<channel id="stdOutChannel"/>
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<beans:property name="location" value="classpath:test.properties"/>
|
||||
</beans:bean>
|
||||
<context:property-placeholder location="test.properties"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCache;
|
||||
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
|
||||
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
|
||||
import org.apache.curator.utils.CloseableUtils;
|
||||
import org.apache.curator.utils.EnsurePath;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
|
||||
@@ -43,6 +42,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 4.2
|
||||
*/
|
||||
public class ZookeeperMetadataStore implements ListenableMetadataStore, SmartLifecycle {
|
||||
@@ -274,10 +274,13 @@ public class ZookeeperMetadataStore implements ListenableMetadataStore, SmartLif
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (!this.running) {
|
||||
try {
|
||||
EnsurePath ensurePath = new EnsurePath(this.root);
|
||||
ensurePath.ensure(this.client.getZookeeperClient());
|
||||
this.client.checkExists()
|
||||
.creatingParentContainersIfNeeded()
|
||||
.forPath(this.root);
|
||||
|
||||
this.cache = new PathChildrenCache(this.client, this.root, true);
|
||||
this.cache.getListenable().addListener(new MetadataStoreListenerInvokingPathChildrenCacheListener());
|
||||
this.cache.getListenable()
|
||||
.addListener(new MetadataStoreListenerInvokingPathChildrenCacheListener());
|
||||
this.cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
|
||||
this.running = true;
|
||||
}
|
||||
@@ -343,52 +346,56 @@ public class ZookeeperMetadataStore implements ListenableMetadataStore, SmartLif
|
||||
private int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MetadataStoreListenerInvokingPathChildrenCacheListener implements
|
||||
PathChildrenCacheListener {
|
||||
private class MetadataStoreListenerInvokingPathChildrenCacheListener implements PathChildrenCacheListener {
|
||||
|
||||
@Override
|
||||
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
|
||||
throws Exception {
|
||||
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
|
||||
synchronized (ZookeeperMetadataStore.this.updateMap) {
|
||||
String eventPath = event.getData().getPath();
|
||||
String eventKey = getKey(eventPath);
|
||||
byte[] eventData = event.getData().getData();
|
||||
switch (event.getType()) {
|
||||
case CHILD_ADDED:
|
||||
if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) {
|
||||
if (event.getData().getStat().getVersion() >=
|
||||
ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) {
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventPath);
|
||||
case CHILD_ADDED:
|
||||
if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) {
|
||||
if (event.getData().getStat().getVersion() >=
|
||||
ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) {
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onAdd(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
break;
|
||||
case CHILD_UPDATED:
|
||||
if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) {
|
||||
if (event.getData().getStat().getVersion() >=
|
||||
ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) {
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventPath);
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onAdd(eventKey, IntegrationUtils.bytesToString(eventData,
|
||||
ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
}
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onUpdate(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
break;
|
||||
case CHILD_REMOVED:
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventKey);
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onRemove(eventKey, IntegrationUtils.bytesToString(eventData, ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// ignore all other events
|
||||
break;
|
||||
break;
|
||||
case CHILD_UPDATED:
|
||||
if (ZookeeperMetadataStore.this.updateMap.containsKey(eventKey)) {
|
||||
if (event.getData().getStat().getVersion() >=
|
||||
ZookeeperMetadataStore.this.updateMap.get(eventKey).getVersion()) {
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventPath);
|
||||
}
|
||||
}
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onUpdate(eventKey, IntegrationUtils.bytesToString(eventData,
|
||||
ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
break;
|
||||
case CHILD_REMOVED:
|
||||
ZookeeperMetadataStore.this.updateMap.remove(eventKey);
|
||||
for (MetadataStoreListener listener : ZookeeperMetadataStore.this.listeners) {
|
||||
listener.onRemove(eventKey, IntegrationUtils.bytesToString(eventData,
|
||||
ZookeeperMetadataStore.this.encoding));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// ignore all other events
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user