KickJava   Java API By Example, From Geeks To Geeks.

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


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  * @author Alejandro Guízar
18  * @version $Revision: 1.3 $ $Date: 2005/06/23 02:17:27 $
19  */

20 public class ParDescriptorArchiveParserTest extends TestCase {
21
22   ParDescriptorArchiveParser parParser = new ParDescriptorArchiveParser();
23   
24   public ParDescriptorArchiveParserTest(String JavaDoc name) {
25     super(name);
26   }
27
28   public void testReadFromArchive() throws Exception JavaDoc {
29     ProcessArchive archive = createProcessArchive("archiveSample.zip");
30     // parse par descriptor
31
BpelDefinition processDefinition = (BpelDefinition) parParser.readFromArchive(archive, null);
32     assertTrue(archive.getProblems().isEmpty());
33     // test location
34
assertEquals("processSample.bpel", processDefinition.getLocation());
35     // test import count
36
List JavaDoc imports = processDefinition.getImports().getImports();
37     assertNull(imports);
38   }
39   
40   public void testReadFromArchive_1_1() throws Exception JavaDoc {
41     ProcessArchive archive = createProcessArchive("archiveSample-1_1.zip");
42     // parse par descriptor
43
BpelDefinition processDefinition = (BpelDefinition) parParser.readFromArchive(archive, null);
44     assertTrue(archive.getProblems().isEmpty());
45     // process location
46
assertEquals("bpel/processSample-1_1.bpel", processDefinition.getLocation());
47     // import count
48
List JavaDoc imports = processDefinition.getImports().getImports();
49     assertEquals(1, imports.size());
50     // wsdl location
51
Import imp = (Import) imports.get(0);
52     assertEquals("wsdl/partnerLinkTypeSample-1_1.wsdl", imp.getLocation());
53     // wsdl target namespace
54
Definition definition = (Definition) imp.getDocument();
55     assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace());
56   }
57
58   private ProcessArchive createProcessArchive(String JavaDoc resourceName) throws Exception JavaDoc {
59     InputStream JavaDoc archiveStream = getClass().getResourceAsStream(resourceName);
60     ProcessArchive archive = new ProcessArchive(new ZipInputStream JavaDoc(archiveStream));
61     archiveStream.close();
62     return archive;
63   }
64 }
65
Popular Tags