org.apache.wicket.mock
Class MockApplication

java.lang.Object
  extended by org.apache.wicket.Application
      extended by org.apache.wicket.protocol.http.WebApplication
          extended by org.apache.wicket.mock.MockApplication
All Implemented Interfaces:
IEventSink, 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
MockApplication()
          Construct.
 
Method Summary
 RuntimeConfigurationType getConfigurationType()
          Gets the configuration mode to use for configuring the app, either RuntimeConfigurationType.DEVELOPMENT or RuntimeConfigurationType.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, getFilterFactoryManager, getMimeType, getServletContext, getSessionAttributePrefix, getUpdateAutoLabelsOnAjaxRequests, getWicketFilter, hasBufferedResponse, hasFilterFactoryManager, init, internalDestroy, logEventTarget, logResponseTarget, mount, mountPackage, mountPage, mountResource, newAjaxRequestTarget, newSession, newWebRequest, newWebResponse, outputDevelopmentModeWarning, renderXmlDecl, sessionUnbound, setAjaxRequestTargetProvider, setConfigurationType, setServletContext, setWicketFilter, storeBufferedResponse, unmount
 
Methods inherited from class org.apache.wicket.Application
configure, createRequestCycle, decorateHeaderResponse, exists, fetchCreateAndSetSession, get, getApplicationKeys, getApplicationListeners, getApplicationSettings, getBehaviorInstantiationListeners, getComponentInitializationListeners, getComponentInstantiationListeners, getComponentOnAfterRenderListeners, getComponentOnConfigureListeners, getComponentPostOnBeforeRenderListeners, getComponentPreOnBeforeRenderListeners, getConverterLocator, getDebugSettings, getExceptionMapperProvider, getExceptionSettings, getFrameworkSettings, getHeaderContributorListenerCollection, getInitializers, getJavaScriptLibrarySettings, getMapperContext, getMarkupIdGenerator, getMarkupSettings, getMetaData, getName, getPageFactory, getPageManagerContext, getPageManagerProvider, getPageRendererProvider, getPageSettings, getRequestCycleListeners, getRequestCycleProvider, getRequestCycleSettings, getRequestLogger, getRequestLoggerSettings, getResourceBundles, getResourceReferenceRegistry, getResourceSettings, getRootRequestMapper, getRootRequestMapperAsCompound, getSecuritySettings, getSessionListeners, getSessionStore, getSessionStoreProvider, getSharedResources, getStoreSettings, initApplication, initializeComponents, newConverterLocator, newMapperContext, newPageFactory, newRequestLogger, newResourceBundles, newResourceReferenceRegistry, newSharedResources, onDestroy, onEvent, setApplicationSettings, setDebugSettings, setExceptionSettings, setFrameworkSettings, setHeaderResponseDecorator, setJavaScriptLibrarySettings, setMarkupIdGenerator, setMarkupSettings, setMetaData, setName, setPageManagerProvider, setPageRendererProvider, setPageSettings, setRequestCycleProvider, setRequestCycleSettings, setRequestLoggerSettings, setResourceSettings, setRootRequestMapper, setSecuritySettings, setSessionStoreProvider, setStoreSettings, usesDeploymentConfig, usesDevelopmentConfig, validateInit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 class Application
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, either RuntimeConfigurationType.DEVELOPMENT or RuntimeConfigurationType.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 class WebApplication
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 class WebApplication
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 class WebApplication


Copyright © 2006–2017 Apache Software Foundation. All rights reserved.