1 46 package org.codehaus.groovy.wiki; 47 48 import junit.framework.TestCase; 49 50 import org.radeox.engine.context.BaseRenderContext; 51 52 56 public class TestCaseRenderEngineTest extends TestCase { 57 58 private BaseRenderContext context = new BaseRenderContext(); 59 60 public void testRender() { 61 assertRender( 62 "blah blah {code:groovy}x = 1; assert x == 1{code} whatnot", 63 "package wiki\nclass someFileTest extends GroovyTestCase {\n\n/*\nblah blah */ \n\n void testCase1() {\nx = 1; assert x == 1\n}\n\n /* whatnot\n*/\n\nvoid testDummy() {\n// this is a dummy test case\n}\n\n}\n"); 64 } 65 66 public void testRenderWithScript() { 67 assertRender( 68 "blah blah {code:groovysh}x = 1; println 'hello ${x}'{code} whatnot", 69 "package wiki\nclass someFileTest extends GroovyTestCase {\n\n/*\nblah blah */ \n\n void testScript1() {\n assertScript( <<<SCRIPT_EOF1\nx = 1; println 'hello \\${x}'\nSCRIPT_EOF1 )\n} \n\n /* whatnot\n*/\n\nvoid testDummy() {\n// this is a dummy test case\n}\n\n}\n"); 70 } 71 72 protected void assertRender(String input, String expected) { 73 TestCaseRenderEngine test = new TestCaseRenderEngine(); 74 context.set("name", "someFile.wiki"); 75 String answer = test.render(input, context); 76 77 System.out.println("Converted: " + input); 78 System.out.println("Into: " + answer); 79 80 System.out.println(answer.replaceAll("\n", "\\\\n")); 82 83 assertEquals("Rendering", expected, answer); 84 } 85 86 } 87 | Popular Tags |