1   /*
2    * $Id: BPELElementFactoryTest.java,v 1.1 2004/12/15 14:18:18 patforna Exp $
3    *
4    * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
5    * Berne University of Applied Sciences
6    * School of Engineering and Information Technology
7    * All rights reserved.
8    */
9   package bexee.model.xmltobpel;
10  
11  import org.jmock.MockObjectTestCase;
12  
13  import bexee.model.AttributeNames;
14  import bexee.model.elements.*;
15  import bexee.model.process.BPELProcess;
16  import bexee.model.process.impl.BPELProcessImpl;
17  
18  /***
19   * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:18 $
20   * @author Pawel Kowalski
21   */
22  public class BPELElementFactoryTest extends MockObjectTestCase implements
23          AttributeNames {
24  
25      /*
26       * @see TestCase#setUp()
27       */
28      protected void setUp() throws Exception {
29          super.setUp();
30      }
31  
32      /*
33       * @see TestCase#tearDown()
34       */
35      protected void tearDown() throws Exception {
36          super.tearDown();
37      }
38  
39      public final void testGetInstanceBPELProcessEquals() {
40  
41          BPELProcess bpelProcess = new BPELProcessImpl();
42  
43          BPELElementFactory elementFactoryOne = BPELElementFactory
44                  .getInstance(bpelProcess);
45          BPELElementFactory elementFactoryTwo = BPELElementFactory
46                  .getInstance(bpelProcess);
47  
48          assertEquals(elementFactoryOne, elementFactoryTwo);
49      }
50  
51      public final void testGetInstanceBPELProcessNotEquals() {
52  
53          BPELProcess bpelProcessOne = new BPELProcessImpl();
54          BPELProcess bpelProcessTwo = new BPELProcessImpl();
55  
56          BPELElementFactory elementFactoryOne = BPELElementFactory
57                  .getInstance(bpelProcessOne);
58          BPELElementFactory elementFactoryTwo = BPELElementFactory
59                  .getInstance(bpelProcessTwo);
60  
61          assertNotSame(elementFactoryOne, elementFactoryTwo);
62      }
63  
64      public final void testCreateRetrievePartnerLink() {
65  
66          BPELProcess bpelProcess = new BPELProcessImpl();
67          BPELElementFactory elementFactory = BPELElementFactory
68                  .getInstance(bpelProcess);
69  
70          String pLinkName = "aPartnerLink";
71          String partnerLinkType = "type:aPartnerLinkType";
72          String myRole = "aMyRole";
73          String partnerRole = "aPartnerRole";
74  
75          PartnerLink pLink = elementFactory.createPartnerLink(pLinkName,
76                  partnerLinkType, myRole, partnerRole);
77  
78          assertEquals(pLink, elementFactory.retrievePartnerLink(pLinkName));
79          assertNotSame(pLink, elementFactory.retrievePartnerLink("otherName"));
80      }
81  
82      public final void testCreateRetrievePartnerLinkDifferentProcesses() {
83  
84          BPELProcess bpelProcessOne = new BPELProcessImpl();
85          BPELProcess bpelProcessTwo = new BPELProcessImpl();
86  
87          BPELElementFactory elementFactoryOne = BPELElementFactory
88                  .getInstance(bpelProcessOne);
89          BPELElementFactory elementFactoryTwo = BPELElementFactory
90                  .getInstance(bpelProcessTwo);
91  
92          String pLinkName = "aPartnerLink";
93          String partnerLinkType = "type:aPartnerLinkType";
94          String myRole = "aMyRole";
95          String partnerRole = "aPartnerRole";
96  
97          PartnerLink pLink = elementFactoryOne.createPartnerLink(pLinkName,
98                  partnerLinkType, myRole, partnerRole);
99  
100         assertNotSame(pLink, elementFactoryTwo.retrievePartnerLink(pLinkName));
101     }
102 
103     public final void testCreateRetrieveVariable() {
104 
105         BPELProcess bpelProcess = new BPELProcessImpl();
106         BPELElementFactory elementFactory = BPELElementFactory
107                 .getInstance(bpelProcess);
108 
109         String varName = "varName";
110         String varMessageType = "type:varMessageType";
111         String varType = "varType";
112         String varElement = "varElement";
113 
114         Variable variable = elementFactory.createVariable(varName,
115                 varMessageType, varType, varElement);
116 
117         assertEquals(variable, elementFactory.retrieveVariable(varName));
118         assertNotSame(variable, elementFactory.retrieveVariable("otherName"));
119     }
120 
121     public final void testCreateRetrieveVariableDifferentProcesses() {
122 
123         BPELProcess bpelProcessOne = new BPELProcessImpl();
124         BPELProcess bpelProcessTwo = new BPELProcessImpl();
125 
126         BPELElementFactory elementFactoryOne = BPELElementFactory
127                 .getInstance(bpelProcessOne);
128         BPELElementFactory elementFactoryTwo = BPELElementFactory
129                 .getInstance(bpelProcessTwo);
130 
131         String varName = "varName";
132         String varMessageType = "type:varMessageType";
133         String varType = "varType";
134         String varElement = "varElement";
135 
136         Variable variableOne = elementFactoryOne.createVariable(varName,
137                 varMessageType, varType, varElement);
138 
139         Variable variableTwo = elementFactoryTwo.createVariable(varName,
140                 varMessageType, varType, varElement);
141 
142         assertNotSame(variableOne, elementFactoryTwo.retrieveVariable(varName));
143         assertNotSame(variableTwo, elementFactoryOne.retrieveVariable(varName));
144     }
145 }