1 25 26 package examples; 27 28 import junit.framework.Test; 29 import junit.framework.TestCase; 30 import junit.framework.TestSuite; 31 import org.radeox.macro.Macro; 32 import org.radeox.api.engine.context.RenderContext; 33 import org.snipsnap.render.context.SnipRenderContext; 34 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 35 import org.snipsnap.snip.Snip; 36 import org.snipsnap.snip.SnipImpl; 37 import org.snipsnap.snip.SnipSpace; 38 import org.snipsnap.test.mock.MockSnipSpace; 39 40 import java.io.IOException ; 41 import java.io.StringWriter ; 42 43 49 50 public class HelloSnipMacroExample extends TestCase { 51 52 public HelloSnipMacroExample(String name) { 53 super(name); 54 } 55 56 protected void setUp() throws Exception { 57 super.setUp(); 58 } 59 60 public static Test suite() { 61 return new TestSuite(HelloSnipMacroExample.class); 62 } 63 64 public void testHelloSnipMacro() { 65 SnipSpace space = new MockSnipSpace(); 66 Snip snip = new SnipImpl("HelloSnip","HelloSnip"); 67 68 RenderContext context = new SnipRenderContext(snip, space); 69 SnipMacroParameter parameter = new SnipMacroParameter(context); 70 71 Macro macro = new HelloSnipMacro(); 72 StringWriter writer = new StringWriter (); 73 try { 74 macro.execute(writer, parameter); 75 } catch (IllegalArgumentException e) { 76 e.printStackTrace(); 77 78 } catch (IOException e) { 79 e.printStackTrace(); 80 } 81 assertEquals("HelloSnipMacro renders correct.", "hello", writer.toString()); 82 } 83 } 84
| Popular Tags
|