/** * Add an int header value. * * @param name * The header name * @param i * The value */ public void addIntHeader(final String name, final int i) { addHeader(name, "" + i); }
/** * Set a date header. * * @param name * The header name * @param l * The long value */ public void setDateHeader(final String name, final long l) { setHeader(name, formatDate(l)); }
/** * Dumps the source of last rendered <code>Page</code>. */ public void dumpPage() { log.info(getServletResponse().getDocument()); }
/** * Asserts that the Ajax location header is present. */ public void assertAjaxLocation() { if (null != ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getRedirectLocation()) { throw new AssertionFailedError( "Location header should *not* be present when using Ajax"); } String ajaxLocation = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Ajax-Location"); if (null == ajaxLocation) { throw new AssertionFailedError("Ajax-Location header should be present when using Ajax"); } int statusCode = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getStatus(); if (statusCode != 200) { throw new AssertionFailedError("Expected HTTP status code to be 200 (OK)"); } }
.getHttpServletResponse(); if (httpResponse.isRedirect()) String redirectLocation = httpResponse.getRedirectLocation(); cycle = setupRequestAndResponse(false); servletRequest.setRequestToRedirectString(redirectLocation); String url = httpResponse.getHeader("Ajax-Location"); if (url != null)
/** * @return value of content-type header */ public String getContentType() { return getHeader("Content-Type"); }
.getHttpServletResponse(); if (httpResponse.isRedirect()) newHttpRequest.setRequestToRedirectString(httpResponse.getRedirectLocation()); wicketRequest = application.newWebRequest(newHttpRequest);
/** * Create the response object. * * @param servletRequest */ public MockHttpServletResponse(MockHttpServletRequest servletRequest) { this.servletRequest = servletRequest; initialize(); }
/** * @param l * @return formatted date */ public static String formatDate(long l) { StringBuffer _dateBuffer = new StringBuffer(32); Calendar _calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); _calendar.setTimeInMillis(l); formatDate(_dateBuffer, _calendar, false); return _dateBuffer.toString(); }
/** * Indicate sending of a redirectLocation to a particular named resource. This implementation * just keeps hold of the redirectLocation info and makes it available for query. * * @param location * The location to redirectLocation to * @throws IOException * Not used */ public void sendRedirect(String location) throws IOException { // If the location starts with ../ if (location.startsWith("../")) { // Test if the current url has a / in it. (a mount) String url = getURL(); int index = url.lastIndexOf("/"); if (index != -1) { // Then we have to recalculate what the real redirect is for the next request // which is just getContext() + getServletPath() + "/" + location; url = url.substring(0, index + 1) + location; url = RequestUtils.removeDoubleDots(url); // strip the servlet path again from it. index = url.indexOf("/"); location = url.substring(index + 1); } } redirectLocation = location; }
buf.append(','); buf.append(' '); append2digits(buf, day_of_month); buf.append(MONTHS[month]); buf.append('-'); append2digits(buf, year); buf.append(MONTHS[month]); buf.append(' '); append2digits(buf, century); append2digits(buf, year); append2digits(buf, hours); buf.append(':'); append2digits(buf, minutes); buf.append(':'); append2digits(buf, seconds); buf.append(" GMT");
/** * Asserts that the Ajax location header is present. */ public void assertAjaxLocation() { if (null != ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getRedirectLocation()) { throw new AssertionFailedError( "Location header should *not* be present when using Ajax"); } String ajaxLocation = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Ajax-Location"); if (null == ajaxLocation) { throw new AssertionFailedError("Ajax-Location header should be present when using Ajax"); } int statusCode = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getStatus(); if (statusCode != 200) { throw new AssertionFailedError("Expected HTTP status code to be 200 (OK)"); } }
public String getContentType() { return getHeader("Content-Type"); }
/** * Delegate to initialize method. */ public void reset() { initialize(); }
/** * @param l * @return */ public static String formatDate(long l) { StringBuffer _dateBuffer = new StringBuffer(32); Calendar _calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); _calendar.setTimeInMillis(l); formatDate(_dateBuffer, _calendar, false); return _dateBuffer.toString(); }
/** * Indicate sending of a redirectLocation to a particular named resource. This implementation * just keeps hold of the redirectLocation info and makes it available for query. * * @param location * The location to redirectLocation to * @throws IOException * Not used */ public void sendRedirect(String location) throws IOException { // If the location starts with ../ if (location.startsWith("../")) { // Test if the current url has a / in it. (a mount) String url = getURL(); int index = url.lastIndexOf("/"); if (index != -1) { // Then we have to recalculate what the real redirect is for the next request // which is just getContext() + getServletPath() + "/" + location; url = url.substring(0, index + 1) + location; url = RequestUtils.removeDoubleDots(url); // stril the servlet path again from it. index = url.indexOf("/"); location = url.substring(index + 1); } } redirectLocation = location; }
buf.append(','); buf.append(' '); append2digits(buf, day_of_month); buf.append(MONTHS[month]); buf.append('-'); append2digits(buf, year); buf.append(MONTHS[month]); buf.append(' '); append2digits(buf, century); append2digits(buf, year); append2digits(buf, hours); buf.append(':'); append2digits(buf, minutes); buf.append(':'); append2digits(buf, seconds); buf.append(" GMT");
/** * Dumps the source of last rendered <code>Page</code>. */ public void dumpPage() { log.info(getServletResponse().getDocument()); }
/** * Retrieves the content disposition from the response header. * * @return the content disposition from the response header */ public String getContentDispositionFromResponseHeader() { return ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse()).getHeader("Content-Disposition"); }
/** * Set a date header. * * @param name * The header name * @param l * The long value */ public void setDateHeader(final String name, final long l) { setHeader(name, formatDate(l)); }