Class FcSystemIntegrationExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.InvocationInterceptor, org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.TestInstancePostProcessor

    public class FcSystemIntegrationExtension
    extends Object
    implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.InvocationInterceptor, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback
    A JUnit extension for system integration tests. Sets up the formcycle system, including monitor threads and an in-RAM H2 database. All starts the Weld CDI runtime, as CDI is now required for all formcycle code. The system is set up once before all tests start and shut down once all tests end, instead of setting up the system once for each test. Setup takes a significant amount of time, so this helps to reduce the total test time. Individual tests should create a new client and be independent of other tests.

    You can use the following parameters in your test methods, a value will be provided by this extension:

    • IEntityContextHolder - Creates and injects a wrapper that can be used to access the entity context or to reload (close and open again) the context.
    • TestSystemInfo - Provides info about the system configuration.
    • WeldEnvironment - Gives you access to the started Weld CDI container.
    Any instance fields annotated with FcSetup will have the corresponding value injected as well.

    For debugging, you can set the environment variable DEBUG_SHOW_SQL to true to enable SQL statement logging.

    Since:
    8.0.0
    Author:
    XIMA MEDIA GmbH
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

        org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T extends Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void afterTestExecution​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void beforeTestExecution​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void interceptAfterAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      void interceptAfterEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      void interceptBeforeAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      void interceptBeforeEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      void postProcessTestInstance​(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)  
      Object resolveParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      boolean supportsParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)  
      • Methods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

        interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestMethod, interceptTestTemplateMethod
    • Constructor Detail

      • FcSystemIntegrationExtension

        public FcSystemIntegrationExtension()
    • Method Detail

      • afterAll

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

        public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                       throws Exception
        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
        Throws:
        Exception
      • afterTestExecution

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

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

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                        throws Exception
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Throws:
        Exception
      • beforeTestExecution

        public void beforeTestExecution​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        beforeTestExecution in interface org.junit.jupiter.api.extension.BeforeTestExecutionCallback
      • interceptAfterAllMethod

        public void interceptAfterAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                            org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                            org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                     throws Throwable
        Specified by:
        interceptAfterAllMethod in interface org.junit.jupiter.api.extension.InvocationInterceptor
        Throws:
        Throwable
      • interceptAfterEachMethod

        public void interceptAfterEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                             org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                             org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                      throws Throwable
        Specified by:
        interceptAfterEachMethod in interface org.junit.jupiter.api.extension.InvocationInterceptor
        Throws:
        Throwable
      • interceptBeforeAllMethod

        public void interceptBeforeAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                             org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                             org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                      throws Throwable
        Specified by:
        interceptBeforeAllMethod in interface org.junit.jupiter.api.extension.InvocationInterceptor
        Throws:
        Throwable
      • interceptBeforeEachMethod

        public void interceptBeforeEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                              org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                              org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                       throws Throwable
        Specified by:
        interceptBeforeEachMethod in interface org.junit.jupiter.api.extension.InvocationInterceptor
        Throws:
        Throwable
      • postProcessTestInstance

        public void postProcessTestInstance​(Object testInstance,
                                            org.junit.jupiter.api.extension.ExtensionContext context)
                                     throws Exception
        Specified by:
        postProcessTestInstance in interface org.junit.jupiter.api.extension.TestInstancePostProcessor
        Throws:
        Exception
      • resolveParameter

        public 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
      • 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