Class MockApplication
- java.lang.Object
-
- org.apache.wicket.Application
-
- org.apache.wicket.protocol.http.WebApplication
-
- org.apache.wicket.mock.MockApplication
-
- All Implemented Interfaces:
IEventSink
,IMetadataContext<Object,Application>
,ISessionStore.UnboundListener
public class MockApplication extends WebApplication
WebApplication
used for testing.
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.protocol.http.WebApplication
META_INF_RESOURCES
-
Fields inherited from class org.apache.wicket.Application
CONFIGURATION
-
-
Constructor Summary
Constructors Constructor Description MockApplication()
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RuntimeConfigurationType
getConfigurationType()
Gets the configuration mode to use for configuring the app, eitherRuntimeConfigurationType.DEVELOPMENT
orRuntimeConfigurationType.DEPLOYMENT
.Class<? extends Page>
getHomePage()
Application subclasses must specify a home page class by implementing this abstract method.String
getInitParameter(String key)
Gets an init parameter of the filter, or null if the parameter does not exist.Session
getSession()
protected void
internalInit()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.-
Methods inherited from class org.apache.wicket.protocol.http.WebApplication
addResourceReplacement, addResourceReplacement, get, getAjaxRequestTargetListeners, getAjaxRequestTargetProvider, getAndRemoveBufferedResponse, getApplicationKey, getCspSettings, getFilterFactoryManager, getMimeType, getServletContext, getSessionAttributePrefix, getWicketFilter, hasBufferedResponse, hasFilterFactoryManager, init, internalDestroy, logEventTarget, logResponseTarget, mount, mountPackage, mountPage, mountResource, newAjaxRequestTarget, newCspSettings, newSession, newWebRequest, newWebResponse, outputDevelopmentModeWarning, renderXmlDecl, sessionUnbound, setAjaxRequestTargetProvider, setConfigurationType, setCspSettings, setServletContext, setWicketFilter, storeBufferedResponse, unmount, validateInit
-
Methods inherited from class org.apache.wicket.Application
checkSettingsAvailable, configure, createRequestCycle, decorateHeaderResponse, exists, fetchCreateAndSetSession, get, getApplicationKeys, getApplicationListeners, getApplicationSettings, getBehaviorInstantiationListeners, getComponentInitializationListeners, getComponentInstantiationListeners, getComponentOnAfterRenderListeners, getComponentOnConfigureListeners, getComponentPostOnBeforeRenderListeners, getComponentPreOnBeforeRenderListeners, getConverterLocator, getDebugSettings, getExceptionMapperProvider, getExceptionSettings, getFrameworkSettings, getHeaderContributorListeners, getHeaderResponseDecorators, getInitializers, getJavaScriptLibrarySettings, getMapperContext, getMarkupSettings, getMetaData, getName, getOnComponentTagListeners, getPageFactory, getPageManagerProvider, getPageRendererProvider, getPageSettings, getRequestCycleListeners, getRequestCycleProvider, getRequestCycleSettings, getRequestLogger, getRequestLoggerSettings, getResourceBundles, getResourceReferenceRegistry, getResourceSettings, getRootRequestMapper, getRootRequestMapperAsCompound, getSecuritySettings, getSessionListeners, getSessionStore, getSessionStoreProvider, getSharedResources, getStoreSettings, initApplication, newConverterLocator, newMapperContext, newPageFactory, newRequestLogger, newResourceBundles, newResourceReferenceRegistry, newSharedResources, onDestroy, onEvent, setApplicationSettings, setDebugSettings, setExceptionMapperProvider, setExceptionSettings, setFrameworkSettings, setHeaderResponseDecorator, setJavaScriptLibrarySettings, setMarkupSettings, setMetaData, setName, setPageManagerProvider, setPageRendererProvider, setPageSettings, setRequestCycleProvider, setRequestCycleSettings, setRequestLoggerSettings, setResourceSettings, setRootRequestMapper, setSecuritySettings, setSessionStoreProvider, setStoreSettings, usesDeploymentConfig, usesDevelopmentConfig
-
-
-
-
Constructor Detail
-
MockApplication
public MockApplication()
Construct.
-
-
Method Detail
-
getHomePage
public Class<? extends Page> getHomePage()
Description copied from class:Application
Application subclasses must specify a home page class by implementing this abstract method.- Specified by:
getHomePage
in classApplication
- Returns:
- Home page class for this application
-
getConfigurationType
public RuntimeConfigurationType getConfigurationType()
Description copied from class:WebApplication
Gets the configuration mode to use for configuring the app, eitherRuntimeConfigurationType.DEVELOPMENT
orRuntimeConfigurationType.DEPLOYMENT
.The configuration type. Must currently be either DEVELOPMENT or DEPLOYMENT. Currently, if the configuration type is DEVELOPMENT, resources are polled for changes, component usage is checked, wicket tags are not stripped from output and a detailed exception page is used. If the type is DEPLOYMENT, component usage is not checked, wicket tags are stripped from output and a non-detailed exception page is used to display errors.
Note that you should not run Wicket in DEVELOPMENT mode on production servers - the various debugging checks and resource polling is inefficient and may leak resources, particularly on webapp redeploy.
To change the deployment mode, add the following to your web.xml, inside your
mapping (or mapping if you're using 1.3.x): <init-param> <param-name>configuration</param-name> <param-value>deployment</param-value> </init-param>
You can alternatively set this as a <context-param> on the whole context.
Another option is to set the "wicket.configuration" system property to either "deployment" or "development". The value is not case-sensitive.
The system property is checked first, allowing you to add a web.xml param for deployment, and a command-line override when you want to run in development mode during development.
You may also override Application.getConfigurationType() to provide your own custom switch, in which case none of the above logic is used.
IMPORTANT NOTE
THIS METHOD IS CALLED OFTEN FROM MANY DIFFERENT POINTS IN CODE, INCLUDING DURING THE RENDER PROCESS, THEREFORE THE IMPLEMENTATION SHOULD BE FAST - PREFERRABLY USING A FAST-TO-RETRIEVE CACHED VALUE- Overrides:
getConfigurationType
in classWebApplication
- Returns:
- configuration
-
getSession
public Session getSession()
- Returns:
- the session
-
getInitParameter
public final String getInitParameter(String key)
Description copied from class:WebApplication
Gets an init parameter of the filter, or null if the parameter does not exist.- Overrides:
getInitParameter
in classWebApplication
- Parameters:
key
- the key to search for- Returns:
- the value of the filter init parameter
-
internalInit
protected void internalInit()
Description copied from class:WebApplication
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. Internal initialization. First determine the deployment mode. First check the system property -Dwicket.configuration. If it does not exist check the servlet init parameter (<init-param><param-name>configuration</param-name>
). If not found check the servlet context init parameter<context-param><param-name6gt;configuration</param-name>
). If the parameter is "development" (which is default), settings appropriate for development are set. If it's "deployment" , deployment settings are used. If development is specified and a "sourceFolder" init parameter is also set, then resources in that folder will be polled for changes.- Overrides:
internalInit
in classWebApplication
-
-