INTEXT-221: Document S3 Gateway & CheckStyle

JIRA: https://jira.spring.io/browse/INTEXT-221

Also apply Checkstyle for the project
Move testing to the `AssertJ`
Adjust `.travis.yml` for Gradle 2.13
Add `CODE_OF_CONDUCT.adoc`
This commit is contained in:
Artem Bilan
2016-05-18 18:44:38 -04:00
parent f946a1d5e9
commit 5d4bcb37db
39 changed files with 1000 additions and 696 deletions

View File

@@ -1,2 +1,11 @@
language: java
jdk: oraclejdk8
install: true
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
script:
- ./gradlew check --no-daemon

44
CODE_OF_CONDUCT.adoc Normal file
View File

@@ -0,0 +1,44 @@
= Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open
and welcoming community, we pledge to respect all people who contribute through reporting
issues, posting feature requests, updating documentation, submitting pull requests or
patches, and other activities.
We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses,
without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
that they deem inappropriate, threatening, offensive, or harmful.
By adopting this Code of Conduct, project maintainers commit themselves to fairly and
consistently applying these principles to every aspect of managing this project. Project
maintainers who do not follow or enforce the Code of Conduct may be permanently removed
from the project team.
This Code of Conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will
be reviewed and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. Maintainers are obligated to maintain confidentiality
with regard to the reporter of an incident.
This Code of Conduct is adapted from the
http://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at
http://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/]

View File

@@ -155,6 +155,18 @@ See more information in the `S3MessageHandler` JavaDocs and `<int-aws:s3-outboun
###Outbound Gateway
The S3 Outbound Gateway is represented by the same `S3MessageHandler` with the `produceReply = true` constructor
argument for Java Configuration and `<int-aws:s3-outbound-gateway>` for xml definitions.
The "request-reply" nature of this gateway is async and the `Transfer` result from the `TransferManager`
operation is sent to the `outputChannel`, assuming the transfer progress observation in the downstream flow.
The `S3ProgressListener can be supplied to track the transfer progress.
Also the listener can be populated into the returned `Transfer` afterwards in the downstream flow.
See more information in the `S3MessageHandler` JavaDocs and `<int-aws:s3-outbound-channel-adapter>` &
`<int-aws:s3-outbound-gateway>` descriptions.
##Simple Email Service (SES)
There is no adapter for SES, since [Spring Cloud AWS][] provides implementations for

View File

