RedirectionActionHelper { public static String buildFormPostContent(final WebContext context) { final String requestedUrl = context.getFullRequestURL(); final Map<String, String[]> parameters = context.getRequestParameters(); final StringBuilder buffer = new StringBuilder(); buffer.append("<html>\n"); buffer.append("<body>\n"); buffer.append("<form action=\"" + escapeHtml(requestedUrl) + "\" name=\"f\" method=\"post\">\n"); if (parameters != null) { for (final Map.Entry<String, String[]> entry : parameters.entrySet()) { final String[] values = entry.getValue(); if (values != null && values.length > 0) { buffer.append("<input type='hidden' name=\"" + escapeHtml(entry.getKey()) + "\" value=\"" + values[0] + "\" />\n"); } } } buffer.append("<input value='POST' type='submit' />\n"); buffer.append("</form>\n"); buffer.append("<script type='text/javascript'>document.forms['f'].submit();</script>\n"); buffer.append("</body>\n"); buffer.append("</html>\n"); return buffer.toString(); }  static RedirectionAction buildRedirectUrlAction(final WebContext context, final String location); static RedirectionAction buildFormPostContentAction(final WebContext context, final String content); static String buildFormPostContent(final WebContext context); static boolean isUseModernHttpCodes(); static void setUseModernHttpCodes(final boolean useModernHttpCodes);  }
@Test public void testBuildFormPostContent() { final String content = RedirectionActionHelper.buildFormPostContent(MockWebContext.create().setFullRequestURL(CALLBACK_URL)); assertEquals("<html>\n<body>\n<form action=\"" + CALLBACK_URL + "\" name=\"f\" method=\"post\">\n" + "<input value='POST' type='submit' />\n</form>\n" + "<script type='text/javascript'>document.forms['f'].submit();</script>\n" + "</body>\n</html>\n", content); }
@Test public void testBuildFormPostContentWithData() { final String content = RedirectionActionHelper .buildFormPostContent(MockWebContext.create().setFullRequestURL(CALLBACK_URL).addRequestParameter(NAME, VALUE)); assertEquals("<html>\n<body>\n<form action=\"" + CALLBACK_URL + "\" name=\"f\" method=\"post\">\n" + "<input type='hidden' name=\"" + NAME + "\" value=\"" + VALUE + "\" />\n" + "<input value='POST' type='submit' />\n</form>\n" + "<script type='text/javascript'>document.forms['f'].submit();</script>\n" + "</body>\n</html>\n", content); }