From: <wan...@us...> - 2003-07-17 12:53:02
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv30347 Modified Files: TemplateTestCase.java TestDirectiveParser.java TestGetSet.java Log Message: New tests, specifically to catch the new directive parsing bug. Index: TemplateTestCase.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TemplateTestCase.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TemplateTestCase.java 16 Jul 2003 06:45:00 -0000 1.17 --- TemplateTestCase.java 17 Jul 2003 12:52:58 -0000 1.18 *************** *** 167,173 **** /** Asserts that the given template text evalutes to the given result text * when evaluated against the current context */ ! ! public void assertStringTemplateEquals (String templateText, ! String resultText) { String result = null; --- 167,172 ---- /** Asserts that the given template text evalutes to the given result text * when evaluated against the current context */ ! private void assertStringTemplate(String templateText, ! String resultText, boolean equals) { String result = null; *************** *** 190,200 **** return; ! if (!result.equals(resultText)) { System.err.println("Execution of /" + templateText + "/" ! + " yielded /" + result + "/, expecting /" ! + resultText + "/"); assertTrue(false); } } --- 189,218 ---- return; ! if (result.equals(resultText) != equals) { System.err.println("Execution of /" + templateText + "/" ! + " yielded /" + result + "/, " + (equals ? "" : " not ")+ ! "expecting /" + resultText + "/"); assertTrue(false); } + } + + + /** Asserts that the given template text evalutes to the given result text + * when evaluated against the current context */ + + public void assertStringTemplateEquals (String templateText, + String resultText) + { + assertStringTemplate( templateText, resultText, true); + } + + /** Asserts that the given template text evalutes to the given result text + * when evaluated against the current context */ + + public void assertStringTemplateNotEquals (String templateText, + String resultText) + { + assertStringTemplate( templateText, resultText, false); } Index: TestDirectiveParser.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestDirectiveParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestDirectiveParser.java 12 Jun 2003 00:47:50 -0000 1.6 --- TestDirectiveParser.java 17 Jul 2003 12:52:58 -0000 1.7 *************** *** 71,74 **** --- 71,80 ---- } + public void testQuotedDirective () throws Exception + { + assertStringTemplateEquals( "#if (true) ok #end", "ok"); + assertStringTemplateEquals( "x#if (true) ok #end", "xok" ); + } + public static class DirectiveOne extends BaseDirective Index: TestGetSet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestGetSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestGetSet.java 12 Jun 2003 00:47:50 -0000 1.5 --- TestGetSet.java 17 Jul 2003 12:52:58 -0000 1.6 *************** *** 2,5 **** --- 2,6 ---- import org.webmacro.Context; + import org.webmacro.PropertyException; import org.webmacro.engine.DefaultEvaluationExceptionHandler; *************** *** 200,203 **** --- 201,211 ---- String tmpl = "$TestObject.getArray().length"; assertStringTemplateEquals(tmpl, "2"); + } + + /** Make sure we are not evaluating stuff that doesn't exist */ + public void testNonExistentProperties () throws Exception + { + String tmpl = "$TestObject.Int.Int.Int.Int"; + assertStringTemplateThrows( tmpl, PropertyException.class ); } } |