1 package org.apache.velocity.test; 2 3 18 19 import java.io.FileInputStream ; 20 21 import java.util.Properties ; 22 import java.util.List ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 26 import org.apache.velocity.app.Velocity; 27 28 import junit.framework.TestSuite; 29 30 39 public class TemplateTestSuite extends TestSuite implements TemplateTestBase 40 { 41 private Properties testProperties; 42 43 46 public TemplateTestSuite() 47 { 48 try 49 { 50 Velocity.setProperty( 51 Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); 52 53 Velocity.setProperty(Velocity.RUNTIME_LOG_ERROR_STACKTRACE, "true"); 54 Velocity.setProperty(Velocity.RUNTIME_LOG_WARN_STACKTRACE, "true"); 55 Velocity.setProperty(Velocity.RUNTIME_LOG_INFO_STACKTRACE, "true"); 56 57 Velocity.init(); 58 59 testProperties = new Properties (); 60 testProperties.load(new FileInputStream (TEST_CASE_PROPERTIES)); 61 } 62 catch (Exception e) 63 { 64 System.err.println("Cannot setup TemplateTestSuite!"); 65 e.printStackTrace(); 66 System.exit(1); 67 } 68 69 addTemplateTestCases(); 70 } 71 72 76 private void addTemplateTestCases() 77 { 78 String template; 79 for (int i = 1 ;; i++) 80 { 81 template = testProperties.getProperty(getTemplateTestKey(i)); 82 83 if (template != null) 84 { 85 System.out.println("Adding TemplateTestCase : " + template); 86 addTest(new TemplateTestCase(template)); 87 } 88 else 89 { 90 break; 92 } 93 } 94 } 95 96 103 private static final String getTemplateTestKey(int nbr) 104 { 105 return ("test.template." + nbr); 106 } 107 } 108 | Popular Tags |