@Test public void testWriteTagContentTagWriter03() { TransactionTokenTag tag = new TransactionTokenTag(); PageContext pageContext = mock(PageContext.class); tag.setPageContext(pageContext); HttpServletRequest request = mock(HttpServletRequest.class); TransactionToken token = new TransactionToken("tokenName", "tokenkey", "tokenValue"); TagWriter tagWriter = mock(TagWriter.class); when((HttpServletRequest) pageContext.getRequest()).thenReturn(request); when((TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME)) .thenReturn(token); int result = 1; try { doThrow(new JspException()).when(tagWriter).startTag(anyString()); result = tag.writeTagContent(tagWriter); } catch (JspException e) { e.printStackTrace(); } assertThat(result, is(1)); }
@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; }    }