@@ -14,10 +14,11 @@ plugins {
description = 'Spring Integration AWS Support'
apply plugin: 'java'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
group = 'org.springframework.integration'
@@ -28,7 +29,15 @@ repositories {
maven { url 'http://repo.spring.io/libs-milestone' }
}
sourceCompatibility = targetCompatibility = 1.7
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
if (project.hasProperty('platformVersion')) {
apply plugin: 'spring-io'
@@ -43,6 +52,7 @@ if (project.hasProperty('platformVersion')) {
}
ext {
assertjVersion = '3.4.1'
servletApiVersion = '3.1.0'
slf4jVersion = '1.7.21'
springCloudAwsVersion = '1.1.0.RELEASE'
@@ -51,30 +61,36 @@ ext {
idPrefix = 'aws'
linkHomepage = 'https://github.com/spring-projects/spring-integration-aws'
linkCi = 'https://build.spring.io/browse/INTEXT'
linkIssue = 'https://jira.spring.io/browse/INTEXT'
linkScmUrl = 'https://github.com/spring-projects/spring-integration-aws'
linkScmConnection = 'https://github.com/spring-projects/spring-integration-aws.git'
linkCi = 'https://build.spring.io/browse/INTEXT'
linkIssue = 'https://jira.spring.io/browse/INTEXT'
linkScmUrl = 'https://github.com/spring-projects/spring-integration-aws'
linkScmConnection = 'https://github.com/spring-projects/spring-integration-aws.git'
linkScmDevConnection = 'git@github.com:spring-projects/spring-integration-aws.git'
}
ext.javadocLinks = [
"http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/"
"http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/"
] as String[]
jacoco {
toolVersion = "0.7.6.201602180812"
}
checkstyle {
configFile = file('src/checkstyle/checkstyle.xml')
toolVersion = '6.18'
}
dependencies {
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
compile ("org.springframework.cloud:spring-cloud-aws-messaging:$springCloudAwsVersion", optional)
compile ("org.springframework.integration:spring-integration-file:$springIntegrationVersion", optional)
compile ("org.springframework.integration:spring-integration-http:$springIntegrationVersion", optional)
compile ("javax.servlet:javax.servlet-api:$servletApiVersion", provided)
compile("org.springframework.cloud:spring-cloud-aws-messaging:$springCloudAwsVersion", optional)
compile("org.springframework.integration:spring-integration-file:$springIntegrationVersion", optional)
compile("org.springframework.integration:spring-integration-http:$springIntegrationVersion", optional)
compile("javax.servlet:javax.servlet-api:$servletApiVersion", provided)
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
testCompile "org.assertj:assertj-core:$assertjVersion"
testRuntime "org.slf4j:slf4j-log4j12:$slf4jVersion"
}
@@ -170,7 +186,7 @@ task schemaZip(type: Zip) {
group = 'Distribution'
classifier = 'schema'
description = "Builds -${classifier} archive containing all " +
"XSDs for deployment at static.springframework.org/schema."
"XSDs for deployment at static.springframework.org/schema."
def Properties schemas = new Properties();
def shortName = idPrefix.replaceFirst("${idPrefix}-", '')
@@ -184,7 +200,7 @@ task schemaZip(type: Zip) {
it.path.replaceAll('\\\\', '/').endsWith(schemas.get(key))
}
assert xsdFile != null
into ("integration/${shortName}") {
into("integration/${shortName}") {
from xsdFile.path
}
}
@@ -192,18 +208,18 @@ task schemaZip(type: Zip) {
}
task docsZip(type: Zip) {
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing the JavaDoc api " +
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing the JavaDoc api " +
"for deployment at static.springframework.org/spring-integration/docs."
from('.') {
include 'README.md'
}
from('.') {
include 'README.md'
}
from (javadoc) {
into 'api'
}
from(javadoc) {
into 'api'
}
}
@@ -211,7 +227,7 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
group = 'Distribution'
classifier = 'dist'
description = "Builds -${classifier} archive, containing all jars and docs, " +
"suitable for community download page."
"suitable for community download page."
ext.baseDir = "${project.name}-${project.version}";
@@ -230,7 +246,7 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
into "${baseDir}/schema"
}
into ("${baseDir}/libs") {
into("${baseDir}/libs") {
from project.jar
from project.sourcesJar
from project.javadocJar
@@ -243,7 +259,7 @@ task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
group = 'Distribution'
classifier = 'dist-with-deps'
description = "Builds -${classifier} archive, containing everything " +
"in the -${distZip.classifier} archive plus all dependencies."
"in the -${distZip.classifier} archive plus all dependencies."
from zipTree(distZip.archivePath)

View File

@@ -0,0 +1,17 @@
^\Q/*\E$
^\Q * Copyright \E20\d\d(\-20\d\d)?\Q the original author or authors.\E$
^\Q *\E$
^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
^\Q * you may not use this file except in compliance with the License.\E$
^\Q * You may obtain a copy of the License at\E$
^\Q *\E$
^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$
^\Q *\E$
^\Q * Unless required by applicable law or agreed to in writing, software\E$
^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
^\Q * See the License for the specific language governing permissions and\E$
^\Q * limitations under the License.\E$
^\Q */\E$
^$
^.*$

View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="package-info\.java" checks=".*" />
<suppress files="[\\/]test[\\/]" checks="RequireThis" />
<suppress files="[\\/]test[\\/]" checks="FinalClass" />
<suppress files="[\\/]test[\\/]" checks="AvoidStaticImport" />
<suppress files="[\\/]test[\\/]" checks="InnerTypeLast" />
<suppress files="[\\/]test[\\/]" checks="Javadoc*" />
</suppressions>

View File

@@ -0,0 +1,183 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="src/checkstyle/checkstyle-suppressions.xml" />
</module>
<!-- Root Checks -->
<module name="RegexpHeader">
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt" />
<property name="fileExtensions" value="java" />
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<!-- TreeWalker Checks -->
<module name="TreeWalker">
<!-- Annotations -->
<module name="AnnotationUseStyle">
<property name="elementStyle" value="compact" />
</module>
<module name="MissingOverride" />
<module name="PackageAnnotation" />
<module name="AnnotationLocation">
<property name="allowSamelineSingleParameterlessAnnotation"
value="false" />
</module>
<!-- Block Checks -->
<module name="EmptyBlock">
<property name="option" value="text" />
</module>
<module name="LeftCurly" />
<module name="RightCurly">
<property name="option" value="alone" />
</module>
<module name="NeedBraces" />
<module name="AvoidNestedBlocks" />
<!-- Class Design -->
<module name="FinalClass" />
<module name="InterfaceIsType" />
<module name="HideUtilityClassConstructor" />
<module name="MutableException" />
<module name="InnerTypeLast" />
<module name="OneTopLevelClass" />
<!-- Coding -->
<module name="CovariantEquals" />
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="InnerAssignment" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="NestedForDepth">
<property name="max" value="3" />
</module>
<module name="NestedIfDepth">
<property name="max" value="4" />
</module>
<module name="NestedTryDepth">
<property name="max" value="3" />
</module>
<module name="MultipleVariableDeclarations" />
<module name="RequireThis">
<property name="checkMethods" value="false" />
</module>
<module name="OneStatementPerLine" />
<!-- Imports -->
<module name="AvoidStarImport" />
<module name="AvoidStaticImport">
<property name="excludes"
value="org.assertj.core.api.Assertions.*,
org.junit.Assert.*,
org.junit.Assume.*,
org.junit.internal.matchers.ThrowableMessageMatcher.*,
org.hamcrest.CoreMatchers.*,
org.hamcrest.Matchers.*,
org.mockito.Mockito.*,
org.mockito.BDDMockito.*,
org.mockito.Matchers.*" />
</module>
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports">
<property name="processJavadoc" value="true" />
</module>
<module name="ImportOrder">
<property name="groups" value="java,/^javax?\./,org,org.springframework,*" />
<property name="ordered" value="true" />
<property name="separated" value="true" />
<property name="option" value="top" />
<property name="sortStaticImportsAlphabetically" value="true" />
</module>
<!-- Javadoc Comments -->
<module name="JavadocType">
<property name="scope" value="package"/>
<property name="authorFormat" value=".+\s.+"/>
</module>
<module name="JavadocMethod">
<property name="allowMissingJavadoc" value="true" />
</module>
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>
<module name="JavadocStyle">
<property name="checkEmptyJavadoc" value="true"/>
</module>
<module name="NonEmptyAtclauseDescription" />
<module name="JavadocTagContinuationIndentation">
<property name="offset" value="0"/>
</module>
<module name="AtclauseOrder">
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
<property name="tagOrder" value="@param, @author, @since, @see, @version, @serial, @deprecated"/>
</module>
<module name="AtclauseOrder">
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
<property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>
</module>
<!-- Miscellaneous -->
<module name="CommentsIndentation">
<property name="tokens" value="BLOCK_COMMENT_BEGIN" />
</module>
<module name="UpperEll" />
<module name="ArrayTypeStyle" />
<module name="OuterTypeFilename" />
<!-- Modifiers -->
<module name="RedundantModifier" />
<!-- Regexp -->
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* +\t*\S" />
<property name="message"
value="Line has leading space characters; indentation should be performed with tabs only." />
<property name="ignoreComments" value="true" />
</module>
<module name="RegexpSinglelineJava">
<property name="maximum" value="0"/>
<property name="format" value="org\.mockito\..*Mockito\.(when|doThrow|doAnswer)" />
<property name="message"
value="Please use BDDMockito instead of Mockito.(when|doThrow|doAnswer)." />
<property name="ignoreComments" value="true" />
</module>
<module name="RegexpSinglelineJava">
<property name="maximum" value="0"/>
<property name="format" value="org\.junit\.Assert\.assert" />
<property name="message"
value="Please use AssertJ imports." />
<property name="ignoreComments" value="true" />
</module>
<module name="Regexp">
<property name="format" value="[ \t]+$" />
<property name="illegalPattern" value="true" />
<property name="message" value="Trailing whitespace" />
</module>
<module name="Regexp">
<property name="format" value="System.(out|err).print" />
<property name="illegalPattern" value="true" />
<property name="message" value="System.out or .err" />
</module>
<!-- Whitespace -->
<module name="GenericWhitespace" />
<module name="MethodParamPad" />
<module name="NoWhitespaceAfter" >
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
</module>
<module name="NoWhitespaceBefore" />
<module name="ParenPad" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />
</module>
</module>

View File

@@ -19,7 +19,7 @@ package org.springframework.integration.aws.config.xml;
import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
/**
* The namespace handler for "int-aws" namespace
* The namespace handler for "int-aws" namespace.
*
* @author Amol Nayak
* @author Artem Bilan

View File

@@ -17,7 +17,7 @@
package org.springframework.integration.aws.config.xml;
/**
* The utility class for the namespace parsers
* The utility class for the namespace parsers.
*
* @author Amol Nayak
* @author Artem Bilan
@@ -26,14 +26,31 @@ package org.springframework.integration.aws.config.xml;
*/
public final class AwsParserUtils {
/**
* The 'sqs' reference attribute name.
*/
public static final String SQS_REF = "sqs";
/**
* The 'sns' reference attribute name.
*/
public static final String SNS_REF = "sns";
/**
* The 's3' reference attribute name.
*/
public static final String S3_REF = "s3";
/**
* The 'resource-id-resolver' reference attribute name.
*/
public static final String RESOURCE_ID_RESOLVER_REF = "resource-id-resolver";
/**
* The 'queue-messaging-template' reference attribute name.
*/
public static final String QUEUE_MESSAGING_TEMPLATE_REF = "queue-messaging-template";
private AwsParserUtils() {
super();
}

View File

@@ -1,17 +1,17 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -23,7 +23,8 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
/**
* The parser for the {@code <int-aws:sns-outbound-channel-adapter>}
* The parser for the {@code <int-aws:s3-outbound-channel-adapter>}.
*
* @author Artem Bilan
*/
public class S3OutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {

View File

@@ -1,17 +1,17 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -27,6 +27,8 @@ import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.StringUtils;
/**
* The parser for the {@code <int-aws:s3-outbound-gateway>}.
*
* @author Artem Bilan
*/
public class S3OutboundGatewayParser extends AbstractConsumerEndpointParser {

View File

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

View File

@@ -1,17 +1,17 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -23,7 +23,8 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
/**
* The parser for the {@code <int-aws:sns-outbound-channel-adapter>}
* The parser for the {@code <int-aws:sns-outbound-channel-adapter>}.
*
* @author Artem Bilan
*/
public class SnsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {

View File

@@ -1,17 +1,17 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -26,6 +26,8 @@ import org.springframework.integration.config.xml.AbstractConsumerEndpointParser
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
/**
* The parser for the {@code <int-aws:sns-outbound-gateway>}.
*
* @author Artem Bilan
*/
public class SnsOutboundGatewayParser extends AbstractConsumerEndpointParser {

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -29,7 +29,7 @@ import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.StringUtils;
/**
* The parser for the {@code <int-aws:sqs-message-driven-channel-adapter>}
* The parser for the {@code <int-aws:sqs-message-driven-channel-adapter>}.
*
* @author Artem Bilan
*/

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
@@ -28,33 +28,31 @@ import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.StringUtils;
/**
* The parser for the {@code <int-aws:sqs-outbound-channel-adapter>}
* The parser for the {@code <int-aws:sqs-outbound-channel-adapter>}.
*
* @author Artem Bilan
* @author Rahul Pilani
*/
public class SqsOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
public static final String QUEUE_MESSAGING_TEMPLATE_REF = "queue-messaging-template";
@Override
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SqsMessageHandler.class);
String template = element.getAttribute(QUEUE_MESSAGING_TEMPLATE_REF);
String template = element.getAttribute(AwsParserUtils.QUEUE_MESSAGING_TEMPLATE_REF);
boolean hasTemplate = StringUtils.hasText(template);
String sqs = element.getAttribute(AwsParserUtils.SQS_REF);
boolean hasSqs = StringUtils.hasText(sqs);
String resourceIdResolver = element.getAttribute(AwsParserUtils.RESOURCE_ID_RESOLVER_REF);
boolean hasResourceIdResolver = StringUtils.hasText(resourceIdResolver);
if (hasTemplate && (hasSqs || hasResourceIdResolver)) {
parserContext.getReaderContext().error(QUEUE_MESSAGING_TEMPLATE_REF +
parserContext.getReaderContext().error(AwsParserUtils.QUEUE_MESSAGING_TEMPLATE_REF +
" should not be defined in conjunction with " + AwsParserUtils.SQS_REF
+ " or " + AwsParserUtils.RESOURCE_ID_RESOLVER_REF, element);
}
if (!hasTemplate && !hasSqs) {
parserContext.getReaderContext().error("One of " + QUEUE_MESSAGING_TEMPLATE_REF + " or "
parserContext.getReaderContext().error("One of " + AwsParserUtils.QUEUE_MESSAGING_TEMPLATE_REF + " or "
+ AwsParserUtils.SQS_REF + " must be defined.", element);
}

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.inbound;
@@ -199,11 +199,11 @@ public class SnsInboundChannelAdapter extends HttpRequestHandlingMessagingGatewa
private static class NotificationStatusResolver extends NotificationStatusHandlerMethodArgumentResolver {
public NotificationStatusResolver(AmazonSNS amazonSns) {
NotificationStatusResolver(AmazonSNS amazonSns) {
super(amazonSns);
}
protected NotificationStatus resolveNotificationStatus(JsonNode content) {
NotificationStatus resolveNotificationStatus(JsonNode content) {
return (NotificationStatus) doResolveArgumentFromNotificationMessage(content, null, null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 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.
@@ -45,7 +45,7 @@ import com.amazonaws.services.sqs.AmazonSQSAsync;
* Works in 'listener' manner and delegates hard to the {@link SimpleMessageListenerContainer}.
*
* @author Artem Bilan
* *
*
* @see SimpleMessageListenerContainerFactory
* @see SimpleMessageListenerContainer
* @see QueueMessageHandler
@@ -135,7 +135,9 @@ public class SqsMessageDrivenChannelAdapter extends MessageProducerSupport
@Override
public Map<MappingInformation, HandlerMethod> getHandlerMethods() {
Set<String> queues = new HashSet<>(Arrays.asList(SqsMessageDrivenChannelAdapter.this.queues));
return Collections.singletonMap(new MappingInformation(queues, messageDeletionPolicy), null);
MappingInformation mappingInformation = new MappingInformation(queues,
SqsMessageDrivenChannelAdapter.this.messageDeletionPolicy);
return Collections.singletonMap(mappingInformation, null);
}
@Override

View File

@@ -396,7 +396,7 @@ public class S3MessageHandler extends AbstractReplyProducingMessageHandler {
@Override
public void progressChanged(ProgressEvent progressEvent) {
if (ProgressEventType.TRANSFER_COMPLETED_EVENT.equals(progressEvent.getEventType())) {
transferManager.getAmazonS3Client().setObjectAcl(theAclRequest);
S3MessageHandler.this.transferManager.getAmazonS3Client().setObjectAcl(theAclRequest);
}
}
@@ -505,8 +505,28 @@ public class S3MessageHandler extends AbstractReplyProducingMessageHandler {
return bucketName;
}
/**
* The {@link S3MessageHandler} mode.
*
* @see #setCommand
*/
public enum Command {
UPLOAD, DOWNLOAD, COPY
/**
* The command to perform {@link TransferManager#upload} operation.
*/
UPLOAD,
/**
* The command to perform {@link TransferManager#download} operation.
*/
DOWNLOAD,
/**
* The command to perform {@link TransferManager#copy} operation.
*/
COPY
}
/**
@@ -523,14 +543,14 @@ public class S3MessageHandler extends AbstractReplyProducingMessageHandler {
private final MessageHeaders messageHeaders;
public MessageHeadersObjectMetadataProvider(MessageHeaders messageHeaders) {
MessageHeadersObjectMetadataProvider(MessageHeaders messageHeaders) {
this.messageHeaders = messageHeaders;
}
@Override
public void provideObjectMetadata(File file, ObjectMetadata metadata) {
if (uploadMetadataProvider != null) {
uploadMetadataProvider.populateMetadata(metadata,
if (S3MessageHandler.this.uploadMetadataProvider != null) {
S3MessageHandler.this.uploadMetadataProvider.populateMetadata(metadata,
MessageBuilder.createMessage(file, this.messageHeaders));
}
if (metadata.getContentMD5() == null) {

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
@@ -146,10 +146,10 @@ public class SnsMessageHandler extends AbstractReplyProducingMessageHandler {
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
TypeLocator typeLocator = this.evaluationContext.getTypeLocator();
if (typeLocator instanceof StandardTypeLocator) {
/*
* Register the 'org.springframework.integration.aws.support' package
* you don't need a FQCN for the 'SnsMessageBuilder'.
*/
/*
* Register the 'org.springframework.integration.aws.support' package
* you don't need a FQCN for the 'SnsMessageBuilder'.
*/
((StandardTypeLocator) typeLocator).registerImport("org.springframework.integration.aws.support");
}
}

View File

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

View File

@@ -1,40 +1,63 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.support;
/**
* The AWS specific message headers constants.
*
* @author Artem Bilan
*/
public abstract class AwsHeaders {
private static final String PREFIX = "aws_";
/**
* The {@value QUEUE} header for sending/receiving data over SQS.
*/
public static final String QUEUE = PREFIX + "queue";
/**
* The {@value TOPIC} header for sending/receiving data over SNS.
*/
public static final String TOPIC = PREFIX + "topic";
/**
* The {@value MESSAGE_ID} header for SQS/SNS message ids.
*/
public static final String MESSAGE_ID = PREFIX + "messageId";
/**
* The {@value RECEIPT_HANDLE} header for received SQS message.
*/
public static final String RECEIPT_HANDLE = PREFIX + "receiptHandle";
/**
* The {@value NOTIFICATION_STATUS} header for SNS notification status.
*/
public static final String NOTIFICATION_STATUS = PREFIX + "notificationStatus";
/**
* The {@value SNS_MESSAGE_TYPE} header for SNS message type.
*/
public static final String SNS_MESSAGE_TYPE = PREFIX + "snsMessageType";
/**
* The {@value SNS_PUBLISHED_MESSAGE_ID} header for message published over SNS.
*/
public static final String SNS_PUBLISHED_MESSAGE_ID = PREFIX + "snsPublishedMessageId";
}

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.support;
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
*
* @author Artem Bilan
*/
public class SnsBodyBuilder {
public final class SnsBodyBuilder {
private final Map<String, String> snsMessage = new HashMap<>();
@@ -50,7 +50,7 @@ public class SnsBodyBuilder {
public String build() {
StringBuilder stringBuilder = new StringBuilder("{");
for (Map.Entry<String, String> entry : snsMessage.entrySet()) {
for (Map.Entry<String, String> entry : this.snsMessage.entrySet()) {
stringBuilder.append("\"")
.append(entry.getKey())
.append("\":\"")

View File

@@ -16,11 +16,7 @@
package org.springframework.integration.aws.config.xml;
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.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -70,35 +66,37 @@ public class S3InboundChannelAdapterParserTests {
@Test
public void testFtpInboundChannelAdapterComplete() throws Exception {
assertFalse(TestUtils.getPropertyValue(this.s3Inbound, "autoStartup", Boolean.class));
assertThat(TestUtils.getPropertyValue(this.s3Inbound, "autoStartup", Boolean.class)).isFalse();
PriorityBlockingQueue<?> blockingQueue = TestUtils.getPropertyValue(this.s3Inbound,
"source.fileSource.toBeReceived", PriorityBlockingQueue.class);
Comparator<?> comparator = blockingQueue.comparator();
assertSame(this.comparator, comparator);
assertEquals("s3Inbound", this.s3Inbound.getComponentName());
assertEquals("aws:s3-inbound-channel-adapter", this.s3Inbound.getComponentType());
assertSame(this.s3Channel, TestUtils.getPropertyValue(this.s3Inbound, "outputChannel"));
assertThat(comparator).isSameAs(this.comparator);
assertThat(this.s3Inbound.getComponentName()).isEqualTo("s3Inbound");
assertThat(this.s3Inbound.getComponentType()).isEqualTo("aws:s3-inbound-channel-adapter");
assertThat(TestUtils.getPropertyValue(this.s3Inbound, "outputChannel")).isSameAs(this.s3Channel);
S3InboundFileSynchronizingMessageSource inbound = TestUtils.getPropertyValue(this.s3Inbound, "source",
S3InboundFileSynchronizingMessageSource.class);
S3InboundFileSynchronizer fisync = TestUtils.getPropertyValue(inbound, "synchronizer",
S3InboundFileSynchronizer.class);
assertEquals("'foo/bar'",
TestUtils.getPropertyValue(fisync, "remoteDirectoryExpression", Expression.class)
.getExpressionString());
assertNotNull(TestUtils.getPropertyValue(fisync, "localFilenameGeneratorExpression"));
assertTrue(TestUtils.getPropertyValue(fisync, "preserveTimestamp", Boolean.class));
assertEquals(".foo", TestUtils.getPropertyValue(fisync, "temporaryFileSuffix", String.class));
assertThat(TestUtils.getPropertyValue(fisync, "remoteDirectoryExpression", Expression.class)
.getExpressionString())
.isEqualTo("'foo/bar'");
assertThat(TestUtils.getPropertyValue(fisync, "localFilenameGeneratorExpression")).isNotNull();
assertThat(TestUtils.getPropertyValue(fisync, "preserveTimestamp", Boolean.class)).isTrue();
assertThat(TestUtils.getPropertyValue(fisync, "temporaryFileSuffix", String.class)).isEqualTo(".foo");
String remoteFileSeparator = (String) TestUtils.getPropertyValue(fisync, "remoteFileSeparator");
assertNotNull(remoteFileSeparator);
assertEquals("", remoteFileSeparator);
assertThat(remoteFileSeparator).isNotNull();
assertThat(remoteFileSeparator).isEmpty();
S3SimplePatternFileListFilter filter = TestUtils.getPropertyValue(fisync, "filter",
S3SimplePatternFileListFilter.class);
assertNotNull(filter);
assertSame(this.s3SessionFactory, TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory"));
assertTrue(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class)
.contains(this.acceptAllFilter));
assertThat(filter).isNotNull();
assertThat(TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory"))
.isSameAs(this.s3SessionFactory);
assertThat(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class)
.contains(this.acceptAllFilter))
.isTrue();
final AtomicReference<Method> genMethod = new AtomicReference<Method>();
ReflectionUtils.doWithMethods(AbstractInboundFileSynchronizer.class, new ReflectionUtils.MethodCallback() {
@@ -111,7 +109,7 @@ public class S3InboundChannelAdapterParserTests {
}
});
assertEquals("FOO.afoo", genMethod.get().invoke(fisync, "foo"));
assertThat(genMethod.get().invoke(fisync, "foo")).isEqualTo("FOO.afoo");
}
}

View File

@@ -16,10 +16,7 @@
package org.springframework.integration.aws.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -86,59 +83,69 @@ public class S3MessageHandlerParserTests {
@Test
public void testS3OutboundChannelAdapterParser() {
assertSame(this.amazonS3,
TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "transferManager.s3"));
assertEquals("foo", TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"bucketExpression.literalValue"));
assertEquals("'bar'", TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"destinationBucketExpression.expression"));
assertEquals("'baz'", TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"destinationKeyExpression.expression"));
assertEquals("payload.name", TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"keyExpression.expression"));
assertEquals("'qux'", TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"objectAclExpression.expression"));
assertEquals(S3MessageHandler.Command.COPY.name(),
TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "commandExpression.literalValue"));
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "transferManager.s3"))
.isSameAs(this.amazonS3);
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"bucketExpression.literalValue"))
.isEqualTo("foo");
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"destinationBucketExpression.expression"))
.isEqualTo("'bar'");
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"destinationKeyExpression.expression"))
.isEqualTo("'baz'");
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"keyExpression.expression"))
.isEqualTo("payload.name");
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler,
"objectAclExpression.expression"))
.isEqualTo("'qux'");
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "commandExpression.literalValue"))
.isEqualTo(S3MessageHandler.Command.COPY.name());
assertFalse(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "produceReply", Boolean.class));
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "produceReply", Boolean.class))
.isFalse();
assertSame(this.progressListener,
TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "s3ProgressListener"));
assertSame(this.uploadMetadataProvider,
TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "uploadMetadataProvider"));
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "s3ProgressListener"))
.isSameAs(this.progressListener);
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapterHandler, "uploadMetadataProvider"))
.isSameAs(this.uploadMetadataProvider);
assertEquals(100, this.s3OutboundChannelAdapter.getPhase());
assertFalse(this.s3OutboundChannelAdapter.isAutoStartup());
assertFalse(this.s3OutboundChannelAdapter.isRunning());
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.s3OutboundChannelAdapter, "inputChannel"));
assertSame(this.s3OutboundChannelAdapterHandler,
TestUtils.getPropertyValue(this.s3OutboundChannelAdapter, "handler"));
assertThat(this.s3OutboundChannelAdapter.getPhase()).isEqualTo(100);
assertThat(this.s3OutboundChannelAdapter.isAutoStartup()).isFalse();
assertThat(this.s3OutboundChannelAdapter.isRunning()).isFalse();
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapter, "inputChannel"))
.isSameAs(this.errorChannel);
assertThat(TestUtils.getPropertyValue(this.s3OutboundChannelAdapter, "handler"))
.isSameAs(this.s3OutboundChannelAdapterHandler);
}
@Test
public void testS3OutboundGatewayParser() {
assertSame(this.transferManager,
TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "transferManager"));
assertEquals("'FOO'", TestUtils.getPropertyValue(this.s3OutboundGatewayHandler,
"bucketExpression.expression"));
assertThat(TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "transferManager"))
.isSameAs(this.transferManager);
assertThat(TestUtils.getPropertyValue(this.s3OutboundGatewayHandler,
"bucketExpression.expression"))
.isEqualTo("'FOO'");
Expression commandExpression =
TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "commandExpression", Expression.class);
assertEquals("'" + S3MessageHandler.Command.DOWNLOAD.name() + "'",
TestUtils.getPropertyValue(commandExpression, "expression"));
assertThat(TestUtils.getPropertyValue(commandExpression, "expression"))
.isEqualTo("'" + S3MessageHandler.Command.DOWNLOAD.name() + "'");
StandardEvaluationContext evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
S3MessageHandler.Command command =
commandExpression.getValue(evaluationContext, S3MessageHandler.Command.class);
assertEquals(S3MessageHandler.Command.DOWNLOAD, command);
assertThat(command).isEqualTo(S3MessageHandler.Command.DOWNLOAD);
assertTrue(TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "produceReply", Boolean.class));
assertSame(this.nullChannel, TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "outputChannel"));
assertThat(TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "produceReply", Boolean.class)).isTrue();
assertThat(TestUtils.getPropertyValue(this.s3OutboundGatewayHandler, "outputChannel"))
.isSameAs(this.nullChannel);
assertTrue(this.s3OutboundGateway.isRunning());
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.s3OutboundGateway, "inputChannel"));
assertSame(this.s3OutboundGatewayHandler, TestUtils.getPropertyValue(this.s3OutboundGateway, "handler"));
assertThat(this.s3OutboundGateway.isRunning()).isTrue();
assertThat(TestUtils.getPropertyValue(this.s3OutboundGateway, "inputChannel")).isSameAs(this.errorChannel);
assertThat(TestUtils.getPropertyValue(this.s3OutboundGateway, "handler"))
.isSameAs(this.s3OutboundGatewayHandler);
}
}

