@NotThreadSafe public class WebScopeTestRule extends org.junit.rules.ExternalResource
| Modifier and Type | Field and Description |
|---|---|
static String |
MOCK_CONTEXT_PATH
Mock servlet context name
|
| Constructor and Description |
|---|
WebScopeTestRule() |
WebScopeTestRule(com.helger.commons.collection.impl.ICommonsMap<String,String> aServletContextInitParameters) |
| Modifier and Type | Method and Description |
|---|---|
void |
after() |
void |
before() |
protected com.helger.servlet.mock.MockHttpServletRequest |
createMockRequest(com.helger.servlet.mock.MockServletContext aServletContext)
Create a new mock request
|
protected com.helger.servlet.mock.MockServletContext |
createMockServletContext(String sContextPath,
Map<String,String> aInitParams)
Create a new mock servlet context
|
String |
getContextPath() |
com.helger.servlet.mock.MockHttpServletRequest |
getRequest() |
com.helger.servlet.mock.MockServletContext |
getServletContext() |
com.helger.commons.collection.impl.ICommonsMap<String,String> |
getServletContextInitParameters() |
com.helger.servlet.mock.MockServletPool |
getServletPool() |
javax.servlet.http.HttpSession |
getSession(boolean bCreateIfNotExisting) |
protected void |
initListener()
This method triggers the initialization of the
MockHttpListener. |
WebScopeTestRule |
setContextPath(String sContextPath) |
WebScopeTestRule |
setServletContextInitParameters(com.helger.commons.collection.impl.ICommonsMap<String,String> aServletContextInitParameters) |
String |
toString() |
public static final String MOCK_CONTEXT_PATH
@Nonnull public final WebScopeTestRule setContextPath(@Nullable String sContextPath)
@Nonnull public final WebScopeTestRule setServletContextInitParameters(@Nullable com.helger.commons.collection.impl.ICommonsMap<String,String> aServletContextInitParameters)
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsMap<String,String> getServletContextInitParameters()
@OverrideOnDemand protected void initListener()
MockHttpListener. It
is called before the main servlet context is created.@Nonnull @OverrideOnDemand protected com.helger.servlet.mock.MockServletContext createMockServletContext(@Nullable String sContextPath, @Nullable Map<String,String> aInitParams)
sContextPath - The context path to use. May be null.aInitParams - The initialization context parameters to use. May be
null.null.@Nullable @OverrideOnDemand protected com.helger.servlet.mock.MockHttpServletRequest createMockRequest(@Nonnull com.helger.servlet.mock.MockServletContext aServletContext)
aServletContext - The servlet context to use. Never null.null to indicate that the request is added
manually - this is helpful for servlet testing.@OverrideOnDemand @OverridingMethodsMustInvokeSuper public void before()
before in class org.junit.rules.ExternalResource@OverrideOnDemand @OverridingMethodsMustInvokeSuper public void after()
after in class org.junit.rules.ExternalResource@Nullable public final com.helger.servlet.mock.MockServletContext getServletContext()
MockServletContext or null if non
has been created yet.@Nullable public final com.helger.servlet.mock.MockServletPool getServletPool()
MockServletPool of the MockServletContext or
null if no servlet context has been created yet.@Nullable public final com.helger.servlet.mock.MockHttpServletRequest getRequest()
MockHttpServletRequest or null if
non has been created yet.@Nullable public final javax.servlet.http.HttpSession getSession(boolean bCreateIfNotExisting)
bCreateIfNotExisting - true to create a new session, if non is existing yet.
This has only an effect if a request is present.HttpSession or null if no session was
created or if no request is present.Copyright © 2014–2019 Philip Helger. All rights reserved.