1 37 package net.sourceforge.cruisecontrol.taglib; 38 39 import javax.servlet.jsp.JspException ; 40 import javax.servlet.jsp.tagext.Tag ; 41 42 import junit.framework.TestCase; 43 import net.sourceforge.cruisecontrol.mock.MockPageContext; 44 import net.sourceforge.cruisecontrol.mock.MockServletRequest; 45 46 50 public class LinkTagTest extends TestCase { 51 public LinkTagTest(String name) { 52 super(name); 53 } 54 55 public void testCreateLink() throws JspException { 56 LinkTag tag = new LinkTag(); 57 MockPageContext pageContext = new MockPageContext(); 58 pageContext.setHttpServletRequest(new MockServletRequest("context", "servlet")); 59 tag.setPageContext(pageContext); 60 tag.setId("link"); 61 assertEquals(Tag.SKIP_BODY, tag.doStartTag()); 62 assertEquals(Tag.EVAL_PAGE, tag.doEndTag()); 63 64 assertEquals("/context/servlet", pageContext.getAttribute("link")); 65 } 66 67 public void testCreateLinkExcludeLog() throws JspException { 68 LinkTag tag = new LinkTag(); 69 MockPageContext pageContext = new MockPageContext(); 70 final MockServletRequest mockRequest = new MockServletRequest("context", "servlet"); 71 pageContext.setHttpServletRequest(mockRequest); 72 mockRequest.addParameter("log", "logFile"); 73 mockRequest.addParameter("other", "value"); 74 tag.setPageContext(pageContext); 75 tag.setId("link"); 76 assertEquals(Tag.SKIP_BODY, tag.doStartTag()); 77 assertEquals(Tag.EVAL_PAGE, tag.doEndTag()); 78 79 assertEquals("/context/servlet?other=value", pageContext.getAttribute("link")); 80 81 } 82 } 83 | Popular Tags |