View File

@@ -1,35 +1,28 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer;
import org.springframework.integration.aws.inbound.SnsInboundChannelAdapter;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.test.util.TestUtils;
@@ -62,19 +55,25 @@ public class SnsInboundChannelAdapterParserTests {
@Test
public void testSnsInboundChannelAdapterParser() {
assertSame(this.amazonSns, TestUtils.getPropertyValue(this.snsInboundChannelAdapter,
"notificationStatusResolver.amazonSns"));
assertTrue(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "handleNotificationStatus", Boolean.class));
assertArrayEquals(new String[] {"/foo"},
TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "requestMapping.pathPatterns", String[].class));
assertEquals("payload.Message",
TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "payloadExpression.expression"));
assertFalse(this.snsInboundChannelAdapter.isRunning());
assertEquals(100, this.snsInboundChannelAdapter.getPhase());
assertFalse(this.snsInboundChannelAdapter.isAutoStartup());
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "requestChannel"));
assertSame(this.nullChannel, TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "errorChannel"));
assertEquals(2000L, TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "messagingTemplate.sendTimeout"));
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "notificationStatusResolver.amazonSns"))
.isSameAs(this.amazonSns);
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "handleNotificationStatus",
Boolean.class))
.isTrue();
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "requestMapping.pathPatterns",
String[].class))
.isEqualTo(new String[] { "/foo" });
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "payloadExpression.expression"))
.isEqualTo("payload.Message");
assertThat(this.snsInboundChannelAdapter.isRunning()).isFalse();
assertThat(this.snsInboundChannelAdapter.getPhase()).isEqualTo(100);
assertThat(this.snsInboundChannelAdapter.isAutoStartup()).isFalse();
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "requestChannel"))
.isSameAs(this.errorChannel);
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "errorChannel"))
.isSameAs(this.nullChannel);
assertThat(TestUtils.getPropertyValue(this.snsInboundChannelAdapter, "messagingTemplate.sendTimeout"))
.isEqualTo(2000L);
}
}

