01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.spi.hibernate;
06:
07: import com.opensymphony.workflow.basic.BasicWorkflow;
08: import com.opensymphony.workflow.config.Configuration;
09: import com.opensymphony.workflow.config.DefaultConfiguration;
10: import com.opensymphony.workflow.spi.AbstractFunctionalWorkflowTest;
11: import com.opensymphony.workflow.util.DatabaseHelper;
12:
13: import net.sf.hibernate.SessionFactory;
14:
15: /**
16: * This test case is functional in that it attempts to validate the entire
17: * lifecycle of a workflow. This is also a good resource for beginners
18: * to OSWorkflow. This leverages Hibernate as the persistence mechanism.
19: *
20: * @author Eric Pugh (epugh@upstate.com)
21: */
22: public class HibernateFunctionalWorkflowTestCase extends
23: AbstractFunctionalWorkflowTest {
24: //~ Instance fields ////////////////////////////////////////////////////////
25:
26: private SessionFactory factory;
27:
28: //~ Constructors ///////////////////////////////////////////////////////////
29:
30: public HibernateFunctionalWorkflowTestCase(String s) {
31: super (s);
32: }
33:
34: //~ Methods ////////////////////////////////////////////////////////////////
35:
36: protected void setUp() throws Exception {
37: super .setUp();
38: DatabaseHelper.runScript("", "jdbc/CreateDS");
39:
40: factory = DatabaseHelper.createHibernateSessionFactory();
41:
42: Configuration config = new DefaultConfiguration();
43: config
44: .load(getClass().getResource(
45: "/osworkflow-hibernate.xml"));
46: workflow.setConfiguration(config);
47: ((BasicWorkflow) workflow).getConfiguration()
48: .getPersistenceArgs().put("sessionFactory", factory);
49: }
50:
51: protected void tearDown() throws Exception {
52: factory.close();
53: DatabaseHelper.runScript(getClass().getResource(
54: "/scripts/jdbc/dropschema.sql"), "jdbc/DefaultDS");
55: }
56: }
|