1 20 package org.apache.cactus.sample.servlet; 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 44 private BodyContent tagContent; 45 46 50 public void setUp() 51 { 52 this.tag = new SampleBodyTag(); 53 this.tag.setPageContext(this.pageContext); 54 55 this.tagContent = this.pageContext.pushBody(); 57 this.tag.setBodyContent(this.tagContent); 58 } 59 60 63 public void tearDown() 64 { 65 this.pageContext.popBody(); 67 } 68 69 71 77 public void testReplacement() throws Exception 78 { 79 this.tag.setTarget("@target@"); 81 this.tag.setReplacement("replacement"); 82 83 this.tagContent.println("@target@ is now @target@"); 86 this.tagContent.println("@target@_@target@"); 87 88 int result = this.tag.doAfterBody(); 91 92 assertEquals(BodyTag.SKIP_BODY, result); 93 } 94 95 101 public void endReplacement(WebResponse theResponse) 102 { 103 String content = theResponse.getText(); 104 105 assertTrue("Response should have contained the [" 106 + "replacement is now replacement] string", 107 content.indexOf("replacement is now replacement") > -1); 108 assertTrue("Response should have contained the [" 109 + "replacement_replacement] string", 110 content.indexOf("replacement") > -1); 111 } 112 } 113 | Popular Tags |