Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-12278

Improve handling of late instantiated context in SlingContextExtension/OsgiContextExtension

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Testing OSGi Mock 3.4.2, Testing Sling Mock 3.5.0
    • None
    • Testing
    • None

    Description

      Currently neither in https://sling.apache.org/documentation/development/osgi-mock.html#junit-5-osgi-context-junit-extension nor in https://sling.apache.org/documentation/development/sling-mock.html#junit-5-sling-context-junit-extension it is mentioned that the context must not be instantiated in @BeforeAll or @BeforeEach as at that point in time the extension has already instantiated another context. Those two contexts may lead to subtle issues (for example if resources are only added in the second context). For a concrete example look at https://github.com/wcm-io/io.wcm.testing.aem-mock/issues/37.

      In the best case the JUnit5 extension never creates a context (but only uses the existing instance) or at least creation should be deferred until the Before methods have been executed.

      Attachments

        Issue Links

          Activity

            People

              sseifert Stefan Seifert
              kwin Konrad Windszus
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: