1 20 package org.apache.maven.cactus.sample; 21 22 import javax.servlet.jsp.tagext.BodyContent ; 23 import javax.servlet.jsp.tagext.BodyTag ; 24 25 import org.apache.cactus.JspTestCase; 26 import org.apache.cactus.WebResponse; 27 28 33 public class TestSampleBodyTag extends JspTestCase 34 { 35 38 private SampleBodyTag tag; 39 40 43 private BodyContent tagContent; 44 45 49 public void setUp() 50 { 51 this.tag = new SampleBodyTag(); 52 this.tag.setPageContext(this.pageContext); 53 54 this.tagContent = this.pageContext.pushBody(); 56 this.tag.setBodyContent(this.tagContent); 57 } 58 59 61 67 public void testReplacement() throws Exception 68 { 69 this.tag.setTarget("@target@"); 71 this.tag.setReplacement("replacement"); 72 73 this.tagContent.println("@target@ is now @target@"); 76 this.tagContent.println("@target@_@target@"); 77 78 int result = this.tag.doAfterBody(); 81 82 assertEquals(BodyTag.SKIP_BODY, result); 83 } 84 85 88 public void tearDown() 89 { 90 this.pageContext.popBody(); 92 } 93 94 100 public void endReplacement(WebResponse theResponse) 101 { 102 String content = theResponse.getText(); 103 104 assertTrue("Response should have contained the [" 105 + "replacement is now replacement] string", 106 content.indexOf("replacement is now replacement") > -1); 107 assertTrue("Response should have contained the [" 108 + "replacement_replacement] string", 109 content.indexOf("replacement") > -1); 110 } 111 } | Popular Tags |