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