1 package org.jbpm.bpel.xml; 2 3 import java.io.StringReader ; 4 5 import junit.framework.TestCase; 6 7 import org.xml.sax.InputSource ; 8 9 import org.jbpm.bpel.bar.BarApplication; 10 import org.jbpm.bpel.bar.BarPartnerLink; 11 import org.jbpm.bpel.bar.BarScope; 12 import org.jbpm.bpel.xml.util.NodeUtil; 13 14 public class BarDescriptorReaderTest extends TestCase { 15 16 BarDescriptorReader reader = BarDescriptorReader.getInstance(); 17 18 public void testReadUri() { 19 ProblemCollector problems = new ProblemCollector(); 20 reader.setProblemHandler(problems); 21 22 BarApplication application = new BarApplication(); 23 String locationUri = getClass().getResource("bpelApplicationSample.xml").toString(); 24 reader.read(application, new InputSource (locationUri)); 25 26 assertFalse(problems.hasErrors()); 27 } 28 29 public void testApplicationConnectionFactoryName() throws Exception { 30 String text = 31 "<bpelApplication xmlns='" + BpelConstants.NS_VENDOR + "'>" + 32 " <connectionFactory name='CF'/>" + 33 "</bpelApplication>"; 34 BarApplication application = new BarApplication(); 35 reader.read(application, new InputSource ( new StringReader (text) )); 36 37 assertEquals("CF", application.getConnectionFactoryName()); 38 } 39 40 public void testScopeName() throws Exception { 41 String text = "<scope name='rfpScope'/>"; 42 BarScope scope = new BarScope(); 43 reader.readScope(NodeUtil.parseElement(text), scope); 44 45 assertEquals("rfpScope", scope.getName()); 46 } 47 48 public void testScopeDestination() throws Exception { 49 String text = 50 "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" + 51 " <destination name='queue/b'/>" + 52 "</scope>"; 53 BarScope scope = new BarScope(); 54 reader.readScope(NodeUtil.parseElement(text), scope); 55 56 assertEquals("queue/b", scope.getDestinationName()); 57 } 58 59 public void testScopePartnerLinks() throws Exception { 60 String text = 61 "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" + 62 "<partnerLinks><partnerLink name='aName'/></partnerLinks>" + 63 "</scope>"; 64 BarScope scope = new BarScope(); 65 reader.readScope(NodeUtil.parseElement(text), scope); 66 67 assertEquals(1, scope.getPartnerLinks().size()); 68 } 69 70 public void testScopeScopes() throws Exception { 71 String text = 72 "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" + 73 "<scopes><scope name='aName'/></scopes>" + 74 "</scope>"; 75 BarScope scope = new BarScope(); 76 reader.readScope(NodeUtil.parseElement(text), scope); 77 78 assertEquals(1, scope.getScopes().size()); 79 } 80 81 public void testPartnerLinkName() throws Exception { 82 String text = "<partnerLink name='schedulerPL'/>"; 83 BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text)); 84 85 assertEquals("schedulerPL", plink.getName()); 86 } 87 88 public void testPartnerLinkDestination() throws Exception { 89 String text = 90 "<partnerLink xmlns='" + BpelConstants.NS_VENDOR + "'>" + 91 " <destination name='queue/b'/>" + 92 "</partnerLink>"; 93 BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text)); 94 95 assertEquals("queue/b", plink.getDestinationName()); 96 } 97 98 public void testPartnerLinkJndiName() throws Exception { 99 String text = 100 "<partnerLink xmlns='" + BpelConstants.NS_VENDOR + "'>" + 101 " <namingContext name='Scheduler'/>" + 102 "</partnerLink>"; 103 BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text)); 104 105 assertEquals("Scheduler", plink.getNamingContextName()); 106 } 107 108 } 109 | Popular Tags |