1 5 package com.opensymphony.workflow.util.beanshell; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 import com.opensymphony.module.propertyset.database.JDBCPropertySet; 9 10 import com.opensymphony.workflow.AbstractWorkflow; 11 import com.opensymphony.workflow.Workflow; 12 import com.opensymphony.workflow.basic.BasicWorkflow; 13 import com.opensymphony.workflow.config.Configuration; 14 import com.opensymphony.workflow.config.DefaultConfiguration; 15 16 import junit.framework.TestCase; 17 18 import org.apache.commons.lang.exception.ExceptionUtils; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 24 31 public class BeanShellFunctionProviderTestCase extends TestCase { 32 34 public BeanShellFunctionProviderTestCase(String s) { 35 super(s); 36 } 37 38 40 63 public void testThrowingException() throws Exception { 64 Configuration config = new DefaultConfiguration(); 65 config.load(getClass().getResource("/osworkflow-jdbc.xml")); 66 67 Workflow workflow = new BasicWorkflow("test"); 68 workflow.setConfiguration(config); 69 70 BeanShellFunctionProvider function = new BeanShellFunctionProvider(); 72 PropertySet ps = new JDBCPropertySet(); 73 Map transientVars = new HashMap (); 74 Map args = new HashMap (); 75 args.put(AbstractWorkflow.BSH_SCRIPT, "String caller = \"testcaller\"; propertySet.setString(\"caller\", caller);"); 76 77 try { 78 function.execute(transientVars, args, ps); 79 } catch (Exception e) { 80 String fullStackTrace = ExceptionUtils.getFullStackTrace(e); 81 assertTrue("Make sure our stack trace records the error in JDBC:" + fullStackTrace, fullStackTrace.indexOf("at com.opensymphony.module.propertyset.database.JDBCPropertySet.setImpl") > -1); 82 } 83 } 84 } 85 | Popular Tags |