From: Tim P <ti...@us...> - 2010-02-19 01:12:53
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7444/test/unit/org/webmacro/template Modified Files: TestSetpropsDirective.java Log Message: Test allowing a package Index: TestSetpropsDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestSetpropsDirective.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestSetpropsDirective.java 18 Feb 2010 23:29:48 -0000 1.5 --- TestSetpropsDirective.java 19 Feb 2010 00:21:30 -0000 1.6 *************** *** 1,5 **** --- 1,9 ---- package org.webmacro.template; + import java.util.Properties; + + import org.webmacro.Broker; import org.webmacro.Context; + import org.webmacro.WM; import org.webmacro.WebMacroException; import org.webmacro.engine.CrankyEvaluationExceptionHandler; *************** *** 20,27 **** { //System.getProperties().setProperty("org.webmacro.LogLevel", "DEBUG"); - //System.getProperties().setProperty("org.webmacro.ImpliedPackages", - //"java.util"); - //System.getProperties().setProperty("org.webmacro.AllowedPackages", - //"java.util"); super.setUp(); } --- 24,27 ---- *************** *** 67,70 **** --- 67,91 ---- /** + * Tests the "class" option with the AllowedPackages configuration + * option which restricts the classes that can be loaded. + */ + public void testSetpropsAllowedPackage() throws Exception + { + System.getProperties().setProperty("org.webmacro.AllowedPackages", "org.webmacro"); + // overwrite the wm created in setup + _wm = null; + _context = null; + System.err.println("IN"); + + _wm = new WM(Broker.getBroker(new Properties())); + _context = _wm.getContext(); + String tmpl = "#setprops $WM class=\"org.webmacro.WM\""; + tmpl += "\n{\n"; + tmpl += "}\n"; + tmpl += "$WM"; + assertStringTemplateEquals(tmpl, "WebMacro(WebMacro.properties)"); + } + + /** * This version uses the line continuation character. Notice that it needs to * be double escaped here (\\\\). In a template file it should be be escaped *************** *** 114,118 **** } ! public void testSetpropsThrowsOnNotFoundClass() throws Exception { String tmpl = "#setprops $e class=\"org.melati.Melati\""; --- 135,139 ---- } ! public void testSetpropsThrowsOnClassNotFound() throws Exception { String tmpl = "#setprops $e class=\"org.melati.Melati\""; *************** *** 132,149 **** } - /** - * Tests the "class" option with the AllowedPackages configuration - * option which restricts the classes that can be loaded. - */ - public void testSetpropsAllowedPackage() throws Exception - { - String tmpl = "#setprops $WM class=\"org.webmacro.WM\""; - tmpl += "\n{\n"; - tmpl += "}\n"; - tmpl += "$WM"; - System.err.println(_wm.getBroker()); - assertStringTemplateThrows(tmpl, WebMacroException.class); - } - public class User { --- 153,156 ---- |