1 package org.jbpm.bpel.par; 2 3 import java.io.InputStream ; 4 import java.util.List ; 5 import java.util.zip.ZipInputStream ; 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 21 public class ProcessArchiveTest extends TestCase { 22 23 public ProcessArchiveTest(String name) { 24 super(name); 25 } 26 27 public void testParseProcessDefinition() throws Exception { 28 ProcessArchive archive = createProcessArchive("archiveSample.zip"); 30 BpelDefinition processDefinition = (BpelDefinition) archive.parseProcessDefinition(); 31 assertTrue(archive.getProblems().isEmpty()); 33 assertEquals("processSample.bpel", processDefinition.getLocation()); 35 assertEquals("sampleProcess", processDefinition.getName()); 37 List imports = processDefinition.getImports().getImports(); 39 assertEquals(1, imports.size()); 40 Import imp = (Import) imports.get(0); 42 assertEquals("wsdl/partnerLinkTypeSample.wsdl", imp.getLocation()); 43 Definition definition = (Definition) imp.getDocument(); 45 assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace()); 46 } 47 48 public void testParseProcessDefinition_1_1() throws Exception { 49 ProcessArchive archive = createProcessArchive("archiveSample-1_1.zip"); 51 BpelDefinition processDefinition = (BpelDefinition) archive.parseProcessDefinition(); 52 assertTrue(archive.getProblems().isEmpty()); 54 assertEquals("bpel/processSample-1_1.bpel", processDefinition.getLocation()); 56 assertEquals("sampleProcess", processDefinition.getName()); 58 List imports = processDefinition.getImports().getImports(); 60 assertEquals(1, imports.size()); 61 Import imp = (Import) imports.get(0); 63 assertEquals("wsdl/partnerLinkTypeSample-1_1.wsdl", imp.getLocation()); 64 Definition definition = (Definition) imp.getDocument(); 66 assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace()); 67 } 68 69 private ProcessArchive createProcessArchive(String resourceName) throws Exception { 70 InputStream archiveStream = getClass().getResourceAsStream(resourceName); 71 ProcessArchive archive = new ProcessArchive(new ZipInputStream (archiveStream)); 72 archiveStream.close(); 73 return archive; 74 } 75 } 76 | Popular Tags |