View File

@@ -1,29 +1,22 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
@@ -85,42 +78,43 @@ public class SnsOutboundChannelAdapterParserTests {
@Test
public void testSnsOutboundChannelAdapterDefaultParser() throws Exception {
Object handler = TestUtils.getPropertyValue(this.defaultAdapter, "handler");
assertFalse(AopUtils.isAopProxy(handler));
assertThat(AopUtils.isAopProxy(handler)).isFalse();
assertSame(this.defaultAdapterHandler, handler);
assertThat(handler).isSameAs(this.defaultAdapterHandler);
assertThat(TestUtils.getPropertyValue(handler, "adviceChain", List.class).get(0),
instanceOf(RequestHandlerRetryAdvice.class));
assertThat(TestUtils.getPropertyValue(handler, "adviceChain", List.class).get(0))
.isInstanceOf(RequestHandlerRetryAdvice.class);
assertSame(this.defaultAdapterChannel, TestUtils.getPropertyValue(this.defaultAdapter, "inputChannel"));
assertThat(TestUtils.getPropertyValue(this.defaultAdapter, "inputChannel"))
.isSameAs(this.defaultAdapterChannel);
assertSame(this.amazonSns, TestUtils.getPropertyValue(this.defaultAdapterHandler, "amazonSns"));
assertNotNull(TestUtils.getPropertyValue(this.defaultAdapterHandler, "evaluationContext"));
assertNull(TestUtils.getPropertyValue(this.defaultAdapterHandler, "topicArnExpression"));
assertNull(TestUtils.getPropertyValue(this.defaultAdapterHandler, "subjectExpression"));
assertNull(TestUtils.getPropertyValue(this.defaultAdapterHandler, "bodyExpression"));
assertThat(TestUtils.getPropertyValue(this.defaultAdapterHandler, "amazonSns")).isSameAs(this.amazonSns);
assertThat(TestUtils.getPropertyValue(this.defaultAdapterHandler, "evaluationContext")).isNotNull();
assertThat(TestUtils.getPropertyValue(this.defaultAdapterHandler, "topicArnExpression")).isNull();
assertThat(TestUtils.getPropertyValue(this.defaultAdapterHandler, "subjectExpression")).isNull();
assertThat(TestUtils.getPropertyValue(this.defaultAdapterHandler, "bodyExpression")).isNull();
}
@Test
public void testSnsOutboundChannelAdapterParser() {
assertSame(this.notificationChannel, TestUtils.getPropertyValue(this.snsGateway, "inputChannel"));
assertSame(this.snsGatewayHandler, TestUtils.getPropertyValue(this.snsGateway, "handler"));
assertFalse(TestUtils.getPropertyValue(this.snsGateway, "autoStartup", Boolean.class));
assertEquals(new Integer(201), TestUtils.getPropertyValue(this.snsGateway, "phase", Integer.class));
assertTrue(TestUtils.getPropertyValue(this.snsGatewayHandler, "produceReply", Boolean.class));
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.snsGatewayHandler, "outputChannel"));
assertThat(TestUtils.getPropertyValue(this.snsGateway, "inputChannel")).isSameAs(this.notificationChannel);
assertThat(TestUtils.getPropertyValue(this.snsGateway, "handler")).isSameAs(this.snsGatewayHandler);
assertThat(TestUtils.getPropertyValue(this.snsGateway, "autoStartup", Boolean.class)).isFalse();
assertThat(TestUtils.getPropertyValue(this.snsGateway, "phase", Integer.class)).isEqualTo(201);
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "produceReply", Boolean.class)).isTrue();
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "outputChannel")).isSameAs(this.errorChannel);
assertSame(this.amazonSns, TestUtils.getPropertyValue(this.snsGatewayHandler, "amazonSns"));
assertNotNull(TestUtils.getPropertyValue(this.snsGatewayHandler, "evaluationContext"));
assertEquals("foo",
TestUtils.getPropertyValue(this.snsGatewayHandler, "topicArnExpression", Expression.class)
.getExpressionString());
assertEquals("bar",
TestUtils.getPropertyValue(this.snsGatewayHandler, "subjectExpression", Expression.class)
.getExpressionString());
assertEquals("payload.toUpperCase()",
TestUtils.getPropertyValue(this.snsGatewayHandler, "bodyExpression", Expression.class)
.getExpressionString());
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "amazonSns")).isSameAs(this.amazonSns);
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "evaluationContext")).isNotNull();
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "topicArnExpression", Expression.class)
.getExpressionString())
.isEqualTo("foo");
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "subjectExpression", Expression.class)
.getExpressionString())
.isEqualTo("bar");
assertThat(TestUtils.getPropertyValue(this.snsGatewayHandler, "bodyExpression", Expression.class)
.getExpressionString())
.isEqualTo("payload.toUpperCase()");
}
}

