1 package org.jbpm.bpel.xml; 2 3 import java.io.StringReader ; 4 5 import org.xml.sax.InputSource ; 6 7 import junit.framework.TestCase; 8 9 import org.jbpm.bpel.def.Import; 10 import org.jbpm.bpel.par.ParDefinition; 11 import org.jbpm.bpel.xml.util.NodeUtil; 12 13 17 public class ParDescriptorReaderTest extends TestCase { 18 19 private ParDescriptorReader reader = ParDescriptorReader.getInstance(); 20 21 public void testReadUri() { 22 ProblemCollector problems = new ProblemCollector(); 23 reader.setProblemHandler(problems); 24 25 String locationUri = getClass().getResource("bpelDefinitionSample.xml").toString(); 26 ParDefinition definition = new ParDefinition(); 27 reader.read(definition, new InputSource (locationUri)); 28 29 assertFalse(problems.hasErrors()); 30 } 31 32 public void testDefinitionLocation() throws Exception { 33 String text = "<bpelDefinition location='hello.bpel' xmlns='http://jbpm.org/bpel'/>"; 35 ParDefinition definition = new ParDefinition(); 36 reader.read(definition, new InputSource ( new StringReader (text) )); 37 assertEquals("hello.bpel", definition.getLocation()); 39 } 40 41 public void testDefinitionImports() throws Exception { 42 String text = 44 "<bpelDefinition xmlns='http://jbpm.org/bpel'>" + 45 " <imports>" + 46 " <wsdl />" + 47 " <schema />" + 48 " </imports>" + 49 "</bpelDefinition>"; 50 ParDefinition definition = new ParDefinition(); 51 reader.read(definition, new InputSource ( new StringReader (text) )); 52 assertEquals(2, definition.getImports().size()); 54 } 55 56 public void testImportNamespace() throws Exception { 57 String text = "<wsdl namespace='http://jbpm.org/bpel/examples'/>"; 59 Import imp = reader.readImport(NodeUtil.parseElement(text)); 60 assertEquals(BpelConstants.NS_EXAMPLES, imp.getNamespace()); 62 } 63 64 public void testImportLocation() throws Exception { 65 String text = "<wsdl location='hello.wsdl'/>"; 67 Import imp = reader.readImport(NodeUtil.parseElement(text)); 68 assertEquals("hello.wsdl", imp.getLocation()); 70 } 71 72 public void testImportTypeWsdl() throws Exception { 73 String text = "<wsdl />"; 75 Import imp = reader.readImport(NodeUtil.parseElement(text)); 76 assertEquals(Import.Type.WSDL, imp.getType()); 78 } 79 80 public void testImportTypeXmlSchema() throws Exception { 81 String text = "<schema />"; 83 Import imp = reader.readImport(NodeUtil.parseElement(text)); 84 assertEquals(Import.Type.XML_SCHEMA, imp.getType()); 86 } 87 } 88 | Popular Tags |