Comments (3)
@mpaluchowski I am using Junit's TemporaryFolder
rule which ensures clean S3Mock backend directory quite fine
from s3mock.
I've updated the docs, so now you can use in-memory provider for that case.
from s3mock.
@shuttie is there a way to clean up the entire memory contents after each test?
public class SampleJavaClassTest {
static S3Mock api = new S3Mock.Builder().withPort(8001).withInMemoryBackend().build();
S3AsyncClient client = S3AsyncClient.builder()
.serviceConfiguration(x -> x.pathStyleAccessEnabled(true))
.endpointOverride(URI.create("http://localhost:8001"))
.region(Region.US_WEST_2)
.credentialsProvider(AnonymousCredentialsProvider.create())
.build();
@BeforeAll
public static void setUp() throws URISyntaxException {
api.start();
}
@AfterAll
public static void teardown() {
api.shutdown();
}
@Test
public void testS3Mock_PutGet() throws InterruptedException, ExecutionException {
String bucketName = "test-bucket";
String input = "hello world";
client.createBucket(r -> r.bucket(bucketName)).get();
client.putObject(r -> r.bucket(bucketName).key("mykey"), AsyncRequestBody.fromString(input)).get();
var responseBytes = client.getObject(r -> r.bucket(bucketName).key("mykey"), AsyncResponseTransformer.toBytes()).get();
assertEquals(responseBytes.asUtf8String(), input);
// clean up
client.deleteBucket(r -> r.bucket(bucketName)).get();
}
]
I want to do some sort of @BeforeEach
which cleans up everything before each test instead of manually deleting the bucket as done above.
from s3mock.
Related Issues (20)
- Use correct default maxkeys size to trigger expected pagination
- Poor performance on Linux compared to Windows
- Increase file upload size config
- Need documentation on structure of S3MOCK_DATA_DIR HOT 2
- putObject() overrides lastModified in ObjectMetaData HOT 1
- Batch delete API (DeleteObjects) doesn't URL-encode object keys like single-object APIs
- Mime-Type change HOT 1
- Put Object fails when streaming
- Issue #47 Missed Max Keys on Response
- `Not Implemented` exception when working with `multipartCopy`
- java.lang.ClassNotFoundException: scala.$less$colon$less HOT 4
- response-content-disposition header is not respected
- missing uploadPartCopy?
- Is there an active fork for this project? HOT 3
- It's time to fix the build and upgrade libraries HOT 2
- S3Mock causes some S3Client calls to block for 30 seconds
- Encoding issue in listObjects
- listObjects only returns the first match
- use pekko instead of akka? HOT 1
- Different behaviour from the AWS Java SDK when deleting a non-existing item
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s3mock.