View File

@@ -1,30 +1,26 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -78,8 +74,8 @@ public class SqsMessageDrivenChannelAdapterParserTests {
@Bean
public DestinationResolver<?> destinationResolver() {
DestinationResolver<?> destinationResolver = Mockito.mock(DestinationResolver.class);
doThrow(DestinationResolutionException.class)
.when(destinationResolver)
willThrow(DestinationResolutionException.class)
.given(destinationResolver)
.resolveDestination(anyString());
return destinationResolver;
}
@@ -89,30 +85,35 @@ public class SqsMessageDrivenChannelAdapterParserTests {
SimpleMessageListenerContainer listenerContainer =
TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "listenerContainer",
SimpleMessageListenerContainer.class);
assertSame(this.amazonSqs, TestUtils.getPropertyValue(listenerContainer, "amazonSqs"));
assertSame(this.resourceIdResolver, TestUtils.getPropertyValue(listenerContainer, "resourceIdResolver"));
assertSame(this.taskExecutor, TestUtils.getPropertyValue(listenerContainer, "taskExecutor"));
assertSame(this.destinationResolver, TestUtils.getPropertyValue(listenerContainer, "destinationResolver"));
assertFalse(listenerContainer.isRunning());
assertEquals(5, TestUtils.getPropertyValue(listenerContainer, "maxNumberOfMessages"));
assertEquals(200, TestUtils.getPropertyValue(listenerContainer, "visibilityTimeout"));
assertEquals(40, TestUtils.getPropertyValue(listenerContainer, "waitTimeOut"));
assertThat(TestUtils.getPropertyValue(listenerContainer, "amazonSqs")).isSameAs(this.amazonSqs);
assertThat(TestUtils.getPropertyValue(listenerContainer, "resourceIdResolver"))
.isSameAs(this.resourceIdResolver);
assertThat(TestUtils.getPropertyValue(listenerContainer, "taskExecutor")).isSameAs(this.taskExecutor);
assertThat(TestUtils.getPropertyValue(listenerContainer, "destinationResolver"))
.isSameAs(this.destinationResolver);
assertThat(listenerContainer.isRunning()).isFalse();
assertThat(TestUtils.getPropertyValue(listenerContainer, "maxNumberOfMessages")).isEqualTo(5);
assertThat(TestUtils.getPropertyValue(listenerContainer, "visibilityTimeout")).isEqualTo(200);
assertThat(TestUtils.getPropertyValue(listenerContainer, "waitTimeOut")).isEqualTo(40);
@SuppressWarnings("rawtypes")
Map queues = TestUtils.getPropertyValue(listenerContainer, "registeredQueues", Map.class);
assertTrue(queues.keySet().contains("foo"));
assertTrue(queues.keySet().contains("bar"));
assertThat(queues.keySet().contains("foo")).isTrue();
assertThat(queues.keySet().contains("bar")).isTrue();
assertEquals(100, this.sqsMessageDrivenChannelAdapter.getPhase());
assertFalse(this.sqsMessageDrivenChannelAdapter.isAutoStartup());
assertFalse(this.sqsMessageDrivenChannelAdapter.isRunning());
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "outputChannel"));
assertSame(this.nullChannel, TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "errorChannel"));
assertEquals(2000L, TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter,
"messagingTemplate.sendTimeout"));
assertEquals(SqsMessageDeletionPolicy.NEVER,
TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "messageDeletionPolicy",
SqsMessageDeletionPolicy.class));
assertThat(this.sqsMessageDrivenChannelAdapter.getPhase()).isEqualTo(100);
assertThat(this.sqsMessageDrivenChannelAdapter.isAutoStartup()).isFalse();
assertThat(this.sqsMessageDrivenChannelAdapter.isRunning()).isFalse();
assertThat(TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "outputChannel"))
.isSameAs(this.errorChannel);
assertThat(TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "errorChannel"))
.isSameAs(this.nullChannel);
assertThat(TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter,
"messagingTemplate.sendTimeout"))
.isEqualTo(2000L);
assertThat(TestUtils.getPropertyValue(this.sqsMessageDrivenChannelAdapter, "messageDeletionPolicy",
SqsMessageDeletionPolicy.class))
.isEqualTo(SqsMessageDeletionPolicy.NEVER);
}
}

View File

@@ -1,24 +1,22 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,9 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.aws.core.env.ResourceIdResolver;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
@@ -62,18 +58,21 @@ public class SqsMessageHandlerParserTests {
@Test
public void testSqsMessageHandlerParser() {
assertSame(this.amazonSqs,
TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler, "template.amazonSqs"));
assertSame(this.resourceIdResolver, TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler,
"template.destinationResolver.targetDestinationResolver.resourceIdResolver"));
assertEquals("foo", TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler,
"queueExpression.literalValue"));
assertEquals(100, this.sqsOutboundChannelAdapter.getPhase());
assertFalse(this.sqsOutboundChannelAdapter.isAutoStartup());
assertFalse(this.sqsOutboundChannelAdapter.isRunning());
assertSame(this.errorChannel, TestUtils.getPropertyValue(this.sqsOutboundChannelAdapter, "inputChannel"));
assertSame(this.sqsOutboundChannelAdapterHandler,
TestUtils.getPropertyValue(this.sqsOutboundChannelAdapter, "handler"));
assertThat(TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler, "template.amazonSqs"))
.isSameAs(this.amazonSqs);
assertThat(TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler,
"template.destinationResolver.targetDestinationResolver.resourceIdResolver"))
.isSameAs(this.resourceIdResolver);
assertThat(TestUtils.getPropertyValue(this.sqsOutboundChannelAdapterHandler,
"queueExpression.literalValue"))
.isEqualTo("foo");
assertThat(this.sqsOutboundChannelAdapter.getPhase()).isEqualTo(100);
assertThat(this.sqsOutboundChannelAdapter.isAutoStartup()).isFalse();
assertThat(this.sqsOutboundChannelAdapter.isRunning()).isFalse();
assertThat(TestUtils.getPropertyValue(this.sqsOutboundChannelAdapter, "inputChannel"))
.isSameAs(this.errorChannel);
assertThat(TestUtils.getPropertyValue(this.sqsOutboundChannelAdapter, "handler"))
.isSameAs(this.sqsOutboundChannelAdapterHandler);
}
}

View File

@@ -1,26 +1,27 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.config.xml;
import org.junit.Assert;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.aws.outbound.SqsMessageHandler;
import org.springframework.integration.test.util.TestUtils;
@@ -33,37 +34,39 @@ public class SqsOutboundChannelAdapterParserTests {
@Test(expected = BeanDefinitionStoreException.class)
public void test_sqs_resource_resolver_defined_with_queue_messaging_template() {
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad.xml", this.getClass());
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad.xml", getClass()).close();
}
@Test(expected = BeanDefinitionStoreException.class)
public void test_sqs_defined_with_queue_messaging_template() {
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad2.xml", this.getClass());
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad2.xml", getClass()).close();
}
@Test(expected = BeanDefinitionStoreException.class)
public void test_resource_resolver_defined_with_queue_messaging_template() {
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad3.xml", this.getClass());
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad3.xml", getClass()).close();
}
@Test(expected = BeanDefinitionStoreException.class)
public void test_neither_sqs_nor_queue_messaging_template_defined() {
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad4.xml", this.getClass());
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-bad4.xml", getClass()).close();
}
@Test
public void test_happy_path_with_queue_messaging_template() {
ApplicationContext applicationContext =
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-good.xml", this.getClass());
ConfigurableApplicationContext applicationContext =
new ClassPathXmlApplicationContext("SqsOutboundChannelAdapterParserTests-context-good.xml", getClass());
SqsMessageHandler handlerWithTemplate =
applicationContext.getBean("sqsOutboundChannelAdapterWithQueueMessagingTemplate.handler",
SqsMessageHandler.class);
Assert.assertNotNull(TestUtils.getPropertyValue(handlerWithTemplate, "template"));
assertThat(TestUtils.getPropertyValue(handlerWithTemplate, "template")).isNotNull();
SqsMessageHandler handlerWithSqs = applicationContext.getBean("sqsOutboundChannelAdapterWithSqs.handler",
SqsMessageHandler.class);
Assert.assertNotNull(TestUtils.getPropertyValue(handlerWithSqs, "template"));
assertThat(TestUtils.getPropertyValue(handlerWithSqs, "template")).isNotNull();
applicationContext.close();
}
}

View File

