01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.spi.jdbc;
06:
07: import com.opensymphony.workflow.config.Configuration;
08: import com.opensymphony.workflow.config.DefaultConfiguration;
09: import com.opensymphony.workflow.spi.AbstractFunctionalWorkflowTest;
10: import com.opensymphony.workflow.util.DatabaseHelper;
11:
12: import java.util.HashMap;
13:
14: /**
15: * This test case is functional in that it attempts to validate the entire
16: * lifecycle of a workflow. This is also a good resource for beginners
17: * to OSWorkflow. This leverages Hibernate as teh
18: *
19: * @author Eric Pugh (epugh@upstate.com)
20: */
21: public class JDBCFunctionalWorkflowTestCase extends
22: AbstractFunctionalWorkflowTest {
23: //~ Constructors ///////////////////////////////////////////////////////////
24:
25: public JDBCFunctionalWorkflowTestCase(String s) {
26: super (s);
27: }
28:
29: //~ Methods ////////////////////////////////////////////////////////////////
30:
31: public void testTrigger() throws Exception {
32: String workflowName = getClass().getResource(
33: "/samples/scheduler.xml").toString();
34: assertTrue("canInitialize for workflow " + workflowName
35: + " is false", workflow.canInitialize(workflowName, 1));
36:
37: long id = workflow.initialize(workflowName, 1, new HashMap());
38: Thread.sleep(500);
39: assertEquals("trigger was not fired", "blahblah", workflow
40: .getPropertySet(id).getString("testTrigger"));
41: }
42:
43: protected void setUp() throws Exception {
44: super .setUp();
45: DatabaseHelper.runScript(getClass().getResource(
46: "/scripts/jdbc/mckoi.sql"), "jdbc/CreateDS");
47:
48: Configuration config = new DefaultConfiguration();
49: config.load(getClass().getResource("/osworkflow-jdbc.xml"));
50: workflow.setConfiguration(config);
51: }
52:
53: protected void tearDown() throws Exception {
54: DatabaseHelper.runScript(getClass().getResource(
55: "/scripts/jdbc/dropschema.sql"), "jdbc/DefaultDS");
56: }
57: }
|