1 15 package org.apache.tapestry.html; 16 17 import java.io.IOException ; 18 19 import org.apache.hivemind.ApplicationRuntimeException; 20 import org.apache.tapestry.IMarkupWriter; 21 import org.apache.tapestry.IRequestCycle; 22 import org.apache.tapestry.components.BaseComponentTestCase; 23 import org.easymock.MockControl; 24 25 31 public class TestInsertText extends BaseComponentTestCase 32 { 33 public void testRewinding() 34 { 35 IMarkupWriter writer = newWriter(); 36 IRequestCycle cycle = newCycle(true); 37 38 replayControls(); 39 40 InsertText component = (InsertText) newInstance(InsertText.class); 41 42 component.render(writer, cycle); 43 44 verifyControls(); 45 } 46 47 public void testRenderNull() 48 { 49 IMarkupWriter writer = newWriter(); 50 IRequestCycle cycle = newCycle(false); 51 52 replayControls(); 53 54 InsertText component = (InsertText) newInstance(InsertText.class); 55 56 component.render(writer, cycle); 57 58 verifyControls(); 59 } 60 61 public void testRenderBreaks() 62 { 63 IMarkupWriter writer = newWriter(); 64 IRequestCycle cycle = newCycle(false); 65 66 writer.print("Now is the time", false); 67 writer.beginEmpty("br"); 68 writer.print("for all good men", false); 69 writer.beginEmpty("br"); 70 writer.print("to come to the aid of their Tapestry.", false); 71 72 replayControls(); 73 74 InsertText component = (InsertText) newInstance( 75 InsertText.class, 76 "value", 77 "Now is the time\nfor all good men\nto come to the aid of their Tapestry."); 78 79 component.finishLoad(cycle, null, null); 80 component.render(writer, cycle); 81 82 verifyControls(); 83 } 84 85 public void testRenderParas() 86 { 87 IMarkupWriter writer = newWriter(); 88 IRequestCycle cycle = newCycle(false); 89 90 writer.begin("p"); 91 writer.print("Now is the time", false); 92 writer.end(); 93 94 writer.begin("p"); 95 writer.print("for all good men", false); 96 writer.end(); 97 98 writer.begin("p"); 99 writer.print("to come to the aid of their Tapestry.", false); 100 writer.end(); 101 102 replayControls(); 103 104 InsertText component = (InsertText) newInstance(InsertText.class, new Object [] 105 { "mode", InsertTextMode.PARAGRAPH, "value", 106 "Now is the time\nfor all good men\nto come to the aid of their Tapestry." }); 107 108 component.render(writer, cycle); 109 110 verifyControls(); 111 } 112 113 public void testRenderRaw() 114 { 115 IMarkupWriter writer = newWriter(); 116 IRequestCycle cycle = newCycle(false); 117 118 writer.print("output", true); 119 writer.beginEmpty("br"); 120 writer.print("<b>raw</b>", true); 121 122 replayControls(); 123 124 InsertText component = (InsertText) newInstance(InsertText.class, new Object [] 125 { "value", "output\n<b>raw</b>", "raw", Boolean.TRUE }); 126 127 component.finishLoad(cycle, null, null); 128 component.render(writer, cycle); 129 130 verifyControls(); 131 } 132 } 133 | Popular Tags |