/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.workflow.spi.hibernate;

import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;

import com.opensymphony.workflow.basic.BasicWorkflow;
import com.opensymphony.workflow.config.Configuration;
import com.opensymphony.workflow.config.DefaultConfiguration;
import com.opensymphony.workflow.spi.AbstractFunctionalWorkflowTest;
import com.opensymphony.workflow.util.DatabaseHelper;


/**
 * This test case is functional in that it attempts to validate the entire
 * lifecycle of a workflow.  This is also a good resource for beginners
 * to OSWorkflow.  This leverages Hibernate as the persistence mechanism.
 *
 * @author Eric Pugh (epugh@upstate.com)
 */
public class NewHibernateFunctionalWorkflowTestCase extends AbstractFunctionalWorkflowTest {
    //~ Instance fields ////////////////////////////////////////////////////////

    private SessionFactory factory;
    Session session;
    //~ Constructors ///////////////////////////////////////////////////////////

    public NewHibernateFunctionalWorkflowTestCase(String s) {
        super(s);
    }

    //~ Methods ////////////////////////////////////////////////////////////////

    protected void setUp() throws Exception {
        super.setUp();
        DatabaseHelper.runScript("", "jdbc/CreateDS");

        factory = DatabaseHelper.createHibernateSessionFactory();

        Configuration config = new DefaultConfiguration();
        config.load(getClass().getResource("/new-osworkflow-hibernate.xml"));
        workflow.setConfiguration(config);
        session = factory.openSession();
        ((BasicWorkflow)workflow).getConfiguration().getPersistenceArgs().put("session", session);
    }

    protected void tearDown() throws Exception {
        session.flush();
        session.close();
        factory.close();
    }
}

@@ -121,82 +121,8 @@
 e;%0A%0A
-import net.sf.hibernate.Session;%0Aimport net.sf.hibernate.SessionFactory;%0A%0A
 impo
@@ -416,276 +416,203 @@
 r;%0A%0A
-%0A/**%0A * This test case is functional in that it attempts to validate the entire%0A * lifecycle of a workflow.  This is also a good resource for beginners%0A * to OSWorkflow.  This leverages Hibernate as the persistence mechanism.%0A *%0A * @author Eric Pugh (epugh@upstate.com
+import net.sf.hibernate.Session;%0Aimport net.sf.hibernate.SessionFactory;%0A%0A%0A/**%0A * White Box semi-functional test case that uses Hibernate as Store%0A *%0A * @author Luca Masini (l.masini@infogroup.it
 )%0A *
@@ -784,24 +784,45 @@
 //////////%0A%0A
+    Session session;%0A
     private 
@@ -845,36 +845,16 @@
 actory;%0A
-    Session session;
 %0A    //~
@@ -1287,16 +1287,57 @@
 ctory();
+%0A        session = factory.openSession();
 %0A%0A      
@@ -1479,92 +1479,70 @@
     
-workflow.setConfiguration(config);%0A        session = factory.openS
+config.getPersistenceArgs().put(%22session%22, s
 ession
-(
 );%0A
+%0A
         
 ((Ba
@@ -1541,32 +1541,16 @@
     
-((BasicWorkflow)
 workflow
 ).ge
@@ -1545,19 +1545,18 @@
 workflow
-).g
+.s
 etConfig
@@ -1567,53 +1567,14 @@
 ion(
-).getPersistenceArgs().put(%22session%22, session
+config
 );%0A 

Use config object instead of ugly cast