1 18 package org.apache.struts.taglib; 19 20 import junit.framework.Assert; 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 24 import org.apache.cactus.JspTestCase; 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.oro.text.perl.Perl5Util; 28 29 public class TaglibTestBase extends JspTestCase{ 30 31 private static Log log = LogFactory.getLog(TaglibTestBase.class); 32 33 private Perl5Util perl = new Perl5Util(); 34 35 public TaglibTestBase(String arg0) { 36 super(arg0); 37 } 38 public static Test suite() { 40 return (new TestSuite(TaglibTestBase.class)); 41 } 42 43 protected void runTest(String whichTest, String jsp) throws Exception { 44 request.setAttribute("runTest", whichTest); 45 pageContext.forward(jsp); 46 } 47 48 protected String replace(String source, String find, String replace){ 49 50 return perl.substitute("s/" + find + "/" + replace + "/", source); 51 52 } 53 54 59 public static void assertResults(String expected, String compareTo){ 60 Perl5Util perl = new Perl5Util(); 61 expected = perl.substitute("s/[\\r\\n]//gmx", expected); 62 compareTo = perl.substitute("s/[\\r\\n]//gmx", compareTo); 63 Assert.assertEquals(expected, compareTo); 64 } 65 66 public static void fail(String msg){ 67 Assert.fail(msg); 68 } 69 70 } 71 | Popular Tags |