1 16 package org.apache.commons.jelly.tags.junit; 17 18 import java.net.URL ; 19 20 import junit.framework.TestSuite; 21 22 import org.apache.commons.jelly.JellyContext; 23 import org.apache.commons.jelly.XMLOutput; 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 33 public abstract class JellyTestSuite { 34 35 36 private static final Log log = LogFactory.getLog(JellyTestSuite.class); 37 38 39 53 public static TestSuite createTestSuite(Class testClass, String script) throws Exception { 54 URL url = testClass.getResource(script); 55 if ( url == null ) { 56 throw new Exception ( 57 "Could not find Jelly script: " + script 58 + " in package of class: " + testClass.getName() 59 ); 60 } 61 return createTestSuite( url ); 62 } 63 64 70 public static TestSuite createTestSuite(URL script) throws Exception { 71 JellyContext context = new JellyContext(script); 72 XMLOutput output = XMLOutput.createXMLOutput(System.out); 73 context = context.runScript(script, output); 74 TestSuite answer = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite"); 75 if ( answer == null ) { 76 log.warn( "Could not find a TestSuite created by Jelly for the script:" + script ); 77 return new TestSuite(); 79 } 80 return answer; 81 } 82 } 83 | Popular Tags |