1
2
3
4
5
6
7
8
9 package bexee.model;
10
11 import java.io.*;
12 import java.util.List;
13
14 import org.jmock.MockObjectTestCase;
15
16 import bexee.model.activity.Receive;
17 import bexee.model.process.*;
18
19 /***
20 * @author Pawel Kowalski
21 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:17 $
22 */
23 public class BPELElementVisitorTest extends MockObjectTestCase {
24
25 private BPELProcessFactory factory;
26
27 private ClassLoader loader;
28
29 protected void setUp() throws Exception {
30 super.setUp();
31 factory = BPELProcessFactory.getInstance();
32 loader = getClass().getClassLoader();
33 }
34
35 protected void tearDown() throws Exception {
36 super.tearDown();
37 }
38
39 public void testCreationReceivesVisitor() {
40 try {
41
42 InputStream inputStream = loader
43 .getResourceAsStream("receiveReplyProcess.xml");
44 BPELProcess bpelProcess = factory.createBPELProcess(inputStream);
45
46 bexee.model.process.Process process = bpelProcess.getProcess();
47
48 assertNotNull(process);
49
50 FindCreateReceivesVisitor findReceives = new FindCreateReceivesVisitor();
51 process.accept(findReceives);
52 List creationReceives = findReceives.getCreationReceives();
53
54 Receive creationReceive = (Receive) creationReceives.get(0);
55 assertEquals("receiveInput", creationReceive.getName());
56 assertTrue(creationReceive.isCreateInstance());
57
58 } catch (Exception e) {
59 fail("must create a BPELProcess without throwing an Exception");
60 }
61 }
62
63 public void testIsSynchProcessTrue() {
64 try {
65
66 InputStream inputStream = loader
67 .getResourceAsStream("receiveReplyProcess.xml");
68 BPELProcess bpelProcess = factory.createBPELProcess(inputStream);
69
70 bexee.model.process.Process process = bpelProcess.getProcess();
71
72 IsSynchronousProcessVisitor synchVisitor = new IsSynchronousProcessVisitor();
73 process.accept(synchVisitor);
74
75 assertTrue(synchVisitor.isSynchronous());
76
77 } catch (Exception e) {
78 fail("must create a BPELProcess without throwing an Exception");
79 }
80 }
81
82
83 public void testIsSynchProcessFalse() {
84 try {
85
86 InputStream inputStream = loader
87 .getResourceAsStream("asynchProcess.xml");
88 BPELProcess bpelProcess = factory.createBPELProcess(inputStream);
89
90 bexee.model.process.Process process = bpelProcess.getProcess();
91
92 IsSynchronousProcessVisitor synchVisitor = new IsSynchronousProcessVisitor();
93 process.accept(synchVisitor);
94
95 assertFalse(synchVisitor.isSynchronous());
96
97 } catch (Exception e) {
98 fail("must create a BPELProcess without throwing an Exception");
99 }
100 }
101
102 }