/** * Creates a <code>WicketTester</code>. * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param servletContextBasePath * the absolute path on disk to the web application's contents (e.g. war root) - may * be <code>null</code> */ public BaseWicketTester(final WebApplication application, String servletContextBasePath) { this(application, new MockServletContext(application, servletContextBasePath)); }
@Override public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() { return getDefaultSessionTrackingModes(); }
/** * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value. * * @param name * The name of the servlet or JSP * @return The dispatcher */ @Override public RequestDispatcher getNamedDispatcher(final String name) { return getRequestDispatcher(name); }
@Override public ServletRegistration.Dynamic addServlet(String servletName, String className) { try { return addServlet(servletName, Class.forName(className).asSubclass(Servlet.class)); } catch (ClassNotFoundException e) { throw new WicketRuntimeException(e); } }
@Override public ServletRegistration.Dynamic addServlet(String servletName, String className) { try { return addServlet(servletName, Class.forName(className).asSubclass(Servlet.class)); } catch (ClassNotFoundException e) { throw new WicketRuntimeException(e); } }
/** * Creates a <code>WicketTester</code>. * * @param application * a <code>WicketTester</code> <code>WebApplication</code> object * @param servletContextBasePath * the absolute path on disk to the web application's contents (e.g. war root) - may * be <code>null</code> */ public BaseWicketTester(final WebApplication application, String servletContextBasePath) { this(application, new MockServletContext(application, servletContextBasePath)); }
@Override public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) { try { return addServlet(servletName, servletClass.newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new WicketRuntimeException(e); } }
/** * Wicket does not use the RequestDispatcher, so this implementation just returns a dummy value. * * @param name * The name of the servlet or JSP * @return The dispatcher */ @Override public RequestDispatcher getNamedDispatcher(final String name) { return getRequestDispatcher(name); }
@Override public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() { return getDefaultSessionTrackingModes(); }
private void initApplication() { if (application instanceof WebApplication) { WebApplication webApplication = (WebApplication)application; // WebApplication requires a servlet context webApplication.setServletContext(new MockServletContext(application, null)); } application.setName("ComponentRenderer[" + System.identityHashCode(ComponentRenderer.this) + "]"); application.initApplication(); }
@Override public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) { try { return addServlet(servletName, servletClass.getDeclaredConstructor().newInstance()); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new WicketRuntimeException(e); } }
public static WicketFilter newMockFilter(final WebApplication application) { final MockServletContext context = new MockServletContext(application, "/"); final WicketFilter filter = new WicketFilter() { @Override
private void initApplication() { if (application instanceof WebApplication) { WebApplication webApplication = (WebApplication)application; // WebApplication requires a servlet context webApplication.setServletContext(new MockServletContext(application, null)); } application.setName("ComponentRenderer[" + System.identityHashCode(ComponentRenderer.this) + "]"); application.initApplication(); }
/** * Invoke this method in the new thread before doing something with Wicket. */ public void mock() { ThreadContext.setApplication(application); ThreadContext.setSession(session); final MockServletContext context = new MockServletContext(application, SystemUtils.JAVA_IO_TMPDIR); ThreadContext.setRequestCycle( application.createRequestCycle(new MockWebRequest( Url.parse("http://localhost/mock")) { @Override public Object getContainerRequest() { return new MockHttpServletRequest( application, new MockHttpSession(context), context); } }, new MockWebResponse()) ); } }
: new MockServletContext(application, null);
: new MockServletContext(application, null);