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 import org.jbpm.bpel.xml.ArchiveWsdlLocator; 16 import org.jbpm.bpel.xml.BpelReader; 17 18 22 public class BpelArchiveParserTest extends TestCase { 23 24 private BpelArchiveParser bpelParser = new BpelArchiveParser(); 25 private BpelDefinition processDefinition = new BpelDefinition(); 26 27 public BpelArchiveParserTest(String name) { 28 super(name); 29 } 30 31 public void testReadFromArchive() throws Exception { 32 ProcessArchive archive = createProcessArchive("archiveSample.zip"); 33 processDefinition.setLocation("processSample.bpel"); 35 bpelParser.readFromArchive(archive, processDefinition); 36 assertEquals("sampleProcess", processDefinition.getName()); 38 List imports = processDefinition.getImports().getImports(); 40 assertEquals(1, imports.size()); 41 Import imp = (Import) imports.get(0); 43 assertEquals("wsdl/partnerLinkTypeSample.wsdl", imp.getLocation()); 44 Definition definition = (Definition) imp.getDocument(); 46 assertEquals("http://manufacturing.org/wsdl/purchase", definition.getTargetNamespace()); 47 } 48 49 public void testReadFromArchive_1_1() throws Exception { 50 ProcessArchive archive = createProcessArchive("archiveSample-1_1.zip"); 51 Import imp = new Import(); 53 imp.setNamespace("http://manufacturing.org/wsdl/purchase"); 54 imp.setLocation("wsdl/partnerLinkTypeSample-1_1.wsdl"); 55 imp.setType(Import.Type.WSDL); 56 BpelReader.getInstance().readWsdlDocument(imp, new ArchiveWsdlLocator("", archive)); 57 processDefinition.getImports().addImport(imp); 58 processDefinition.setLocation("bpel/processSample-1_1.bpel"); 60 bpelParser.readFromArchive(archive, processDefinition); 61 assertEquals("sampleProcess", processDefinition.getName()); 63 List imports = processDefinition.getImports().getImports(); 65 assertEquals(1, imports.size()); 66 } 67 68 private ProcessArchive createProcessArchive(String resourceName) throws Exception { 69 InputStream archiveStream = getClass().getResourceAsStream(resourceName); 70 ProcessArchive archive = new ProcessArchive(new ZipInputStream (archiveStream)); 71 archiveStream.close(); 72 return archive; 73 } 74 } 75 | Popular Tags |