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:
Artem Bilan
2016-04-25 23:32:14 -04:00
parent 3390734a99
commit 47d7a67bda
43 changed files with 420 additions and 482 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"/>

View File

@@ -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}"

View File

@@ -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/>

View File

@@ -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" />

View File

@@ -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}"

View File

@@ -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>

View File

@@ -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"

View File

@@ -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)));
}
}

View File

@@ -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

View File

@@ -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)));
}
}

View File

@@ -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)));
}
}