Class WebScopeAwareTestSetup


  • @Immutable
    public final class WebScopeAwareTestSetup
    extends Object
    Contains static initialization methods for web scope tests, that makes it a bit easier to use them without JUnit.
    Author:
    Philip Helger
    • Method Detail

      • createDefaultMockServletContext

        @Nonnull
        public static com.helger.servlet.mock.MockServletContext createDefaultMockServletContext()
        Create a new mock servlet context using the context path MOCK_CONTEXT_PATH and no context init parameters.
        Returns:
        Never null.
      • createDefaultMockServletContext

        @Nonnull
        public static com.helger.servlet.mock.MockServletContext createDefaultMockServletContext​(@Nullable
                                                                                                 String sContextPath,
                                                                                                 @Nullable
                                                                                                 Map<String,​String> aInitParams)
        Create a new mock servlet context.
        Parameters:
        sContextPath - The context path to use. May be null.
        aInitParams - The initialization context parameters to use. May be null.
        Returns:
        Never null.
      • createDefaultMockRequest

        @Nonnull
        public static com.helger.servlet.mock.MockHttpServletRequest createDefaultMockRequest​(@Nonnull
                                                                                              com.helger.servlet.mock.MockServletContext aServletContext)
        Create a new mock request.
        Parameters:
        aServletContext - The servlet context to use. May be null but not recommended.
        Returns:
        Never null.
      • shutdownWebScopeTests

        public static void shutdownWebScopeTests​(@Nullable
                                                 com.helger.servlet.mock.MockHttpServletRequest aRequest,
                                                 @Nullable
                                                 com.helger.servlet.mock.MockServletContext aServletContext)
        Invalidate the passed request and the passed servlet context after the test.
        Parameters:
        aRequest - The request to invalidate. May be null.
        aServletContext - The servlet context to invalidate. May be null.