Using Osworkflow in your Application
Using Osworkflow in your Application
Using Osworkflow in your Application
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Us<strong>in</strong>g</strong> OSWorkfl ow <strong>in</strong> <strong>your</strong> <strong>Application</strong><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
This snippet is self-descriptive and <strong>in</strong>cludes the usual JNDI datasource name, the<br />
table, and each of the column names.<br />
Unit Test<strong>in</strong>g <strong>your</strong> Workflow<br />
A fter construct<strong>in</strong>g and chang<strong>in</strong>g <strong>your</strong> bus<strong>in</strong>ess processes, you will want to validate<br />
the functionality and fl ow. This section expla<strong>in</strong>s how to use the JUnit framework to<br />
verify the correctness and completeness of <strong>your</strong> bus<strong>in</strong>ess process. This verifi cation is<br />
called unit test<strong>in</strong>g.<br />
What is JUnit?<br />
J Unit is a unit-test<strong>in</strong>g framework for Java. JUnit is based on a TestCase concept: each<br />
TestCase conta<strong>in</strong>s a set of assertions; if any of these assertions fail, the TestCase<br />
fails. To run unit tests you need to download JUnit from http://junit.org/<br />
<strong>in</strong>dex.html. Unpack the distribution and copy junit.jar to <strong>your</strong> classpath; that's<br />
the only fi le we need to run our example (<strong>in</strong> addition to the OSWorkfl ow libraries<br />
we've used before).<br />
For this example, we'll build a JUnit TestCase with a set of assertions about the<br />
current steps and available actions of a sample WorkflowDescriptor. You can<br />
extend this example with <strong>your</strong> own set of assertions, as they vary across bus<strong>in</strong>ess<br />
processes. Here's the TestCase code:<br />
package packtpub.osw;<br />
import java.util.Collection;<br />
import java.util.HashMap;<br />
import junit.framework.TestCase;<br />
import com.opensymphony.workflow.Workflow;<br />
import com.opensymphony.workflow.basic.BasicWorkflow;<br />
import com.opensymphony.workflow.config.Configuration;<br />
import com.opensymphony.workflow.config.DefaultConfiguration;<br />
import com.opensymphony.workflow.spi.Step;<br />
[ 82 ]