INTEXT-189: Fix S3InboundChannelAdapterParser
JIRA: https://jira.spring.io/browse/INTEXT-189
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,24 +16,24 @@
|
||||
package org.springframework.integration.aws.s3.config.xml;
|
||||
import static org.springframework.integration.aws.config.xml.AmazonWSParserUtils.getAmazonWSCredentials;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.aws.s3.AmazonS3InboundSynchronizationMessageSource;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
||||
/**
|
||||
* The channel adapter parser for the S3 inbound parser
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Li Wang
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
@@ -84,14 +84,10 @@ public class AmazonS3InboundChannelAdapterParser extends
|
||||
throw new BeanDefinitionStoreException(message);
|
||||
}
|
||||
else {
|
||||
Expression expr;
|
||||
if(hasDirectory) {
|
||||
expr = new LiteralExpression(directory);
|
||||
}
|
||||
else {
|
||||
expr = new SpelExpressionParser().parseExpression(directoryExpression);
|
||||
}
|
||||
builder.addPropertyValue("directory", expr);
|
||||
BeanDefinition expressionDef =
|
||||
IntegrationNamespaceUtils.createExpressionDefinitionFromValueOrExpression("local-directory",
|
||||
"local-directory-expression", parserContext, element, true);
|
||||
builder.addPropertyValue("directory", expressionDef);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, MAX_OBJECTS_PER_BATCH);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, ACCEPT_SUB_FOLDERS);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -34,7 +34,7 @@ import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
* The test case class for S3 inbound channel adapter
|
||||
*
|
||||
* @author Amol Nayak
|
||||
*
|
||||
* @author Li Wang
|
||||
* @since 0.5
|
||||
*
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ public class AmazonS3InboundChannelAdapterParserTests {
|
||||
AmazonS3InboundSynchronizationMessageSource source = getPropertyValue(valid, "source", AmazonS3InboundSynchronizationMessageSource.class);
|
||||
assertEquals("TestBucket", getPropertyValue(source, "bucket"));
|
||||
assertEquals(".temp", getPropertyValue(source, "temporarySuffix"));
|
||||
assertEquals(new File(System.getProperty("java.io.tmpdir")), getPropertyValue(source, "directory"));
|
||||
assertEquals(new File("/"), getPropertyValue(source, "directory"));
|
||||
assertEquals("remote", getPropertyValue(source, "remoteDirectory"));
|
||||
assertEquals(true, getPropertyValue(source, "acceptSubFolders", Boolean.class).booleanValue());
|
||||
assertEquals(100, getPropertyValue(source, "maxObjectsPerBatch", Integer.class).intValue());
|
||||
@@ -60,6 +60,7 @@ public class AmazonS3InboundChannelAdapterParserTests {
|
||||
//test the second definition with custom attributes
|
||||
valid = ctx.getBean("validInboundWithCustomOps", SourcePollingChannelAdapter.class);
|
||||
source = getPropertyValue(valid, "source", AmazonS3InboundSynchronizationMessageSource.class);
|
||||
assertEquals(new File(System.getProperty("java.io.tmpdir")), getPropertyValue(source, "directory"));
|
||||
AmazonS3Operations s3Operations = getPropertyValue(source, "s3Operations", AmazonS3Operations.class);
|
||||
assertEquals(AmazonS3DummyOperations.class, s3Operations.getClass());
|
||||
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
<?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:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
|
||||
xsi:schemaLocation=
|
||||
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/aws http://www.springframework.org/schema/integration/aws/spring-integration-aws.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
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/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration/aws http://www.springframework.org/schema/integration/aws/spring-integration-aws.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<util:properties id="placeholderProperties"/>
|
||||
|
||||
<context:property-placeholder properties-ref="placeholderProperties"/>
|
||||
|
||||
<bean id="localDirectory" class="java.lang.String">
|
||||
<constructor-arg value="#{T(java.lang.System).getProperty('java.io.tmpdir')}"/>
|
||||
@@ -19,7 +26,7 @@
|
||||
bucket="TestBucket"
|
||||
propertiesFile="testawscredentials.properties"
|
||||
temporary-suffix=".temp"
|
||||
local-directory-expression="@localDirectory"
|
||||
local-directory="${foo.dir:/}"
|
||||
remote-directory="remote"
|
||||
accept-sub-folders="true"
|
||||
max-objects-per-batch="100"
|
||||
@@ -62,4 +69,4 @@
|
||||
<bean id="customOps"
|
||||
class="org.springframework.integration.aws.s3.config.xml.AmazonS3DummyOperations"/>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user