├── README.md ├── .mvn ├── jvm.config ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src └── test │ ├── resources │ ├── application.yml │ └── AwsIntegrationTestTemplate.json │ └── java │ └── org │ └── springframework │ └── cloud │ └── stream │ └── app │ └── aws │ ├── AwsIntegrationTestStackRule.java │ └── SpringCloudStreamAwsApplicationsITCase.java ├── .gitignore ├── README.adoc ├── pom.xml ├── mvnw.cmd ├── mvnw └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # aws-integration-tests is no longer actively maintained by VMware, Inc. 2 | 3 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/aws-integration-tests/main/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip -------------------------------------------------------------------------------- /src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | cloud: 2 | aws: 3 | region: 4 | static: us-east-1 5 | stack: 6 | name: IntegrationTestStack 7 | -------------------------------------------------------------------------------- /src/test/resources/AwsIntegrationTestTemplate.json: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion": "2010-09-09", 3 | "Description": "Spring Cloud Stream App Starters AWS Integration Test Template", 4 | "Resources": { 5 | "TestBucket": { 6 | "Type": "AWS::S3::Bucket" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | apps/ 2 | /application.yml 3 | /application.properties 4 | asciidoctor.css 5 | *~ 6 | .#* 7 | *# 8 | target/ 9 | build/ 10 | bin/ 11 | _site/ 12 | .classpath 13 | .project 14 | .settings 15 | .springBeans 16 | .DS_Store 17 | *.sw* 18 | *.iml 19 | *.ipr 20 | *.iws 21 | .idea/ 22 | .factorypath 23 | spring-xd-samples/*/xd 24 | dump.rdb 25 | coverage-error.log 26 | .apt_generated 27 | aws.credentials.properties 28 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Stream Application Starters AWS Integration Tests 2 | 3 | This module contains a test-suite which runs integration tests to ensure compatibility with the Amazon Web Services. 4 | In order to run the integration tests, the build process has to create different resources on the Amazon Webservice platform (Amazon EC2 instances, Amazon RDS instances, Amazon S3 Buckets, Amazon SQS Queues). 5 | Creating these resources takes time and costs money, because every instance creation is charged with a one hour usage. 6 | Therefore Spring Cloud AWS does not execute the integration tests by default. 7 | 8 | In order to execute the integration tests you have to create credentials configuration files that configure the necessary parameters to build the environment. 9 | 10 | Please create a new file named `aws.credentials.properties` in any desired place and provide the path as a `aws.credentials.path` Maven command argument (see below). 11 | The `accessKey` and `secretKey` are account/user specific and should never be shared to anyone. 12 | To retrieve these settings you have to open your account inside the AWS console and retrieve them through the https://portal.aws.amazon.com/gp/aws/securityCredentials[Security Credentials Page]. 13 | _Note:_ In general we recommend that you use an https://aws.amazon.com/iam/[Amazon IAM] user instead of the account itself. 14 | 15 | An example file will look like this 16 | 17 | ------------------------------------------- 18 | cloud.aws.credentials.accessKey=ilaugsjdlkahgsdlaksdhg 19 | cloud.aws.credentials.secretKey=aöksjdhöadjs,höalsdhjköalsdjhasd+ 20 | ------------------------------------------- 21 | 22 | After creating the `aws.credentials.properties` file and storing it outside the project (or inside the project, they are ignored in git) you have to provide the configuration directory when running the build. 23 | Providing these configuration settings will automatically execute the integration tests. 24 | 25 | To build with the integration tests you must execute 26 | 27 | ----------------------------------------------------------------------------------------------------- 28 | mvnw -pl :spring-cloud-starter-stream-aws-integration-tests verify -Daws.credentials.path=/Users/foo/config/dir 29 | ----------------------------------------------------------------------------------------------------- 30 | 31 | The integration test will create an https://aws.amazon.com/de/cloudformation/[Amazon Web Services CloudFormation] stack and execute the tests. 32 | The stack is destroyed after executing the tests (either successful or failed) to ensure that there are no unnecessary costs. 33 | 34 | == Costs of integration tests 35 | 36 | The costs for one integration test run should not be more then 0.40 $ per hour (excl. VAT). 37 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | app-starters-build 7 | org.springframework.cloud.stream.app 8 | 1.1.1.BUILD-SNAPSHOT 9 | 10 | 11 | spring-cloud-starter-stream-aws-integration-tests 12 | Spring Cloud Stream Starters Amazon Integration Tests 13 | spring-cloud-starter-stream-aws-integration-tests 14 | 1.1.0.BUILD-SNAPSHOT 15 | 16 | 17 | org.springframework.cloud.stream.app 18 | spring-cloud-starter-stream-source-s3 19 | 1.1.0.BUILD-SNAPSHOT 20 | 21 | 22 | org.springframework.cloud.stream.app 23 | spring-cloud-starter-stream-sink-s3 24 | 1.1.0.BUILD-SNAPSHOT 25 | 26 | 27 | 28 | 29 | org.springframework.cloud.stream.app 30 | app-starters-test-support 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-failsafe-plugin 39 | 40 | 41 | 42 | 43 | 44 | spring 45 | 46 | 47 | spring-snapshots 48 | Spring Snapshots 49 | https://repo.spring.io/libs-snapshot-local 50 | 51 | true 52 | 53 | 54 | 55 | spring-milestones 56 | Spring Milestones 57 | https://repo.spring.io/libs-milestone-local 58 | 59 | false 60 | 61 | 62 | 63 | spring-releases 64 | Spring Releases 65 | https://repo.spring.io/release 66 | 67 | false 68 | 69 | 70 | 71 | spring-libs-release 72 | Spring Libs Release 73 | https://repo.spring.io/libs-release 74 | 75 | false 76 | 77 | 78 | 79 | 80 | false 81 | 82 | spring-milestone-release 83 | Spring Milestone Release 84 | https://repo.spring.io/libs-milestone 85 | 86 | 87 | 88 | 89 | spring-snapshots 90 | Spring Snapshots 91 | https://repo.spring.io/libs-snapshot-local 92 | 93 | true 94 | 95 | 96 | 97 | spring-milestones 98 | Spring Milestones 99 | https://repo.spring.io/libs-milestone-local 100 | 101 | false 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% 146 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/cloud/stream/app/aws/AwsIntegrationTestStackRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.aws; 18 | 19 | import java.io.File; 20 | import java.io.FileReader; 21 | import java.io.InputStreamReader; 22 | import java.util.List; 23 | import java.util.Properties; 24 | 25 | import org.apache.commons.logging.Log; 26 | import org.apache.commons.logging.LogFactory; 27 | import org.junit.Assume; 28 | import org.junit.AssumptionViolatedException; 29 | import org.junit.rules.ExternalResource; 30 | 31 | import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; 32 | import org.springframework.core.io.ClassPathResource; 33 | import org.springframework.util.CollectionUtils; 34 | import org.springframework.util.FileCopyUtils; 35 | 36 | import com.amazonaws.auth.BasicAWSCredentials; 37 | import com.amazonaws.services.cloudformation.AmazonCloudFormation; 38 | import com.amazonaws.services.cloudformation.AmazonCloudFormationClient; 39 | import com.amazonaws.services.cloudformation.model.CreateStackRequest; 40 | import com.amazonaws.services.cloudformation.model.DeleteStackRequest; 41 | import com.amazonaws.services.cloudformation.model.DescribeStacksRequest; 42 | import com.amazonaws.services.cloudformation.model.OnFailure; 43 | import com.amazonaws.services.cloudformation.model.Stack; 44 | import com.amazonaws.services.cloudformation.model.StackStatus; 45 | 46 | /** 47 | * @author Artem Bilan 48 | */ 49 | public class AwsIntegrationTestStackRule extends ExternalResource { 50 | 51 | private static final Log logger = LogFactory.getLog(AwsIntegrationTestStackRule.class); 52 | 53 | private AmazonCloudFormation cloudFormation; 54 | 55 | private String stackName; 56 | 57 | @Override 58 | protected void before() throws Throwable { 59 | try { 60 | String awsCredentialsDir = System.getProperty("aws.credentials.path"); 61 | File awsCredentialsFile = new File(awsCredentialsDir, "aws.credentials.properties"); 62 | Properties awsCredentials = new Properties(); 63 | awsCredentials.load(new FileReader(awsCredentialsFile)); 64 | String accessKey = awsCredentials.getProperty("cloud.aws.credentials.accessKey"); 65 | String secretKey = awsCredentials.getProperty("cloud.aws.credentials.secretKey"); 66 | this.cloudFormation = new AmazonCloudFormationClient(new BasicAWSCredentials(accessKey, secretKey)); 67 | 68 | YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); 69 | yamlPropertiesFactoryBean.setResources(new ClassPathResource("application.yml")); 70 | Properties applicationProperties = yamlPropertiesFactoryBean.getObject(); 71 | 72 | this.stackName = applicationProperties.getProperty("cloud.aws.stack.name"); 73 | 74 | after(); 75 | 76 | ClassPathResource stackTemplate = new ClassPathResource("AwsIntegrationTestTemplate.json"); 77 | String templateBody = FileCopyUtils.copyToString(new InputStreamReader(stackTemplate.getInputStream())); 78 | 79 | this.cloudFormation.createStack( 80 | new CreateStackRequest() 81 | .withTemplateBody(templateBody) 82 | .withOnFailure(OnFailure.DELETE) 83 | .withStackName(this.stackName)); 84 | 85 | waitForCompletion(); 86 | 87 | System.setProperty("cloud.aws.credentials.accessKey", accessKey); 88 | System.setProperty("cloud.aws.credentials.secretKey", secretKey); 89 | } 90 | catch (Exception e) { 91 | if (!(e instanceof AssumptionViolatedException)) { 92 | Assume.assumeTrue("Can't perform AWS integration test because of: " + e.getMessage(), false); 93 | } 94 | else { 95 | throw e; 96 | } 97 | } 98 | } 99 | 100 | @Override 101 | protected void after() { 102 | this.cloudFormation.deleteStack(new DeleteStackRequest() 103 | .withStackName(this.stackName)); 104 | try { 105 | waitForCompletion(); 106 | } 107 | catch (InterruptedException e) { 108 | // Ignore the InterruptedException 109 | } 110 | finally { 111 | System.clearProperty("cloud.aws.credentials.accessKey"); 112 | System.clearProperty("cloud.aws.credentials.secretKey"); 113 | } 114 | } 115 | 116 | // Wait for a stack to complete transitioning 117 | // End stack states are: 118 | // CREATE_COMPLETE 119 | // CREATE_FAILED 120 | // DELETE_FAILED 121 | // ROLLBACK_FAILED 122 | // OR the stack no longer exists 123 | private void waitForCompletion() throws InterruptedException { 124 | DescribeStacksRequest wait = new DescribeStacksRequest(); 125 | wait.setStackName(this.stackName); 126 | Boolean completed = false; 127 | String stackStatus = "Unknown"; 128 | String stackReason = ""; 129 | 130 | while (!completed) { 131 | List stacks = null; 132 | try { 133 | stacks = this.cloudFormation.describeStacks(wait).getStacks(); 134 | } 135 | catch (Exception e) { 136 | logger.error("cloudFormation.describeStacks() exception", e); 137 | } 138 | if (CollectionUtils.isEmpty(stacks)) { 139 | completed = true; 140 | stackStatus = StackStatus.DELETE_COMPLETE.toString(); 141 | stackReason = "Stack has been deleted"; 142 | } 143 | else { 144 | for (Stack stack : stacks) { 145 | if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) || 146 | stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString()) || 147 | stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString()) || 148 | stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) { 149 | completed = true; 150 | stackStatus = stack.getStackStatus(); 151 | stackReason = stack.getStackStatusReason(); 152 | } 153 | } 154 | } 155 | 156 | // Not done yet so sleep for 2 seconds. 157 | if (!completed) { 158 | Thread.sleep(2000); 159 | } 160 | else { 161 | if (stackStatus.equals(StackStatus.CREATE_FAILED.toString())) { 162 | Assume.assumeTrue("The test AWS stack [" + this.stackName + "] cannot be created. Reason: " + 163 | stackReason, true); 164 | } 165 | } 166 | } 167 | } 168 | 169 | } 170 | -------------------------------------------------------------------------------- /src/test/java/org/springframework/cloud/stream/app/aws/SpringCloudStreamAwsApplicationsITCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.aws; 18 | 19 | import static org.hamcrest.Matchers.equalTo; 20 | import static org.junit.Assert.assertNotNull; 21 | import static org.junit.Assert.assertThat; 22 | import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader; 23 | import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload; 24 | 25 | import java.io.ByteArrayInputStream; 26 | import java.io.File; 27 | import java.io.FileOutputStream; 28 | import java.io.IOException; 29 | import java.nio.charset.Charset; 30 | import java.util.ArrayList; 31 | import java.util.Collections; 32 | import java.util.Comparator; 33 | import java.util.LinkedList; 34 | import java.util.List; 35 | import java.util.concurrent.TimeUnit; 36 | 37 | import org.junit.After; 38 | import org.junit.ClassRule; 39 | import org.junit.Rule; 40 | import org.junit.Test; 41 | import org.junit.rules.TemporaryFolder; 42 | 43 | import org.springframework.boot.SpringApplication; 44 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 45 | import org.springframework.cloud.aws.core.env.ResourceIdResolver; 46 | import org.springframework.cloud.stream.app.s3.sink.AmazonS3SinkConfiguration; 47 | import org.springframework.cloud.stream.app.s3.source.AmazonS3SourceConfiguration; 48 | import org.springframework.cloud.stream.messaging.Sink; 49 | import org.springframework.cloud.stream.messaging.Source; 50 | import org.springframework.cloud.stream.test.binder.MessageCollector; 51 | import org.springframework.context.ConfigurableApplicationContext; 52 | import org.springframework.context.annotation.Configuration; 53 | import org.springframework.context.annotation.Import; 54 | import org.springframework.integration.file.FileHeaders; 55 | import org.springframework.messaging.Message; 56 | import org.springframework.messaging.support.GenericMessage; 57 | import org.springframework.util.FileCopyUtils; 58 | import org.springframework.util.StreamUtils; 59 | 60 | import com.amazonaws.services.s3.AmazonS3; 61 | import com.amazonaws.services.s3.model.DeleteObjectsRequest; 62 | import com.amazonaws.services.s3.model.ObjectListing; 63 | import com.amazonaws.services.s3.model.ObjectMetadata; 64 | import com.amazonaws.services.s3.model.S3Object; 65 | import com.amazonaws.services.s3.model.S3ObjectSummary; 66 | 67 | /** 68 | * @author Artem Bilan 69 | */ 70 | public class SpringCloudStreamAwsApplicationsITCase { 71 | 72 | @ClassRule 73 | public static final AwsIntegrationTestStackRule TEST_STACK_RULE = new AwsIntegrationTestStackRule(); 74 | 75 | @Rule 76 | public TemporaryFolder temporaryFolder = new TemporaryFolder(); 77 | 78 | private ConfigurableApplicationContext applicationContext; 79 | 80 | @After 81 | public void after() { 82 | if (this.applicationContext != null) { 83 | this.applicationContext.close(); 84 | } 85 | } 86 | 87 | @Test 88 | public void testS3Source() throws IOException, InterruptedException { 89 | String bucket = "TestBucket"; 90 | String key = "foo"; 91 | String content = "Spring Cloud Stream AWS S3 Source test"; 92 | 93 | this.applicationContext = SpringApplication.run(S3SourceBootConfiguration.class, 94 | "--s3.remoteDir=" + bucket, "--file.consumer.mode=lines", "--file.consumer.with-markers=false"); 95 | 96 | ResourceIdResolver resourceIdResolver = this.applicationContext.getBean(ResourceIdResolver.class); 97 | 98 | AmazonS3 amazonS3 = this.applicationContext.getBean(AmazonS3.class); 99 | ObjectMetadata objectMetadata = new ObjectMetadata(); 100 | objectMetadata.setContentLength(content.length()); 101 | String bucketName = resourceIdResolver.resolveToPhysicalResourceId(bucket); 102 | amazonS3.putObject(bucketName, key, new ByteArrayInputStream(content.getBytes("UTF-8")), objectMetadata); 103 | 104 | try { 105 | Source source = this.applicationContext.getBean(Source.class); 106 | MessageCollector messageCollector = this.applicationContext.getBean(MessageCollector.class); 107 | Message received = messageCollector.forChannel(source.output()).poll(10, TimeUnit.SECONDS); 108 | assertNotNull(received); 109 | assertThat(received, hasHeader(FileHeaders.FILENAME, key)); 110 | assertThat(received, hasPayload("Spring Cloud Stream AWS S3 Source test")); 111 | } 112 | finally { 113 | amazonS3.deleteObject(bucketName, key); 114 | } 115 | } 116 | 117 | @Test 118 | public void testS3Sink() throws IOException, InterruptedException { 119 | String bucket = "TestBucket"; 120 | String key = this.temporaryFolder.getRoot().getName(); 121 | 122 | List testFiles = new ArrayList<>(); 123 | 124 | String content = "Spring Cloud Stream AWS S3 Sink test #"; 125 | 126 | for (int i = 0; i < 2; i++) { 127 | File testFile = this.temporaryFolder.newFile(); 128 | 129 | FileOutputStream fos = new FileOutputStream(testFile); 130 | fos.write((content + (i + 1)).getBytes()); 131 | fos.close(); 132 | 133 | testFiles.add(testFile); 134 | } 135 | 136 | this.applicationContext = SpringApplication.run(S3SinkBootConfiguration.class, "--s3.bucket=" + bucket); 137 | 138 | ResourceIdResolver resourceIdResolver = this.applicationContext.getBean(ResourceIdResolver.class); 139 | 140 | AmazonS3 amazonS3 = this.applicationContext.getBean(AmazonS3.class); 141 | String bucketName = resourceIdResolver.resolveToPhysicalResourceId(bucket); 142 | Sink sink = this.applicationContext.getBean(Sink.class); 143 | 144 | List objectSummaries = null; 145 | try { 146 | sink.input().send(new GenericMessage<>(this.temporaryFolder.getRoot())); 147 | 148 | ObjectListing objectListing = amazonS3.listObjects(bucketName, key); 149 | objectSummaries = objectListing.getObjectSummaries(); 150 | assertThat(objectSummaries.size(), equalTo(2)); 151 | 152 | Collections.sort(objectSummaries, new Comparator() { 153 | 154 | @Override 155 | public int compare(S3ObjectSummary o1, S3ObjectSummary o2) { 156 | return o1.getKey().compareTo(o2.getKey()); 157 | } 158 | 159 | }); 160 | 161 | Collections.sort(testFiles, new Comparator() { 162 | 163 | @Override 164 | public int compare(File o1, File o2) { 165 | return o1.getName().compareTo(o2.getName()); 166 | } 167 | 168 | }); 169 | 170 | for (int i = 0; i < 2; i++) { 171 | S3ObjectSummary s3ObjectSummary = objectSummaries.get(i); 172 | File file = testFiles.get(i); 173 | String fileKey = key + "/" + file.getName(); 174 | assertThat(s3ObjectSummary.getKey(), equalTo(fileKey)); 175 | 176 | S3Object s3Object1 = amazonS3.getObject(bucketName, fileKey); 177 | assertThat(StreamUtils.copyToByteArray(s3Object1.getObjectContent()), 178 | equalTo(FileCopyUtils.copyToByteArray(file))); 179 | } 180 | } 181 | finally { 182 | if (objectSummaries != null) { 183 | for (S3ObjectSummary objectSummary : objectSummaries) { 184 | amazonS3.deleteObject(bucketName, objectSummary.getKey()); 185 | } 186 | } 187 | } 188 | } 189 | 190 | 191 | @Configuration 192 | @EnableAutoConfiguration 193 | @Import(AmazonS3SourceConfiguration.class) 194 | public static class S3SourceBootConfiguration { 195 | 196 | } 197 | 198 | @Configuration 199 | @EnableAutoConfiguration 200 | @Import(AmazonS3SinkConfiguration.class) 201 | public static class S3SinkBootConfiguration { 202 | 203 | } 204 | 205 | } 206 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | #VERSION=$(sed `dirname $0`/pom.xml -e '/\(.*\)<.*/\1/') 50 | #if echo $VERSION | egrep -q 'M|RC'; then 51 | # echo Activating \"milestone\" profile for version=\"$VERSION\" 52 | # echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" 53 | #else 54 | # echo Deactivating \"milestone\" profile for version=\"$VERSION\" 55 | # echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') 56 | #fi 57 | 58 | # OS specific support. $var _must_ be set to either true or false. 59 | cygwin=false; 60 | darwin=false; 61 | mingw=false 62 | case "`uname`" in 63 | CYGWIN*) cygwin=true ;; 64 | MINGW*) mingw=true;; 65 | Darwin*) darwin=true 66 | # 67 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 68 | # for the new JDKs provided by Oracle. 69 | # 70 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 71 | # 72 | # Apple JDKs 73 | # 74 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 75 | fi 76 | 77 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 78 | # 79 | # Apple JDKs 80 | # 81 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 82 | fi 83 | 84 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 85 | # 86 | # Oracle JDKs 87 | # 88 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 89 | fi 90 | 91 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 92 | # 93 | # Apple JDKs 94 | # 95 | export JAVA_HOME=`/usr/libexec/java_home` 96 | fi 97 | ;; 98 | esac 99 | 100 | if [ -z "$JAVA_HOME" ] ; then 101 | if [ -r /etc/gentoo-release ] ; then 102 | JAVA_HOME=`java-config --jre-home` 103 | fi 104 | fi 105 | 106 | if [ -z "$M2_HOME" ] ; then 107 | ## resolve links - $0 may be a link to maven's home 108 | PRG="$0" 109 | 110 | # need this for relative symlinks 111 | while [ -h "$PRG" ] ; do 112 | ls=`ls -ld "$PRG"` 113 | link=`expr "$ls" : '.*-> \(.*\)$'` 114 | if expr "$link" : '/.*' > /dev/null; then 115 | PRG="$link" 116 | else 117 | PRG="`dirname "$PRG"`/$link" 118 | fi 119 | done 120 | 121 | saveddir=`pwd` 122 | 123 | M2_HOME=`dirname "$PRG"`/.. 124 | 125 | # make it fully qualified 126 | M2_HOME=`cd "$M2_HOME" && pwd` 127 | 128 | cd "$saveddir" 129 | # echo Using m2 at $M2_HOME 130 | fi 131 | 132 | # For Cygwin, ensure paths are in UNIX format before anything is touched 133 | if $cygwin ; then 134 | [ -n "$M2_HOME" ] && 135 | M2_HOME=`cygpath --unix "$M2_HOME"` 136 | [ -n "$JAVA_HOME" ] && 137 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 138 | [ -n "$CLASSPATH" ] && 139 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 140 | fi 141 | 142 | # For Migwn, ensure paths are in UNIX format before anything is touched 143 | if $mingw ; then 144 | [ -n "$M2_HOME" ] && 145 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 146 | [ -n "$JAVA_HOME" ] && 147 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 148 | # TODO classpath? 149 | fi 150 | 151 | if [ -z "$JAVA_HOME" ]; then 152 | javaExecutable="`which javac`" 153 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 154 | # readlink(1) is not available as standard on Solaris 10. 155 | readLink=`which readlink` 156 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 157 | if $darwin ; then 158 | javaHome="`dirname \"$javaExecutable\"`" 159 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 160 | else 161 | javaExecutable="`readlink -f \"$javaExecutable\"`" 162 | fi 163 | javaHome="`dirname \"$javaExecutable\"`" 164 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 165 | JAVA_HOME="$javaHome" 166 | export JAVA_HOME 167 | fi 168 | fi 169 | fi 170 | 171 | if [ -z "$JAVACMD" ] ; then 172 | if [ -n "$JAVA_HOME" ] ; then 173 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 174 | # IBM's JDK on AIX uses strange locations for the executables 175 | JAVACMD="$JAVA_HOME/jre/sh/java" 176 | else 177 | JAVACMD="$JAVA_HOME/bin/java" 178 | fi 179 | else 180 | JAVACMD="`which java`" 181 | fi 182 | fi 183 | 184 | if [ ! -x "$JAVACMD" ] ; then 185 | echo "Error: JAVA_HOME is not defined correctly." >&2 186 | echo " We cannot execute $JAVACMD" >&2 187 | exit 1 188 | fi 189 | 190 | if [ -z "$JAVA_HOME" ] ; then 191 | echo "Warning: JAVA_HOME environment variable is not set." 192 | fi 193 | 194 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 195 | 196 | # For Cygwin, switch paths to Windows format before running java 197 | if $cygwin; then 198 | [ -n "$M2_HOME" ] && 199 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 200 | [ -n "$JAVA_HOME" ] && 201 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 202 | [ -n "$CLASSPATH" ] && 203 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 204 | fi 205 | 206 | # traverses directory structure from process work directory to filesystem root 207 | # first directory with .mvn subdirectory is considered project base directory 208 | find_maven_basedir() { 209 | local basedir=$(pwd) 210 | local wdir=$(pwd) 211 | while [ "$wdir" != '/' ] ; do 212 | if [ -d "$wdir"/.mvn ] ; then 213 | basedir=$wdir 214 | break 215 | fi 216 | wdir=$(cd "$wdir/.."; pwd) 217 | done 218 | echo "${basedir}" 219 | } 220 | 221 | # concatenates all lines of a file 222 | concat_lines() { 223 | if [ -f "$1" ]; then 224 | echo "$(tr -s '\n' ' ' < "$1")" 225 | fi 226 | } 227 | 228 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 229 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 230 | 231 | # Provide a "standardized" way to retrieve the CLI args that will 232 | # work with both Windows and non-Windows executions. 233 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 234 | export MAVEN_CMD_LINE_ARGS 235 | 236 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 237 | 238 | exec "$JAVACMD" \ 239 | $MAVEN_OPTS \ 240 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 241 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 242 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" 243 | 244 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2015-Present Pivotal Software Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | 205 | 206 | --------------------------------------------------------------------------------