Class S3MockExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver

    public class S3MockExtension
    extends S3MockStarter
    implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.ParameterResolver
    JUnit extension to start and stop the S3Mock Application. After the tests, the S3Mock is stopped.

    The following modes are supported:

    1. Programmatic registration

     public class MyS3Test {
       @RegisterExtension
       public static S3MockExtension S3_MOCK = S3MockExtension.builder().build();
    
       private final AmazonS3 s3Client = S3_MOCK.createS3Client();
    
       @Test
       public void doSomethingWithS3() {
         s3Client.createBucket("myBucket");
       }
     }
     

    2. Declarative registration

     @ExtendWith(S3MockExtension.class)
     public class MyS3Test {
    
       @Test
       public void doSomethingWithS3(final AmazonS3 s3Client) {
         s3Client.createBucket("myBucket");
       }
     }
     
    • Constructor Detail

      • S3MockExtension

        public S3MockExtension()
        Creates an instance with the default configuration.
    • Method Detail

      • beforeAll

        public void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      • afterAll

        public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      • supportsParameter

        public boolean supportsParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                         org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                  throws org.junit.jupiter.api.extension.ParameterResolutionException
        Specified by:
        supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
        Throws:
        org.junit.jupiter.api.extension.ParameterResolutionException
      • resolveParameter

        public java.lang.Object resolveParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                                 org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                          throws org.junit.jupiter.api.extension.ParameterResolutionException
        Specified by:
        resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
        Throws:
        org.junit.jupiter.api.extension.ParameterResolutionException