So I want to mock AWS SDK 2.x (only S3 service), so that test upload and download files to a bucket without a real AWS. I'm looking for a Java implementations.
I found a lot what implements (Adobe S3Mock ...etc), but all of them uses AWS SDK 1.x.
You shouldn't re-implement the S3 API yourself. Instead, use one of the existing tools like localstack , MinIO , OpenStack Swift and others. They all provide S3-compatible API (though some dif ferences can be). The best one for tests is localstack, IMHO.It is available as a Docker image , so you can use it locally or in your CI pipelines.
Not to the Java part of your question. If you are a lucky user of JUnit 5 I would recommend you to use aws-junit5
, a set of JUnit 5 extensions for AWS. And, yes, I am it's author. These extensions can be used to inject clients for AWS services provided by tools like localstack (actually, any AWS-compatible API is supported, including real AWS itself). Both AWS Java SDK v 2.x and v 1.x are supported. You can use aws-junit5
to inject clients for S3, DynamoDB, Kinesis, SES, SNS and SQS.
Read more in the user guide , it even has a section about CI configuration with GitLab .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.