1 15 package org.apache.tapestry.junit; 16 17 import org.apache.tapestry.BaseComponent; 18 import org.apache.tapestry.IMarkupWriter; 19 import org.apache.tapestry.IRender; 20 import org.apache.tapestry.IRequestCycle; 21 import org.apache.tapestry.engine.NullWriter; 22 import org.apache.tapestry.test.Creator; 23 24 31 32 public class TestComponent extends TapestryTestCase 33 { 34 private static class TestRender implements IRender 35 { 36 private boolean rendered = false; 37 38 public void render(IMarkupWriter writer, IRequestCycle cycle) 39 { 40 rendered = true; 41 } 42 43 } 44 45 public abstract static class FakeComponent extends BaseComponent 46 { 47 void addOuterTest(IRender render) 48 { 49 addOuter(render); 50 } 51 52 void testRenderComponent(IMarkupWriter write, IRequestCycle cycle) 53 { 54 renderComponent(write, cycle); 55 } 56 } 57 58 62 63 public void testOuter() throws Exception 64 { 65 Creator creator = new Creator(); 66 67 FakeComponent c = (FakeComponent) creator.newInstance(FakeComponent.class); 68 69 TestRender[] list = new TestRender[50]; 70 71 for (int i = 0; i < list.length; i++) 72 { 73 list[i] = new TestRender(); 74 c.addOuterTest(list[i]); 75 } 76 77 IMarkupWriter writer = new NullWriter(); 78 79 c.testRenderComponent(writer, null); 80 81 for (int i = 0; i < list.length; i++) 82 assertTrue("Outer object #" + i + " did render.", list[i].rendered); 83 } 84 } | Popular Tags |