AWS: Updated to spring-integration to 4.0.3
Made the corresponding API changes. Had to update jacoco to latest (0.7.1.blah) to get the tests to work correctly on OSX Java 8 Fixed JavaDoc errors show up by the Java 8 linter. Build passes Bringing dependencies inline with Spring 4.0.6 Updated mockito to 1.9.5 Updated Hamcrest to 1.3 Updated aws-sdk to 1.8.7 Merge branch 'master' into integration-4.0 Reformatted gradle file inline with the existing standard Switch back to using the milestone repo Upgrade Gradle version to 1.12 Updated the schema references to use un-versioned refs Updated author tags and copyright dates AWS: SI-4.0 Polishing
This commit is contained in:
@@ -2,7 +2,7 @@ description = 'Spring Integration AWS Support'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url 'https://repo.springsource.org/plugins-snapshot' }
|
||||
maven { url 'http://repo.spring.io/plugins-snapshot' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ apply plugin: 'idea'
|
||||
group = 'org.springframework.integration'
|
||||
|
||||
repositories {
|
||||
maven { url 'http://repo.springsource.org/libs-milestone' }
|
||||
maven { url 'http://repo.springsource.org/plugins-release' }
|
||||
maven { url 'http://repo.spring.io/libs-milestone' }
|
||||
maven { url 'http://repo.spring.io/plugins-release' }
|
||||
}
|
||||
|
||||
sourceCompatibility=1.6
|
||||
@@ -28,26 +28,23 @@ configurations {
|
||||
}
|
||||
|
||||
ext {
|
||||
apacheHttpclientVersion='4.1.1'
|
||||
awsSdkVersion='1.3.32'
|
||||
commonsCodecVersion='1.5'
|
||||
apacheHttpclientVersion='4.3.4'
|
||||
apacheHttpCoreVersion='4.3.2'
|
||||
awsSdkVersion='1.8.7'
|
||||
commonsCodecVersion='1.9'
|
||||
commonsIoVersion='2.0.1'
|
||||
javaMailVersion='1.4.4'
|
||||
javaMailVersion='1.5.2'
|
||||
jacksonVersion='1.9.11'
|
||||
junitVersion='4.11'
|
||||
log4jVersion = '1.2.12'
|
||||
mockitoVersion='1.9.0'
|
||||
springIntegrationVersion = '2.2.2.RELEASE'
|
||||
springVersion = '3.1.4.RELEASE'
|
||||
springIntegrationVersion = '4.0.3.RELEASE'
|
||||
|
||||
idPrefix = 'aws'
|
||||
|
||||
linkHomepage = 'https://github.com/SpringSource/spring-integration-extensions'
|
||||
linkCi = 'https://build.springsource.org/browse/INTEXT'
|
||||
linkIssue = 'https://jira.springsource.org/browse/INTEXT'
|
||||
linkScmUrl = 'https://github.com/SpringSource/spring-integration-extensions'
|
||||
linkScmConnection = 'https://github.com/SpringSource/spring-integration-extensions.git'
|
||||
linkScmDevConnection = 'git@github.com:SpringSource/spring-integration-extensions.git'
|
||||
linkHomepage = 'https://github.com/spring-projects/spring-integration-extensions'
|
||||
linkCi = 'https://build.spring.io/browse/INTEXT'
|
||||
linkIssue = 'https://jira.spring.io/browse/INTEXT'
|
||||
linkScmUrl = 'https://github.com/spring-projects/spring-integration-extensions'
|
||||
linkScmConnection = 'https://github.com/spring-projects/spring-integration-extensions.git'
|
||||
linkScmDevConnection = 'git@github.com:spring-projects/spring-integration-extensions.git'
|
||||
}
|
||||
|
||||
ext.javadocLinks = [
|
||||
@@ -64,20 +61,15 @@ dependencies {
|
||||
compile "org.codehaus.jackson:jackson-core-asl:$jacksonVersion"
|
||||
compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
|
||||
compile "org.apache.httpcomponents:httpclient:$apacheHttpclientVersion"
|
||||
compile "org.apache.httpcomponents:httpcore:$apacheHttpclientVersion"
|
||||
compile "org.apache.httpcomponents:httpcore:$apacheHttpCoreVersion"
|
||||
|
||||
//Amazon SES Support
|
||||
compile ("org.springframework.integration:spring-integration-mail:$springIntegrationVersion", optional)
|
||||
compile ("javax.mail:mail:$javaMailVersion", optional)
|
||||
compile ("javax.mail:javax.mail-api:$javaMailVersion", optional)
|
||||
|
||||
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
|
||||
testCompile "org.hamcrest:hamcrest-all:1.1"
|
||||
testCompile "junit:junit-dep:$junitVersion"
|
||||
testCompile "org.mockito:mockito-all:$mockitoVersion"
|
||||
testCompile "org.springframework:spring-test:$springVersion"
|
||||
testCompile "log4j:log4j:$log4jVersion"
|
||||
|
||||
jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.6.2.201302030002", classifier: "runtime"
|
||||
jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.7.1.201405082137", classifier: "runtime"
|
||||
|
||||
}
|
||||
|
||||
@@ -119,7 +111,7 @@ sourceSets {
|
||||
}
|
||||
|
||||
// enable all compiler warnings; individual projects may customize further
|
||||
ext.xLintArg = '-Xlint:all'
|
||||
ext.xLintArg = '-Xlint:all,-options'
|
||||
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg]
|
||||
|
||||
test {
|
||||
@@ -270,5 +262,6 @@ task dist(dependsOn: assemble) {
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
description = 'Generates gradlew[.bat] scripts'
|
||||
gradleVersion = '1.6'
|
||||
gradleVersion = '1.12'
|
||||
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
#Wed May 15 22:09:50 EDT 2013
|
||||
#Thu Aug 14 15:52:49 EEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -21,13 +21,14 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* The common adapter parser for all AWS Outbound channel adapters
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.aws.core.AWSCredentials;
|
||||
import org.springframework.integration.aws.s3.core.AbstractAmazonS3Operations;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Operations;
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* synchronized from the S3
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.aws.core.AWSCredentials;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Object;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3OperationException;
|
||||
@@ -40,6 +40,7 @@ import org.springframework.util.Assert;
|
||||
* The Message handler for the S3 outbound channel adapter
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -19,7 +19,7 @@ import java.io.File;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -33,9 +33,10 @@ import org.springframework.util.StringUtils;
|
||||
* 2. Else, if the provided payload is of type {@link File}, then the name of the file is used.
|
||||
* if the file name ends with the temporary file suffix, the suffix is removed and the
|
||||
* remainder of the file is used as the name.
|
||||
* 3. If none of the above two are provided, the file name is the <Message Id>.ext
|
||||
* 3. If none of the above two are provided, the file name is the <Message Id>.ext
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
@@ -50,7 +51,7 @@ public class DefaultFileNameGenerationStrategy extends AbstractExpressionEvaluat
|
||||
private volatile String fileNameExpression = "headers['" + AmazonS3MessageHeaders.FILE_NAME + "']" ;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.integration.aws.s3.FileNameGenerationStrategy#generateFileName(org.springframework.integration.Message)
|
||||
* @see org.springframework.integration.aws.s3.FileNameGenerationStrategy#generateFileName(org.springframework.messaging.Message)
|
||||
*/
|
||||
public String generateFileName(Message<?> message) {
|
||||
String generatedFileName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package org.springframework.integration.aws.s3;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* The Common interface used to generate the file name for the file to be uploaded to S3
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
* notifies the operations on the file those were performed
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
@@ -62,7 +63,7 @@ public interface InboundLocalFileOperations {
|
||||
* The method will write to the file with the specified name in the specified directory
|
||||
* from the given {@link InputStream}. Upon completion of the writing the appropriate
|
||||
* {@link FileEventHandler} instance(s) will be notified with the {@link FileOperationType}
|
||||
* <i>WRITE<i> and {@link File} instance for the created file.
|
||||
* <i>WRITE</i> and {@link File} instance for the created file.
|
||||
* @param directory
|
||||
* @param fileName
|
||||
* @param in
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -27,7 +27,7 @@ import org.springframework.integration.aws.s3.DefaultFileNameGenerationStrategy;
|
||||
import org.springframework.integration.aws.s3.core.DefaultAmazonS3Operations;
|
||||
import org.springframework.integration.config.ExpressionFactoryBean;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.w3c.dom.Element;
|
||||
* The namespace parser for outbound-channel-parser for the aws-s3 namespace
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.integration.aws.s3.core;
|
||||
|
||||
import static org.springframework.integration.aws.core.AWSCommonUtils.encodeHex;
|
||||
import static org.springframework.integration.aws.core.AWSCommonUtils.getContentsMD5AsBytes;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -32,7 +29,9 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.aws.core.AWSCommonUtils;
|
||||
import org.springframework.integration.aws.core.AWSCredentials;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -46,13 +45,13 @@ import org.springframework.util.Assert;
|
||||
* @since 0.5
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,InitializingBean {
|
||||
public abstract class AbstractAmazonS3Operations implements AmazonS3Operations, InitializingBean {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private volatile long multipartUploadThreshold;
|
||||
|
||||
private volatile File temporaryDirectory = new File(System.getProperty("java.io.tmpdir"));
|
||||
private volatile File temporaryDirectory = new File(System.getProperty("java.io.tmpdir"));
|
||||
|
||||
private volatile String temporaryFileSuffix = ".writing";
|
||||
|
||||
@@ -63,13 +62,12 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
private String awsEndpoint;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The constructor that accepts the {@link AWSCredentials}
|
||||
* @param credentials
|
||||
*/
|
||||
protected AbstractAmazonS3Operations(AWSCredentials credentials) {
|
||||
Assert.notNull(credentials,"null 'credentials' provided");
|
||||
Assert.notNull(credentials, "null 'credentials' provided");
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
*/
|
||||
public void setTemporaryDirectory(File temporaryDirectory) {
|
||||
Assert.notNull(temporaryDirectory, "Provided temporaryDirectory is null");
|
||||
Assert.isTrue(temporaryDirectory.exists(),"The given temporary directory does not exist");
|
||||
Assert.isTrue(temporaryDirectory.exists(), "The given temporary directory does not exist");
|
||||
Assert.isTrue(temporaryDirectory.isDirectory(), "The given temporary directory path has to be a directory");
|
||||
this.temporaryDirectory = temporaryDirectory;
|
||||
}
|
||||
@@ -124,7 +122,7 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
* @param temporaryDirectory
|
||||
*/
|
||||
public void setTemporaryDirectory(String temporaryDirectory) {
|
||||
Assert.hasText(temporaryDirectory,"Provided temporary directory string is null or empty string");
|
||||
Assert.hasText(temporaryDirectory, "Provided temporary directory string is null or empty string");
|
||||
setTemporaryDirectory(new File(temporaryDirectory));
|
||||
}
|
||||
|
||||
@@ -144,7 +142,7 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
*/
|
||||
public void setTemporaryFileSuffix(String temporaryFileSuffix) {
|
||||
Assert.hasText(temporaryFileSuffix, "The temporary file suffix must not be null or empty");
|
||||
if(!temporaryFileSuffix.startsWith(".")) {
|
||||
if (!temporaryFileSuffix.startsWith(".")) {
|
||||
temporaryFileSuffix = "." + temporaryFileSuffix;
|
||||
}
|
||||
|
||||
@@ -194,16 +192,16 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
* @param in the Stream from which the data of the Object is to be read
|
||||
* @param objectName the name of the object that would be used to upload the file
|
||||
*/
|
||||
private File getTempFile(InputStream in,String bucketName,String objectName) {
|
||||
private File getTempFile(InputStream in, String bucketName, String objectName) {
|
||||
InputStream inStream;
|
||||
if(!(in instanceof BufferedInputStream) && !(in instanceof ByteArrayInputStream)) {
|
||||
if (!(in instanceof BufferedInputStream) && !(in instanceof ByteArrayInputStream)) {
|
||||
inStream = new BufferedInputStream(in);
|
||||
}
|
||||
else {
|
||||
inStream = in;
|
||||
}
|
||||
String fileName;
|
||||
if(objectName.contains(PATH_SEPARATOR)) {
|
||||
if (objectName.contains(PATH_SEPARATOR)) {
|
||||
String[] splits = objectName.split(PATH_SEPARATOR);
|
||||
fileName = splits[splits.length - 1];
|
||||
}
|
||||
@@ -215,7 +213,7 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
|
||||
String filePath = temporaryDirectory.getAbsoluteFile() + File.separator + fileName + temporaryFileSuffix;
|
||||
|
||||
if(logger.isDebugEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Temporary file path is " + filePath);
|
||||
}
|
||||
|
||||
@@ -226,35 +224,40 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
fos = new FileOutputStream(tempFile);
|
||||
byte[] bytes = new byte[1024];
|
||||
int read = 0;
|
||||
while(true) {
|
||||
while (true) {
|
||||
read = inStream.read(bytes);
|
||||
if(read == -1) {
|
||||
if (read == -1) {
|
||||
break;
|
||||
}
|
||||
fos.write(bytes, 0, read);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
throw new AmazonS3OperationException(credentials.getAccessKey(),
|
||||
bucketName,
|
||||
objectName,
|
||||
"Exception caught while writing the temporary file from input stream", e);
|
||||
} catch(IOException ioe) {
|
||||
bucketName,
|
||||
objectName,
|
||||
"Exception caught while writing the temporary file from input stream", e);
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
throw new AmazonS3OperationException(credentials.getAccessKey(),
|
||||
bucketName,
|
||||
objectName,
|
||||
"Exception caught while reading from the provided input stream", ioe);
|
||||
} finally {
|
||||
if(fos != null) {
|
||||
bucketName,
|
||||
objectName,
|
||||
"Exception caught while reading from the provided input stream", ioe);
|
||||
}
|
||||
finally {
|
||||
if (fos != null) {
|
||||
try {
|
||||
fos.flush();
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
//just log
|
||||
logger.error("Unable to close the stream to the temp file being created", e);
|
||||
}
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
//just log
|
||||
logger.error("Unable to close the input stream source", e);
|
||||
}
|
||||
@@ -278,8 +281,8 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
@Override
|
||||
public final void putObject(String bucketName, String folder, String objectName,
|
||||
AmazonS3Object s3Object) {
|
||||
Assert.hasText(bucketName,"null or empty bucketName provided");
|
||||
Assert.hasText(objectName,"null or empty object name provided");
|
||||
Assert.hasText(bucketName, "null or empty bucketName provided");
|
||||
Assert.hasText(objectName, "null or empty object name provided");
|
||||
Assert.notNull(s3Object, "null s3 object provided for upload");
|
||||
|
||||
|
||||
@@ -289,10 +292,10 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
"Exactly one of file or inpuut stream needed in the provided s3 object");
|
||||
|
||||
boolean isTempFile = false;
|
||||
if(in != null) {
|
||||
if (in != null) {
|
||||
//We don't know the source of the stream and hence we read the content
|
||||
//and write to the temporary file.
|
||||
file = getTempFile(in,bucketName,objectName);
|
||||
file = getTempFile(in, bucketName, objectName);
|
||||
isTempFile = true;
|
||||
}
|
||||
|
||||
@@ -306,15 +309,17 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
String stringContentMD5 = null;
|
||||
try {
|
||||
stringContentMD5 =
|
||||
encodeHex(getContentsMD5AsBytes(file));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
AWSCommonUtils.encodeHex(AWSCommonUtils.getContentsMD5AsBytes(file));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
logger.error("Exception while generating the content's MD5 of the file " + file.getAbsolutePath(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
doPut(bucketName, key, file, s3Object.getObjectACL(),
|
||||
s3Object.getUserMetaData(), stringContentMD5);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new AmazonS3OperationException(
|
||||
credentials.getAccessKey(), bucketName,
|
||||
key,
|
||||
@@ -323,13 +328,13 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
|
||||
}
|
||||
|
||||
if(isTempFile) {
|
||||
if (isTempFile) {
|
||||
//Delete the temp file
|
||||
if(logger.isDebugEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Deleting temp file: " + file.getName());
|
||||
}
|
||||
boolean deleteSuccessful = file.delete();
|
||||
if(!deleteSuccessful) {
|
||||
if (!deleteSuccessful) {
|
||||
logger.warn("Unable to delete file '" + file.getName() + "'");
|
||||
}
|
||||
}
|
||||
@@ -344,14 +349,14 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
* @param objectName
|
||||
*/
|
||||
private String getKeyFromFolder(String folder, String objectName) {
|
||||
if(objectName.startsWith(PATH_SEPARATOR)) {
|
||||
if (objectName.startsWith(PATH_SEPARATOR)) {
|
||||
//remove the leading / of the object name
|
||||
objectName = objectName.substring(1);
|
||||
}
|
||||
String key;
|
||||
if(folder != null) {
|
||||
key = folder.endsWith(PATH_SEPARATOR)?
|
||||
folder + objectName:folder + PATH_SEPARATOR + objectName;
|
||||
if (folder != null) {
|
||||
key = folder.endsWith(PATH_SEPARATOR) ?
|
||||
folder + objectName : folder + PATH_SEPARATOR + objectName;
|
||||
}
|
||||
else {
|
||||
key = objectName;
|
||||
@@ -360,7 +365,7 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
//check if the foldername begins with a /, if yes, remove it as well as it created
|
||||
//one directory with blank name
|
||||
|
||||
if(key.startsWith(PATH_SEPARATOR)) {
|
||||
if (key.startsWith(PATH_SEPARATOR)) {
|
||||
key = key.substring(1);
|
||||
}
|
||||
return key;
|
||||
@@ -384,22 +389,22 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
* @param pageSize The max number of records to be retrieved in one list object operation.
|
||||
*
|
||||
*/
|
||||
public final PaginatedObjectsView listObjects(String bucketName, String folder, String nextMarker,int pageSize) {
|
||||
public final PaginatedObjectsView listObjects(String bucketName, String folder, String nextMarker, int pageSize) {
|
||||
Assert.hasText(bucketName, "Bucket name should be non null and non empty");
|
||||
Assert.isTrue(pageSize >= 0, "Page size should be a non negative number");
|
||||
|
||||
if(logger.isDebugEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Listing objects from bucket " + bucketName + " and folder " + folder);
|
||||
logger.debug("Next marker is " + nextMarker + " and pageSize is " + pageSize);
|
||||
logger.debug("Next marker is " + nextMarker + " and pageSize is " + pageSize);
|
||||
}
|
||||
|
||||
|
||||
String prefix = null;
|
||||
if(folder != null && !PATH_SEPARATOR.equals(folder)) {
|
||||
if (folder != null && !PATH_SEPARATOR.equals(folder)) {
|
||||
prefix = folder;
|
||||
}
|
||||
//check if the prefix begins with /
|
||||
if(prefix != null && prefix.startsWith(PATH_SEPARATOR)) {
|
||||
if (prefix != null && prefix.startsWith(PATH_SEPARATOR)) {
|
||||
prefix = prefix.substring(1);
|
||||
}
|
||||
|
||||
@@ -416,14 +421,15 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
public final AmazonS3Object getObject(String bucketName, String folder,
|
||||
String objectName) {
|
||||
Assert.hasText(bucketName, "Bucket name should be non null and non empty");
|
||||
if(logger.isDebugEnabled()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Getting from bucket " + bucketName +
|
||||
", from folder " + folder + " the object name " + objectName);
|
||||
}
|
||||
String key = getKeyFromFolder(folder, objectName);
|
||||
try {
|
||||
return doGetObject(bucketName, key);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new AmazonS3OperationException(
|
||||
credentials.getAccessKey(), bucketName,
|
||||
key,
|
||||
@@ -467,34 +473,37 @@ public abstract class AbstractAmazonS3Operations implements AmazonS3Operations,I
|
||||
* @param stringContentMD5 The MD5 sum of the contents of the file to be uploaded
|
||||
*
|
||||
*/
|
||||
protected abstract void doPut(String bucket,String key,File file,
|
||||
AmazonS3ObjectACL objectACL, Map<String, String> userMetadata,String stringContentMD5);
|
||||
protected abstract void doPut(String bucket, String key, File file,
|
||||
AmazonS3ObjectACL objectACL, Map<String, String> userMetadata, String stringContentMD5);
|
||||
|
||||
|
||||
static class PagninatedObjectsViewImpl implements PaginatedObjectsView {
|
||||
|
||||
private final List<S3ObjectSummary> objectSummary;
|
||||
|
||||
private final String nextMarker;
|
||||
|
||||
public PagninatedObjectsViewImpl(List<S3ObjectSummary> objectSummary,
|
||||
String nextMarker) {
|
||||
this.objectSummary = objectSummary;
|
||||
this.nextMarker = nextMarker;
|
||||
}
|
||||
|
||||
|
||||
public List<S3ObjectSummary> getObjectSummary() {
|
||||
return objectSummary != null ? objectSummary : new ArrayList<S3ObjectSummary>();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasMoreResults() {
|
||||
return nextMarker != null;
|
||||
}
|
||||
|
||||
|
||||
public String getNextMarker() {
|
||||
return nextMarker;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PagninatedObjectsViewImpl implements PaginatedObjectsView {
|
||||
|
||||
private final List<S3ObjectSummary> objectSummary;
|
||||
private final String nextMarker;
|
||||
|
||||
public PagninatedObjectsViewImpl(List<S3ObjectSummary> objectSummary,
|
||||
String nextMarker) {
|
||||
this.objectSummary = objectSummary;
|
||||
this.nextMarker = nextMarker;
|
||||
}
|
||||
|
||||
|
||||
public List<S3ObjectSummary> getObjectSummary() {
|
||||
return objectSummary != null?objectSummary:new ArrayList<S3ObjectSummary>();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasMoreResults() {
|
||||
return nextMarker != null;
|
||||
}
|
||||
|
||||
|
||||
public String getNextMarker() {
|
||||
return nextMarker;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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,12 +18,13 @@ package org.springframework.integration.aws.ses.config.xml;
|
||||
|
||||
import org.springframework.integration.aws.config.xml.AbstractAWSOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.aws.ses.AmazonSESMessageHandler;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
* parse the <ses-outbound-channel-adapter/> of the "int-aws" namespace
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/integration"
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.2.xsd"/>
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration.xsd"/>
|
||||
|
||||
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -23,14 +23,15 @@ import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.aws.core.AWSCredentials;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
* The Abstract test class for the AWS outbound adapter parsers
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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,7 +18,6 @@ package org.springframework.integration.aws.s3;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.springframework.integration.aws.common.AWSTestUtils.md5Hash;
|
||||
import static org.springframework.integration.aws.s3.AmazonS3OperationsMockingUtil.BUCKET;
|
||||
import static org.springframework.integration.aws.s3.AmazonS3OperationsMockingUtil.mockAmazonS3Operations;
|
||||
import static org.springframework.integration.aws.s3.AmazonS3OperationsMockingUtil.mockS3Operations;
|
||||
import static org.springframework.integration.test.util.TestUtils.getPropertyValue;
|
||||
@@ -32,19 +31,23 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.aws.core.BasicAWSCredentials;
|
||||
import org.springframework.integration.aws.s3.core.AbstractAmazonS3Operations;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Object;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3ObjectACL;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Operations;
|
||||
import org.springframework.integration.aws.s3.core.PaginatedObjectsView;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* The test class for {@link AmazonS3InboundSynchronizationMessageSource}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
@@ -53,6 +56,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
private static AmazonS3Operations operations;
|
||||
|
||||
|
||||
@@ -65,7 +69,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing null credentials.
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullCredentials() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setCredentials(null);
|
||||
@@ -74,7 +78,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing null temporary suffix
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullTempSuffix() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setTemporarySuffix(null);
|
||||
@@ -83,7 +87,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing null wildcard
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullWildcard() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setFileNameWildcard(null);
|
||||
@@ -92,7 +96,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing null regex
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullRegex() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setFileNameRegex(null);
|
||||
@@ -101,7 +105,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing both regex and wildcard
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withBothRegexAndWildcard() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setFileNameRegex("[a-z]+\\.txt");
|
||||
@@ -111,7 +115,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests by providing both wildcard and regex, unlike previous one, this sets the wildcard first
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withBothWildcardAndRegex() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setFileNameWildcard("*.txt");
|
||||
@@ -122,7 +126,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
* Tests providing null remote directory
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullRemoteDirectory() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setRemoteDirectory(null);
|
||||
@@ -131,10 +135,11 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
/**
|
||||
*Tests with a non existent local directory
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNonExistentLocalDirectory() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setDirectory(new LiteralExpression("SomeNotExistentDir"));
|
||||
src.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
src.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -142,18 +147,19 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
* Tests with a {@link File} instance that is not a directory
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNonDirectory() throws IOException {
|
||||
File file = temp.newFile("SomeFile.txt");
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setDirectory(new LiteralExpression(file.getAbsolutePath()));
|
||||
src.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
src.afterPropertiesSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests with a null s3 operation.
|
||||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void withNullS3Operations() {
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setS3Operations(null);
|
||||
@@ -170,12 +176,12 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
src.setTemporarySuffix(".temp");
|
||||
src.setCredentials(credentials);
|
||||
src.setDirectory(new LiteralExpression(temp.getRoot().getAbsolutePath()));
|
||||
src.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
src.afterPropertiesSet();
|
||||
assertEquals(".temp", getPropertyValue(src, "s3Operations.temporaryFileSuffix", String.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates with a custom implementation of {@link AmazonS3Operations}
|
||||
* which extends from {@link AbstractAmazonS3Operations}. Also sets the following
|
||||
@@ -216,14 +222,15 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
src.setTemporarySuffix(".temp");
|
||||
src.setAcceptSubFolders(true);
|
||||
src.setDirectory(new LiteralExpression(temp.getRoot().getAbsolutePath()));
|
||||
src.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
src.afterPropertiesSet();
|
||||
|
||||
assertEquals(ops, getPropertyValue(src, "s3Operations",AmazonS3Operations.class));
|
||||
assertEquals(".temp", getPropertyValue(src, "s3Operations.temporaryFileSuffix",String.class));
|
||||
assertEquals(ops, getPropertyValue(src, "s3Operations", AmazonS3Operations.class));
|
||||
assertEquals(".temp", getPropertyValue(src, "s3Operations.temporaryFileSuffix", String.class));
|
||||
assertEquals("testbucket", getPropertyValue(src, "bucket", String.class));
|
||||
assertEquals(temp.getRoot(), getPropertyValue(src, "directory"));
|
||||
assertEquals("[a-z]+\\.txt", getPropertyValue(src, "synchronizer.fileNameRegex", String.class));
|
||||
assertEquals(true, getPropertyValue(src, "synchronizer.acceptSubFolders", Boolean.class).booleanValue());
|
||||
assertEquals(true, getPropertyValue(src, "synchronizer.acceptSubFolders", Boolean.class));
|
||||
assertEquals(15, getPropertyValue(src, "synchronizer.maxObjectsPerBatch", Integer.class).intValue());
|
||||
assertEquals("remotedirectory", getPropertyValue(src, "remoteDirectory", String.class));
|
||||
}
|
||||
@@ -234,14 +241,14 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
@Test
|
||||
public void synchronizeWithLocalDirectory() {
|
||||
mockAmazonS3Operations(Arrays.asList(
|
||||
new String[]{"test.txt","test.txt",md5Hash("test.txt"),null},
|
||||
new String[]{"sub1/test.txt","sub1/test.txt",md5Hash("sub1/test.txt"),null},
|
||||
new String[]{"sub1/sub11/test.txt","sub1/sub11/test.txt",md5Hash("sub1/sub11/test.txt"),null},
|
||||
new String[]{"sub2/test.txt","sub2/test.txt",md5Hash("sub2/test.txt"),null}
|
||||
));
|
||||
new String[] {"test.txt", "test.txt", md5Hash("test.txt"), null},
|
||||
new String[] {"sub1/test.txt", "sub1/test.txt", md5Hash("sub1/test.txt"), null},
|
||||
new String[] {"sub1/sub11/test.txt", "sub1/sub11/test.txt", md5Hash("sub1/sub11/test.txt"), null},
|
||||
new String[] {"sub2/test.txt", "sub2/test.txt", md5Hash("sub2/test.txt"), null}
|
||||
));
|
||||
AmazonS3InboundSynchronizationMessageSource src = new AmazonS3InboundSynchronizationMessageSource();
|
||||
src.setS3Operations(operations);
|
||||
src.setBucket(BUCKET);
|
||||
src.setBucket(AmazonS3OperationsMockingUtil.BUCKET);
|
||||
src.setDirectory(new LiteralExpression(temp.getRoot().getAbsolutePath()));
|
||||
src.setFileNameRegex("[a-z]+\\.txt");
|
||||
src.setRemoteDirectory("/sub1");
|
||||
@@ -249,6 +256,7 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
src.setTemporarySuffix(".temp");
|
||||
src.setAcceptSubFolders(true);
|
||||
src.setDirectory(new LiteralExpression(temp.getRoot().getAbsolutePath()));
|
||||
src.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
src.afterPropertiesSet();
|
||||
File file = src.receive().getPayload();
|
||||
assertEquals(temp.getRoot().getAbsoluteFile() +
|
||||
@@ -261,4 +269,5 @@ public class AmazonS3InboundSynchronizationMessageSourceTests {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -40,20 +40,23 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.aws.core.BasicAWSCredentials;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Object;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Operations;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
|
||||
/**
|
||||
* The test class for {@link AmazonS3MessageHandler}, we rely on mock of {@link AmazonS3Operations}
|
||||
* to test the behavior.
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
@@ -90,6 +93,7 @@ public class AmazonS3MessageHandlerTests {
|
||||
//set the remote directory to root by default
|
||||
handler.setRemoteDirectoryExpression(new LiteralExpression("/"));
|
||||
handler.setBucket("TestBucket");
|
||||
handler.setBeanFactory(Mockito.mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
return handler;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -25,14 +25,15 @@ import org.junit.Rule;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
|
||||
/**
|
||||
* The test class for {@link DefaultFileNameGenerationStrategy}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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,17 +28,18 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.aws.s3.AmazonS3MessageHandler;
|
||||
import org.springframework.integration.aws.s3.FileNameGenerationStrategy;
|
||||
import org.springframework.integration.aws.s3.core.AmazonS3Operations;
|
||||
import org.springframework.integration.aws.s3.core.DefaultAmazonS3Operations;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* The test case for the aws-s3 namespace's {@link AmazonS3OutboundChannelAdapterParser} class
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -36,17 +36,18 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
|
||||
|
||||
/**
|
||||
* The test class for {@link AmazonSESMessageHandler}
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -22,9 +22,9 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
import com.amazonaws.services.simpleemail.AWSJavaMailTransport;
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.amazonaws.services.simpleemail.AWSJavaMailTransport;
|
||||
* The test class for the AmazonSESOutboundAdapterParser
|
||||
*
|
||||
* @author Amol Nayak
|
||||
* @author Rob Harrop
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user