1 15 package org.apache.tapestry.describe; 16 17 import org.apache.tapestry.IMarkupWriter; 18 import org.apache.tapestry.IRender; 19 import org.apache.tapestry.IRequestCycle; 20 21 29 public class TestRenderStrategy extends BaseDescribeTestCase 30 { 31 private RenderStrategy newStrategy() 32 { 33 return (RenderStrategy) newMock(RenderStrategy.class); 34 } 35 36 public void testRenderBridge() 37 { 38 IMarkupWriter writer = newWriter(); 39 RenderStrategy strategy = newStrategy(); 40 IRequestCycle cycle = newCycle(); 41 42 Object object = new Object (); 43 44 strategy.renderObject(object, writer, cycle); 45 46 replayControls(); 47 48 new RenderBridge(object, strategy).render(writer, cycle); 49 50 verifyControls(); 51 } 52 53 public void testRenderableAdapterFactory() 54 { 55 IMarkupWriter writer = newWriter(); 56 RenderStrategy strategy = newStrategy(); 57 IRequestCycle cycle = newCycle(); 58 59 Object object = new Object (); 60 61 strategy.renderObject(object, writer, cycle); 62 63 replayControls(); 64 65 RenderableAdapterFactoryImpl factory = new RenderableAdapterFactoryImpl(); 66 factory.setStrategy(strategy); 67 68 IRender renderable = factory.getRenderableAdaptor(object); 69 70 renderable.render(writer, cycle); 71 72 verifyControls(); 73 } 74 75 public void testDefaultRenderableAdapter() 76 { 77 IMarkupWriter writer = newWriter(); 78 HTMLDescriber describer = newDescriber(); 79 IRequestCycle cycle = newCycle(); 80 81 Object object = new Object (); 82 83 describer.describeObject(object, writer); 84 85 replayControls(); 86 87 DefaultRenderStrategy strategy = new DefaultRenderStrategy(); 88 strategy.setDescriber(describer); 89 90 strategy.renderObject(object, writer, cycle); 91 92 verifyControls(); 93 } 94 } | Popular Tags |