@Test public void testWriteTagContentTagWriter01() { TransactionTokenTag tag = new TransactionTokenTag(); PageContext pageContext = mock(PageContext.class); tag.setPageContext(pageContext); HttpServletRequest request = mock(HttpServletRequest.class); StringWriter sw = new StringWriter(); TagWriter tagWriter = new TagWriter(sw); when((HttpServletRequest) pageContext.getRequest()).thenReturn(request); when((TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME)) .thenReturn(null); int result = 1; try { result = tag.writeTagContent(tagWriter); } catch (JspException e) { fail(); } assertThat(sw.getBuffer().toString(), is("")); assertThat(result, is(0)); }
@Override protected int writeTagContent( final TagWriter tagWriter) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext .getRequest(); TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); tagWriter.writeAttribute("name", TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER); tagWriter.writeAttribute("value", nextToken.getTokenString()); tagWriter.endTag(); } return SKIP_BODY; }
TransactionTokenTag extends AbstractHtmlElementTag { @Override protected int writeTagContent( final TagWriter tagWriter) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext .getRequest(); TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); tagWriter.writeAttribute("name", TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER); tagWriter.writeAttribute("value", nextToken.getTokenString()); tagWriter.endTag(); } return SKIP_BODY; } }
TransactionTokenTag extends AbstractHtmlElementTag { @Override protected int writeTagContent( final TagWriter tagWriter) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext .getRequest(); TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); tagWriter.writeAttribute("name", TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER); tagWriter.writeAttribute("value", nextToken.getTokenString()); tagWriter.endTag(); } return SKIP_BODY; }  }
TransactionTokenTag extends AbstractHtmlElementTag { @Override protected int writeTagContent( final TagWriter tagWriter) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext .getRequest(); TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); tagWriter.writeAttribute("name", TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER); tagWriter.writeAttribute("value", nextToken.getTokenString()); tagWriter.endTag(); } return SKIP_BODY; }   }
TransactionTokenTag extends AbstractHtmlElementTag { @Override protected int writeTagContent( final TagWriter tagWriter) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext .getRequest(); TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); tagWriter.writeAttribute("name", TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER); tagWriter.writeAttribute("value", nextToken.getTokenString()); tagWriter.endTag(); } return SKIP_BODY; }    }