@@ -16,13 +16,7 @@
package org.springframework.integration.aws.inbound;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
@@ -34,7 +28,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
@@ -84,8 +77,6 @@ public class S3InboundChannelAdapterTests {
@ClassRule
public static final TemporaryFolder TEMPORARY_FOLDER = new TemporaryFolder();
private static File REMOTE_FOLDER;
private static List<S3Object> S3_OBJECTS;
private static File LOCAL_FOLDER;
@@ -95,17 +86,18 @@ public class S3InboundChannelAdapterTests {
@BeforeClass
public static void setup() throws IOException {
REMOTE_FOLDER = TEMPORARY_FOLDER.newFolder("remote");
File aFile = new File(REMOTE_FOLDER, "a.test");
File remoteFolder = TEMPORARY_FOLDER.newFolder("remote");
File aFile = new File(remoteFolder, "a.test");
FileCopyUtils.copy("Hello".getBytes(), aFile);
File bFile = new File(REMOTE_FOLDER, "b.test");
File bFile = new File(remoteFolder, "b.test");
FileCopyUtils.copy("Bye".getBytes(), bFile);
File otherFile = new File(REMOTE_FOLDER, "otherFile");
File otherFile = new File(remoteFolder, "otherFile");
FileCopyUtils.copy("Other".getBytes(), otherFile);
S3_OBJECTS = new ArrayList<>();
for (File file : REMOTE_FOLDER.listFiles()) {
for (File file : remoteFolder.listFiles()) {
S3Object s3Object = new S3Object();
s3Object.setBucketName(S3_BUCKET);
s3Object.setKey(file.getName());
@@ -113,41 +105,41 @@ public class S3InboundChannelAdapterTests {
S3_OBJECTS.add(s3Object);
}
LOCAL_FOLDER = new File(TEMPORARY_FOLDER.getRoot(), "local");
LOCAL_FOLDER = TEMPORARY_FOLDER.newFolder("local");
}
@Test
public void testS3InboundChannelAdapter() throws IOException {
Message<?> message = this.s3FilesChannel.receive(10000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(File.class));
assertThat(message).isNotNull();
assertThat(message.getPayload()).isInstanceOf(File.class);
File localFile = (File) message.getPayload();
assertEquals("A.TEST.a", localFile.getName());
assertThat(localFile.getName()).isEqualTo("A.TEST.a");
// The test remote files are created with the current timestamp + 1 day.
assertThat(localFile.lastModified(), Matchers.greaterThan(System.currentTimeMillis()));
assertThat(localFile.lastModified()).isGreaterThan(System.currentTimeMillis());
message = this.s3FilesChannel.receive(10000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(File.class));
assertThat(message).isNotNull();
assertThat(message.getPayload()).isInstanceOf(File.class);
localFile = (File) message.getPayload();
assertEquals("B.TEST.a", localFile.getName());
assertThat(localFile.getName()).isEqualTo("B.TEST.a");
assertThat(localFile.lastModified(), Matchers.greaterThan(System.currentTimeMillis()));
assertThat(localFile.lastModified()).isGreaterThan(System.currentTimeMillis());
assertNull(this.s3FilesChannel.receive(10));
assertThat(this.s3FilesChannel.receive(10)).isNull();
File file = new File(LOCAL_FOLDER, "A.TEST.a");
assertTrue(file.exists());
assertThat(file.exists()).isTrue();
String content = FileCopyUtils.copyToString(new FileReader(file));
assertEquals("Hello", content);
assertThat(content).isEqualTo("Hello");
file = new File(LOCAL_FOLDER, "B.TEST.a");
assertTrue(file.exists());
assertThat(file.exists()).isTrue();
content = FileCopyUtils.copyToString(new FileReader(file));
assertEquals("Bye", content);
assertThat(content).isEqualTo("Bye");
assertFalse(new File(LOCAL_FOLDER, "otherFile.a").exists());
assertThat(new File(LOCAL_FOLDER, "otherFile.a").exists()).isFalse();
}
@Configuration

View File

@@ -1,25 +1,23 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -28,7 +26,7 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.BDDMockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -98,11 +96,11 @@ public class SnsInboundChannelAdapterTests {
.andExpect(status().isNoContent());
Message<?> receive = inputChannel.receive(10000);
assertNotNull(receive);
assertTrue(receive.getHeaders().containsKey(AwsHeaders.SNS_MESSAGE_TYPE));
assertEquals("SubscriptionConfirmation", receive.getHeaders().get(AwsHeaders.SNS_MESSAGE_TYPE));
assertThat(receive).isNotNull();
assertThat(receive.getHeaders().containsKey(AwsHeaders.SNS_MESSAGE_TYPE)).isTrue();
assertThat(receive.getHeaders().get(AwsHeaders.SNS_MESSAGE_TYPE)).isEqualTo("SubscriptionConfirmation");
assertTrue(receive.getHeaders().containsKey(AwsHeaders.NOTIFICATION_STATUS));
assertThat(receive.getHeaders().containsKey(AwsHeaders.NOTIFICATION_STATUS)).isTrue();
NotificationStatus notificationStatus = (NotificationStatus) receive.getHeaders()
.get(AwsHeaders.NOTIFICATION_STATUS);
@@ -123,11 +121,11 @@ public class SnsInboundChannelAdapterTests {
.andExpect(status().isNoContent());
Message<?> receive = inputChannel.receive(10000);
assertNotNull(receive);
assertThat(receive).isNotNull();
Map<String, String> payload = (Map<String, String>) receive.getPayload();
assertEquals("foo", payload.get("Subject"));
assertEquals("bar", payload.get("Message"));
assertThat(payload.get("Subject")).isEqualTo("foo");
assertThat(payload.get("Message")).isEqualTo("bar");
}
@Test
@@ -140,11 +138,11 @@ public class SnsInboundChannelAdapterTests {
.andExpect(status().isNoContent());
Message<?> receive = inputChannel.receive(10000);
assertNotNull(receive);
assertTrue(receive.getHeaders().containsKey(AwsHeaders.SNS_MESSAGE_TYPE));
assertEquals("UnsubscribeConfirmation", receive.getHeaders().get(AwsHeaders.SNS_MESSAGE_TYPE));
assertThat(receive).isNotNull();
assertThat(receive.getHeaders().containsKey(AwsHeaders.SNS_MESSAGE_TYPE)).isTrue();
assertThat(receive.getHeaders().get(AwsHeaders.SNS_MESSAGE_TYPE)).isEqualTo("UnsubscribeConfirmation");
assertTrue(receive.getHeaders().containsKey(AwsHeaders.NOTIFICATION_STATUS));
assertThat(receive.getHeaders().containsKey(AwsHeaders.NOTIFICATION_STATUS)).isTrue();
NotificationStatus notificationStatus = (NotificationStatus) receive.getHeaders()
.get(AwsHeaders.NOTIFICATION_STATUS);
@@ -160,7 +158,7 @@ public class SnsInboundChannelAdapterTests {
@Bean
public AmazonSNS amazonSns() {
return Mockito.mock(AmazonSNS.class);
return BDDMockito.mock(AmazonSNS.class);
}
@Bean

View File

@@ -1,29 +1,26 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -60,13 +57,13 @@ public class SqsMessageDrivenChannelAdapterTests {
@Test
public void testSqsMessageDrivenChannelAdapter() {
org.springframework.messaging.Message<?> receive = this.inputChannel.receive(1000);
assertNotNull(receive);
assertThat((String) receive.getPayload(), Matchers.isOneOf("messageContent", "messageContent2"));
assertEquals("testQueue", receive.getHeaders().get(AwsHeaders.QUEUE));
assertThat(receive).isNotNull();
assertThat((String) receive.getPayload()).isIn("messageContent", "messageContent2");
assertThat(receive.getHeaders().get(AwsHeaders.QUEUE)).isEqualTo("testQueue");
receive = this.inputChannel.receive(1000);
assertNotNull(receive);
assertThat((String) receive.getPayload(), Matchers.isOneOf("messageContent", "messageContent2"));
assertEquals("testQueue", receive.getHeaders().get(AwsHeaders.QUEUE));
assertThat(receive).isNotNull();
assertThat((String) receive.getPayload()).isIn("messageContent", "messageContent2");
assertThat(receive.getHeaders().get(AwsHeaders.QUEUE)).isEqualTo("testQueue");
}
@Configuration
@@ -76,20 +73,22 @@ public class SqsMessageDrivenChannelAdapterTests {
@Bean
public AmazonSQSAsync amazonSqs() {
AmazonSQSAsync sqs = mock(AmazonSQSAsync.class);
when(sqs.getQueueUrl(new GetQueueUrlRequest("testQueue"))).thenReturn(new GetQueueUrlResult().
withQueueUrl("http://testQueue.amazonaws.com"));
given(sqs.getQueueUrl(new GetQueueUrlRequest("testQueue")))
.willReturn(new GetQueueUrlResult().withQueueUrl("http://testQueue.amazonaws.com"));
when(sqs.receiveMessage(new ReceiveMessageRequest("http://testQueue.amazonaws.com")
given(sqs.receiveMessage(new ReceiveMessageRequest("http://testQueue.amazonaws.com")
.withAttributeNames("All")
.withMessageAttributeNames("All")
.withMaxNumberOfMessages(10)))
.thenReturn(new ReceiveMessageResult()
.willReturn(new ReceiveMessageResult()
.withMessages(new Message().withBody("messageContent"),
new Message().withBody("messageContent2")))
.thenReturn(new ReceiveMessageResult());
when(sqs.getQueueAttributes(any(GetQueueAttributesRequest.class)))
.thenReturn(new GetQueueAttributesResult());
.willReturn(new ReceiveMessageResult());
given(sqs.getQueueAttributes(any(GetQueueAttributesRequest.class)))
.willReturn(new GetQueueAttributesResult());
return sqs;
}

View File

@@ -1,24 +1,22 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -63,8 +61,8 @@ public abstract class AbstractSqsMessageHandlerTests {
this.sqsSendChannel.send(message);
}
catch (Exception e) {
assertThat(e, instanceOf(MessageHandlingException.class));
assertThat(e.getCause(), instanceOf(IllegalStateException.class));
assertThat(e).isInstanceOf(MessageHandlingException.class);
assertThat(e.getCause()).isInstanceOf(IllegalStateException.class);
}
this.sqsMessageHandler.setQueue("foo");
@@ -72,12 +70,14 @@ public abstract class AbstractSqsMessageHandlerTests {
ArgumentCaptor<SendMessageRequest> sendMessageRequestArgumentCaptor =
ArgumentCaptor.forClass(SendMessageRequest.class);
verify(this.amazonSqs).sendMessage(sendMessageRequestArgumentCaptor.capture());
assertEquals("http://queue-url.com/foo", sendMessageRequestArgumentCaptor.getValue().getQueueUrl());
assertThat(sendMessageRequestArgumentCaptor.getValue().getQueueUrl())
.isEqualTo("http://queue-url.com/foo");
message = MessageBuilder.withPayload("message").setHeader(AwsHeaders.QUEUE, "bar").build();
this.sqsSendChannel.send(message);
verify(this.amazonSqs, times(2)).sendMessage(sendMessageRequestArgumentCaptor.capture());
assertEquals("http://queue-url.com/bar", sendMessageRequestArgumentCaptor.getValue().getQueueUrl());
assertThat(sendMessageRequestArgumentCaptor.getValue().getQueueUrl())
.isEqualTo("http://queue-url.com/bar");
SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
Expression expression = spelExpressionParser.parseExpression("headers.foo");
@@ -85,7 +85,8 @@ public abstract class AbstractSqsMessageHandlerTests {
message = MessageBuilder.withPayload("message").setHeader("foo", "baz").build();
this.sqsSendChannel.send(message);
verify(this.amazonSqs, times(3)).sendMessage(sendMessageRequestArgumentCaptor.capture());
assertEquals("http://queue-url.com/baz", sendMessageRequestArgumentCaptor.getValue().getQueueUrl());
assertThat(sendMessageRequestArgumentCaptor.getValue().getQueueUrl())
.isEqualTo("http://queue-url.com/baz");
}
}

View File

@@ -1,33 +1,29 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.hamcrest.Matchers.instanceOf;
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.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -36,7 +32,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -45,14 +40,11 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.http.client.methods.HttpRequestBase;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -149,21 +141,21 @@ public class S3MessageHandlerTests {
verify(this.amazonS3, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture());
PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue();
assertEquals("myBucket", putObjectRequest.getBucketName());
assertEquals("foo.mp3", putObjectRequest.getKey());
assertNull(putObjectRequest.getFile());
assertNotNull(putObjectRequest.getInputStream());
assertThat(putObjectRequest.getBucketName()).isEqualTo("myBucket");
assertThat(putObjectRequest.getKey()).isEqualTo("foo.mp3");
assertThat(putObjectRequest.getFile()).isNull();
assertThat(putObjectRequest.getInputStream()).isNotNull();
ObjectMetadata metadata = putObjectRequest.getMetadata();
assertEquals(Md5Utils.md5AsBase64(file), metadata.getContentMD5());
assertEquals(0, metadata.getContentLength());
assertEquals("audio/mpeg", metadata.getContentType());
assertThat(metadata.getContentMD5()).isEqualTo(Md5Utils.md5AsBase64(file));
assertThat(metadata.getContentLength()).isEqualTo(0);
assertThat(metadata.getContentType()).isEqualTo("audio/mpeg");
ProgressListener listener = putObjectRequest.getGeneralProgressListener();
S3ProgressPublisher.publishProgress(listener, ProgressEventType.TRANSFER_COMPLETED_EVENT);
assertTrue(this.transferCompletedLatch.await(10, TimeUnit.SECONDS));
assertTrue(this.aclLatch.await(10, TimeUnit.SECONDS));
assertThat(this.transferCompletedLatch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(this.aclLatch.await(10, TimeUnit.SECONDS)).isTrue();
ArgumentCaptor<SetObjectAclRequest> setObjectAclRequestArgumentCaptor =
ArgumentCaptor.forClass(SetObjectAclRequest.class);
@@ -171,10 +163,10 @@ public class S3MessageHandlerTests {
SetObjectAclRequest setObjectAclRequest = setObjectAclRequestArgumentCaptor.getValue();
assertEquals("myBucket", setObjectAclRequest.getBucketName());
assertEquals("foo.mp3", setObjectAclRequest.getKey());
assertNull(setObjectAclRequest.getAcl());
assertEquals(CannedAccessControlList.PublicReadWrite, setObjectAclRequest.getCannedAcl());
assertThat(setObjectAclRequest.getBucketName()).isEqualTo("myBucket");
assertThat(setObjectAclRequest.getKey()).isEqualTo("foo.mp3");
assertThat(setObjectAclRequest.getAcl()).isNull();
assertThat(setObjectAclRequest.getCannedAcl()).isEqualTo(CannedAccessControlList.PublicReadWrite);
}
@Test
@@ -192,16 +184,16 @@ public class S3MessageHandlerTests {
verify(this.amazonS3, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture());
PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue();
assertEquals("myBucket", putObjectRequest.getBucketName());
assertEquals("myStream", putObjectRequest.getKey());
assertNull(putObjectRequest.getFile());
assertNotNull(putObjectRequest.getInputStream());
assertThat(putObjectRequest.getBucketName()).isEqualTo("myBucket");
assertThat(putObjectRequest.getKey()).isEqualTo("myStream");
assertThat(putObjectRequest.getFile()).isNull();
assertThat(putObjectRequest.getInputStream()).isNotNull();
ObjectMetadata metadata = putObjectRequest.getMetadata();
assertEquals(Md5Utils.md5AsBase64(payload), metadata.getContentMD5());
assertEquals(1, metadata.getContentLength());
assertEquals(MediaType.APPLICATION_JSON_VALUE, metadata.getContentType());
assertEquals("test.json", metadata.getContentDisposition());
assertThat(metadata.getContentMD5()).isEqualTo(Md5Utils.md5AsBase64(payload));
assertThat(metadata.getContentLength()).isEqualTo(1);
assertThat(metadata.getContentType()).isEqualTo(MediaType.APPLICATION_JSON_VALUE);
assertThat(metadata.getContentDisposition()).isEqualTo("test.json");
}
@Test
@@ -214,26 +206,19 @@ public class S3MessageHandlerTests {
this.s3SendChannel.send(message);
File[] fileArray = directoryForDownload.listFiles();
assertNotNull(fileArray);
assertEquals(2, fileArray.length);
assertThat(fileArray).isNotNull();
assertThat(fileArray.length).isEqualTo(2);
List<File> files = Arrays.asList(fileArray);
Collections.sort(files, new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
return o1.getName().compareTo(o2.getName());
}
});
Collections.sort(files, (o1, o2) -> o1.getName().compareTo(o2.getName()));
File file1 = files.get(0);
assertEquals("bar", file1.getName());
assertEquals("bb", FileCopyUtils.copyToString(new FileReader(file1)));
assertThat(file1.getName()).isEqualTo("bar");
assertThat(FileCopyUtils.copyToString(new FileReader(file1))).isEqualTo("bb");
File file2 = files.get(1);
assertEquals("foo", file2.getName());
assertEquals("f", FileCopyUtils.copyToString(new FileReader(file2)));
assertThat(file2.getName()).isEqualTo("foo");
assertThat(FileCopyUtils.copyToString(new FileReader(file2))).isEqualTo("f");
}
@Test
@@ -245,15 +230,15 @@ public class S3MessageHandlerTests {
this.s3ProcessChannel.send(new GenericMessage<>(payload));
Message<?> receive = this.s3ReplyChannel.receive(10000);
assertNotNull(receive);
assertThat(receive).isNotNull();
Assert.assertThat(receive.getPayload(), instanceOf(Copy.class));
assertThat(receive.getPayload()).isInstanceOf(Copy.class);
Copy copy = (Copy) receive.getPayload();
assertEquals("Copying object from myBucket/mySource to theirBucket/theirTarget", copy.getDescription());
assertThat(copy.getDescription()).isEqualTo("Copying object from myBucket/mySource to theirBucket/theirTarget");
copy.waitForCompletion();
assertEquals(Transfer.TransferState.Completed, copy.getState());
assertThat(copy.getState()).isEqualTo(Transfer.TransferState.Completed);
}
@Configuration
@@ -264,9 +249,9 @@ public class S3MessageHandlerTests {
public AmazonS3 amazonS3() {
AmazonS3 amazonS3 = mock(AmazonS3.class);
when(amazonS3.putObject(any(PutObjectRequest.class))).thenReturn(new PutObjectResult());
when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());
when(amazonS3.copyObject(any(CopyObjectRequest.class))).thenReturn(new CopyObjectResult());
given(amazonS3.putObject(any(PutObjectRequest.class))).willReturn(new PutObjectResult());
given(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).willReturn(new ObjectMetadata());
given(amazonS3.copyObject(any(CopyObjectRequest.class))).willReturn(new CopyObjectResult());
ObjectListing objectListing = spy(new ObjectListing());
@@ -284,8 +269,8 @@ public class S3MessageHandlerTests {
fileSummary2.setSize(2);
s3ObjectSummaries.add(fileSummary2);
when(objectListing.getObjectSummaries()).thenReturn(s3ObjectSummaries);
when(amazonS3.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
given(objectListing.getObjectSummaries()).willReturn(s3ObjectSummaries);
given(amazonS3.listObjects(any(ListObjectsRequest.class))).willReturn(objectListing);
final S3Object file1 = new S3Object();
file1.setBucketName("myBucket");
@@ -317,34 +302,28 @@ public class S3MessageHandlerTests {
// no-op
}
doAnswer(new Answer<S3Object>() {
@Override
public S3Object answer(InvocationOnMock invocation) throws Throwable {
GetObjectRequest getObjectRequest = (GetObjectRequest) invocation.getArguments()[0];
String key = getObjectRequest.getKey();
if ("foo".equals(key)) {
return file1;
}
else if ("bar".equals(key)) {
return file2;
}
else {
return (S3Object) invocation.callRealMethod();
}
willAnswer(invocation -> {
GetObjectRequest getObjectRequest = (GetObjectRequest) invocation.getArguments()[0];
String key = getObjectRequest.getKey();
if ("foo".equals(key)) {
return file1;
}
}).when(amazonS3).getObject(any(GetObjectRequest.class));
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
aclLatch().countDown();
return null;
else if ("bar".equals(key)) {
return file2;
}
else {
return invocation.callRealMethod();
}
})
.given(amazonS3)
.getObject(any(GetObjectRequest.class));
}).when(amazonS3).setObjectAcl(any(SetObjectAclRequest.class));
willAnswer(invocation -> {
aclLatch().countDown();
return null;
})
.given(amazonS3)
.setObjectAcl(any(SetObjectAclRequest.class));
return amazonS3;
}
@@ -388,17 +367,12 @@ public class S3MessageHandlerTests {
PARSER.parseExpression("payload instanceof T(java.io.File) ? payload.name : headers.key");
s3MessageHandler.setKeyExpression(keyExpression);
s3MessageHandler.setObjectAclExpression(new ValueExpression<>(CannedAccessControlList.PublicReadWrite));
s3MessageHandler.setUploadMetadataProvider(new S3MessageHandler.UploadMetadataProvider() {
@Override
public void populateMetadata(ObjectMetadata metadata, Message<?> message) {
if (message.getPayload() instanceof InputStream) {
metadata.setContentLength(1);
metadata.setContentType(MediaType.APPLICATION_JSON_VALUE);
metadata.setContentDisposition("test.json");
}
s3MessageHandler.setUploadMetadataProvider((metadata, message) -> {
if (message.getPayload() instanceof InputStream) {
metadata.setContentLength(1);
metadata.setContentType(MediaType.APPLICATION_JSON_VALUE);
metadata.setContentDisposition("test.json");
}
});
s3MessageHandler.setProgressListener(s3ProgressListener());
return s3MessageHandler;

View File

@@ -1,26 +1,23 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import org.junit.Test;
@@ -38,12 +35,12 @@ public class SnsMessageBuilderTests {
fail("IllegalArgumentException expected");
}
catch (Exception e) {
assertThat(e, instanceOf(IllegalArgumentException.class));
assertThat(e.getMessage(), containsString("defaultMessage must not be empty."));
assertThat(e).isInstanceOf(IllegalArgumentException.class);
assertThat(e.getMessage()).contains("defaultMessage must not be empty.");
}
String message = SnsBodyBuilder.withDefault("foo").build();
assertEquals("{\"default\":\"foo\"}", message);
assertThat(message).isEqualTo("{\"default\":\"foo\"}");
try {
SnsBodyBuilder.withDefault("foo")
@@ -52,8 +49,8 @@ public class SnsMessageBuilderTests {
fail("IllegalArgumentException expected");
}
catch (Exception e) {
assertThat(e, instanceOf(IllegalArgumentException.class));
assertThat(e.getMessage(), containsString("protocols must not be empty."));
assertThat(e).isInstanceOf(IllegalArgumentException.class);
assertThat(e.getMessage()).contains("protocols must not be empty.");
}
try {
SnsBodyBuilder.withDefault("foo")
@@ -62,15 +59,15 @@ public class SnsMessageBuilderTests {
fail("IllegalArgumentException expected");
}
catch (Exception e) {
assertThat(e, instanceOf(IllegalArgumentException.class));
assertThat(e.getMessage(), containsString("protocols must not contain empty elements."));
assertThat(e).isInstanceOf(IllegalArgumentException.class);
assertThat(e.getMessage()).contains("protocols must not contain empty elements.");
}
message = SnsBodyBuilder.withDefault("foo")
.forProtocols("{\"foo\" : \"bar\"}", "sms")
.build();
assertEquals("{\"default\":\"foo\",\"sms\":\"{\\\"foo\\\" : \\\"bar\\\"}\"}", message);
assertThat(message).isEqualTo("{\"default\":\"foo\",\"sms\":\"{\\\"foo\\\" : \\\"bar\\\"}\"}");
}
}

View File

@@ -1,34 +1,30 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -83,21 +79,22 @@ public class SnsMessageHandlerTests {
this.sendToSnsChannel.send(message);
Message<?> reply = replyChannel.receive(1000);
assertNotNull(reply);
assertThat(reply).isNotNull();
ArgumentCaptor<PublishRequest> captor = ArgumentCaptor.forClass(PublishRequest.class);
verify(this.amazonSNS).publish(captor.capture());
PublishRequest publishRequest = captor.getValue();
assertEquals("json", publishRequest.getMessageStructure());
assertEquals("topic", publishRequest.getTopicArn());
assertEquals("subject", publishRequest.getSubject());
assertEquals("{\"default\":\"foo\",\"sms\":\"{\\\"foo\\\" : \\\"bar\\\"}\"}", publishRequest.getMessage());
assertThat(publishRequest.getMessageStructure()).isEqualTo("json");
assertThat(publishRequest.getTopicArn()).isEqualTo("topic");
assertThat(publishRequest.getSubject()).isEqualTo("subject");
assertThat(publishRequest.getMessage())
.isEqualTo("{\"default\":\"foo\",\"sms\":\"{\\\"foo\\\" : \\\"bar\\\"}\"}");
assertEquals("111", reply.getHeaders().get(AwsHeaders.SNS_PUBLISHED_MESSAGE_ID));
assertEquals("topic", reply.getHeaders().get(AwsHeaders.TOPIC));
assertSame(publishRequest, reply.getPayload());
assertThat(reply.getHeaders().get(AwsHeaders.SNS_PUBLISHED_MESSAGE_ID)).isEqualTo("111");
assertThat(reply.getHeaders().get(AwsHeaders.TOPIC)).isEqualTo("topic");
assertThat(reply.getPayload()).isSameAs(publishRequest);
}
@Configuration
@@ -108,13 +105,9 @@ public class SnsMessageHandlerTests {
public AmazonSNS amazonSNS() {
AmazonSNS mock = mock(AmazonSNS.class);
doAnswer(new Answer<PublishResult>() {
@Override
public PublishResult answer(InvocationOnMock invocation) throws Throwable {
return new PublishResult().withMessageId("111");
}
}).when(mock).publish(any(PublishRequest.class));
willAnswer(invocation -> new PublishResult().withMessageId("111"))
.given(mock)
.publish(any(PublishRequest.class));
return mock;
}

View File

@@ -1,28 +1,26 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -55,17 +53,14 @@ public class SqsMessageHandlerTests extends AbstractSqsMessageHandlerTests {
public AmazonSQS amazonSqs() {
AmazonSQS amazonSqs = mock(AmazonSQS.class);
doAnswer(new Answer<GetQueueUrlResult>() {
@Override
public GetQueueUrlResult answer(InvocationOnMock invocation) throws Throwable {
GetQueueUrlRequest getQueueUrlRequest = (GetQueueUrlRequest) invocation.getArguments()[0];
GetQueueUrlResult queueUrl = new GetQueueUrlResult();
queueUrl.setQueueUrl("http://queue-url.com/" + getQueueUrlRequest.getQueueName());
return queueUrl;
}
}).when(amazonSqs).getQueueUrl(any(GetQueueUrlRequest.class));
willAnswer(invocation -> {
GetQueueUrlRequest getQueueUrlRequest = (GetQueueUrlRequest) invocation.getArguments()[0];
GetQueueUrlResult queueUrl = new GetQueueUrlResult();
queueUrl.setQueueUrl("http://queue-url.com/" + getQueueUrlRequest.getQueueName());
return queueUrl;
})
.given(amazonSqs)
.getQueueUrl(any(GetQueueUrlRequest.class));
return amazonSqs;
}

View File

@@ -1,28 +1,26 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aws.outbound;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate;
import org.springframework.context.annotation.Bean;
@@ -55,17 +53,14 @@ public class SqsMessageHandlerWithQueueMessagingTemplateTests extends AbstractSq
public AmazonSQS amazonSqs() {
AmazonSQS amazonSqs = mock(AmazonSQS.class);
doAnswer(new Answer<GetQueueUrlResult>() {
@Override
public GetQueueUrlResult answer(InvocationOnMock invocation) throws Throwable {
GetQueueUrlRequest getQueueUrlRequest = (GetQueueUrlRequest) invocation.getArguments()[0];
GetQueueUrlResult queueUrl = new GetQueueUrlResult();
queueUrl.setQueueUrl("http://queue-url.com/" + getQueueUrlRequest.getQueueName());
return queueUrl;
}
}).when(amazonSqs).getQueueUrl(any(GetQueueUrlRequest.class));
willAnswer(invocation -> {
GetQueueUrlRequest getQueueUrlRequest = (GetQueueUrlRequest) invocation.getArguments()[0];
GetQueueUrlResult queueUrl = new GetQueueUrlResult();
queueUrl.setQueueUrl("http://queue-url.com/" + getQueueUrlRequest.getQueueName());
return queueUrl;
})
.given(amazonSqs)
.getQueueUrl(any(GetQueueUrlRequest.class));
return amazonSqs;
}