KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > par > ProcessArchiveTest


1 package org.jbpm.bpel.par;
2
3 import java.io.InputStream JavaDoc;
4 import java.util.List JavaDoc;
5 import java.util.zip.ZipInputStream JavaDoc;
6
7 import javax.wsdl.Definition;
8
9 import junit.framework.TestCase;
10
11 import org.jbpm.jpdl.par.ProcessArchive;
12
13 import org.jbpm.bpel.def.BpelDefinition;
14 import org.jbpm.bpel.def.Import;
15
16
17 /**
18  * @author Alejandro Guízar
19  * @version $Revision: 1.2 $ $Date: 2005/06/07 02:08:04 $
20  */

21 public class ProcessArchiveTest extends TestCase {
22
23   public ProcessArchiveTest(String JavaDoc name) {
24     super(name);
25   }
26
27   public void testParseProcessDefinition() throws Exception JavaDoc {
28     // parse definition
29
ProcessArchive archive = createProcessArchive("archiveSample.zip");
30     BpelDefinition processDefinition = (BpelDefinition) archive.parseProcessDefinition();
31     // no problems
32
assertTrue(archive.getProblems().isEmpty());
33     // bpel location
34
assertEquals("processSample.bpel", processDefinition.getLocation());
35     // process name
36
assertEquals("sampleProcess", processDefinition.getName());
37     // import count
38
List JavaDoc imports = processDefinition.getImports().getImports();
39     assertEquals(1, imports.size());
40     // wsdl location
41
Import imp = (Import) imports.get(0);
42     assertEquals("wsdl/partnerLinkTypeSample.wsdl", imp.getLocation());
43     // wsdl target namespace
44
Definition definition = (Definition) imp.getDocument();
45     assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace());
46   }
47   
48   public void testParseProcessDefinition_1_1() throws Exception JavaDoc {
49     // parse definition
50
ProcessArchive archive = createProcessArchive("archiveSample-1_1.zip");
51     BpelDefinition processDefinition = (BpelDefinition) archive.parseProcessDefinition();
52     // no problems
53
assertTrue(archive.getProblems().isEmpty());
54     // location
55
assertEquals("bpel/processSample-1_1.bpel", processDefinition.getLocation());
56     // process name
57
assertEquals("sampleProcess", processDefinition.getName());
58     // import count
59
List JavaDoc imports = processDefinition.getImports().getImports();
60     assertEquals(1, imports.size());
61     // wsdl location
62
Import imp = (Import) imports.get(0);
63     assertEquals("wsdl/partnerLinkTypeSample-1_1.wsdl", imp.getLocation());
64     // wsdl target namespace
65
Definition definition = (Definition) imp.getDocument();
66     assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace());
67   }
68   
69   private ProcessArchive createProcessArchive(String JavaDoc resourceName) throws Exception JavaDoc {
70     InputStream JavaDoc archiveStream = getClass().getResourceAsStream(resourceName);
71     ProcessArchive archive = new ProcessArchive(new ZipInputStream JavaDoc(archiveStream));
72     archiveStream.close();
73     return archive;
74   }
75 }
76
Popular Tags