[overlord-commits] Overlord SVN: r589 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel: src/java/org/jboss/tools/overlord/cdl/bpel/model/change and 3 other directories.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Mon Apr 20 18:08:19 EDT 2009
Author: objectiser
Date: 2009-04-20 18:08:19 -0400 (Mon, 20 Apr 2009)
New Revision: 589
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Seller.bpel
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/ReqRespFault.cdm
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
Log:
Generate fault name in reply - and support plugin tests based on a cdm file.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF 2009-04-14 10:33:27 UTC (rev 588)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF 2009-04-20 22:08:19 UTC (rev 589)
@@ -14,7 +14,8 @@
org.eclipse.jdt.core,
org.junit,
org.scribble.conversation.parser,
- org.apache.log4j;bundle-version="1.2.13"
+ org.apache.log4j;bundle-version="1.2.13",
+ org.pi4soa.scribble;resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: www.jboss.org
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-14 10:33:27 UTC (rev 588)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-20 22:08:19 UTC (rev 589)
@@ -131,6 +131,11 @@
pl.setPartnerLinkType(interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT");
portType = role.getName()+"PT";
+
+ if (interaction.getMessageSignature().getAnnotations().keySet().contains("faultName")) {
+ ((Reply)act).setFaultName((String)interaction.
+ getMessageSignature().getAnnotations().get("faultName"));
+ }
}
} else {
act = new Receive(bpelModel);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-14 10:33:27 UTC (rev 588)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-20 22:08:19 UTC (rev 589)
@@ -25,6 +25,7 @@
import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
import org.jboss.tools.overlord.cdl.bpel.util.XMLUtils;
import org.scribble.conversation.model.ConversationNotation;
+import org.pi4soa.scribble.cdm.model.CDMNotation;
import org.scribble.extensions.RegistryFactory;
import org.scribble.model.ModelReference;
import org.scribble.model.change.ModelGenerator;
@@ -35,6 +36,8 @@
TestSuite suite = new TestSuite("Conversation->BPEL Generator Tests");
suite.addTest(new ConversationToBPELTest("ESBBrokerProcess at Broker"));
suite.addTest(new ConversationToBPELTest("PurchaseGoodsProcess at Store"));
+ suite.addTest(new ChoreographyToBPELTest("ReqRespFault", "Buyer"));
+ suite.addTest(new ChoreographyToBPELTest("ReqRespFault", "Seller"));
return suite;
}
@@ -165,4 +168,143 @@
private String m_name=null;
}
+ /**
+ * The test case for running the choreography to BPEL test.
+ */
+ protected static class ChoreographyToBPELTest extends TestCase {
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ * @param role The role
+ */
+ public ChoreographyToBPELTest(String name, String role) {
+ super(name+"@"+role);
+ m_name = name;
+ m_role = role;
+ }
+
+ /**
+ * This method runs the test.
+ *
+ * @param result The test result
+ */
+ public void run(TestResult result) {
+ result.startTest(this);
+
+ String filename="testmodels/"+m_name+".cdm";
+
+ java.io.InputStream is=
+ GeneratorTest.class.getResourceAsStream(filename);
+
+ if (is == null) {
+ result.addError(this,
+ new Throwable("Unable to locate resource: "+filename));
+ } else {
+ org.scribble.parser.Parser p=new org.pi4soa.scribble.cdm.parser.CDMParser();
+ org.scribble.model.ModelReference ref=
+ new org.scribble.model.ModelReference(CDMNotation.NOTATION_CODE);
+ org.scribble.model.admin.ModelListener l=
+ new org.scribble.model.admin.DefaultModelListener();
+
+ org.scribble.model.Model model=p.parse(ref, is, l);
+
+ if (model == null) {
+ result.addError(this, new Throwable("Model is null"));
+ } else {
+ org.scribble.projector.Projector projector=
+ new org.scribble.projector.DefaultProjector();
+
+ org.scribble.model.Role role=
+ new org.scribble.model.Role(m_role);
+
+ org.scribble.model.Model projected=
+ projector.project(ref, model, role, l);
+
+ ModelGenerator generator=(ModelGenerator)
+ RegistryFactory.getRegistry().getExtension(
+ ModelGenerator.class, null);
+
+ if (generator != null) {
+ ModelReference targetRef=
+ new ModelReference(BPELNotation.NOTATION_CODE);
+
+ DefaultBPELLanguageModel target=
+ new DefaultBPELLanguageModel(targetRef);
+
+ generator.generate(targetRef,
+ model.getModelName().getLocatedRole(),
+ target, projected);
+
+ if (target.getBPELProcess().getDOMElement() != null) {
+ try {
+ String text=XMLUtils.toText(target.getBPELProcess().getDOMElement());
+ checkResults(result, text);
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("No BPEL generated"));
+ }
+
+ } else {
+ result.addError(this,
+ new Throwable("Unable to find Model Generator"));
+ }
+ }
+ }
+
+ result.endTest(this);
+ }
+
+ /**
+ * This method checks the generated BPEL against a
+ * previously stored correct version.
+ *
+ * @param result The test result
+ * @param bpel The BPEL
+ */
+ protected void checkResults(TestResult result, String bpel) {
+
+ String filename="results/"+m_name+"@"+m_role+".bpel";
+
+ java.io.InputStream is=
+ GeneratorTest.class.getResourceAsStream(filename);
+
+ if (is != null) {
+
+ try {
+ byte[] b=new byte[is.available()];
+
+ is.read(b);
+
+ is.close();
+
+ String orig=new String(b);
+
+ if (orig.equals(bpel) == false) {
+ result.addError(this,
+ new Throwable("Generated BPEL does not match stored version"));
+
+ System.out.println("COMPARED GENERATED:");
+ System.out.println("["+bpel+"]");
+ System.out.println("WITH ORIGINAL:");
+ System.out.println("["+orig+"]");
+ }
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("Resulting BPEL '"+filename+
+ "' not found for comparison"));
+ }
+ }
+
+ private String m_name=null;
+ private String m_role=null;
+ }
}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel 2009-04-20 22:08:19 UTC (rev 589)
@@ -0,0 +1,18 @@
+<process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <partnerLinks>
+ <partnerLink myRole="BuyerRequester" name="BuyerToSeller" partnerLinkType="BuyerToSellerLT" partnerRole="SellerRequester"/>
+ </partnerLinks>
+ <sequence>
+ <invoke operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
+ <if>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
+ </sequence>
+ <else>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Seller.bpel
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Seller.bpel (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Seller.bpel 2009-04-20 22:08:19 UTC (rev 589)
@@ -0,0 +1,18 @@
+<process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <partnerLinks>
+ <partnerLink myRole="SellerService" name="BuyerToSeller" partnerLinkType="BuyerToSellerServiceLT"/>
+ </partnerLinks>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
+ <if>
+ <sequence>
+ <reply operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
+ </sequence>
+ <else>
+ <sequence>
+ <reply faultName="insufficientCredit" operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/ReqRespFault.cdm
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/ReqRespFault.cdm (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/ReqRespFault.cdm 2009-04-20 22:08:19 UTC (rev 589)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="Cp1252"?>
+<org.pi4soa.cdl:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The choreography description for ReqRespFault" name="ReqRespFault" author="gary" version="0.3" targetNamespace="http://www.pi4soa.org/ReqRespFault">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for ReqRespFault" prefix="tns" uRI="http://www.pi4soa.org/ReqRespFault"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <informationTypes description="This is the information type CreditInformation" name="CreditInformation" elementName="CreditCheckRequest"/>
+ <informationTypes description="This is the information type CreditInvalid" name="CreditInvalid" elementName="CreditCheckInvalid"/>
+ <informationTypes description="This is the information type CreditValid" name="CreditValid" elementName="CreditCheckOk"/>
+ <informationTypes description="This is the information type URIType" name="URIType"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/@informationTypes.3"/>
+ <roleTypes description="This is the role type Buyer" name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior" name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Seller" name="Seller">
+ <behaviors description="This is the behavior SellerBehavior" name="SellerBehavior"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Seller" name="BuyerToSellerRel" firstRoleType="//@typeDefinitions/@roleTypes.0" secondRoleType="//@typeDefinitions/@roleTypes.1"/>
+ <participantTypes description="This is the participant type Buyer" name="Buyer" roleTypes="//@typeDefinitions/@roleTypes.0">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Buyer" name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type Seller" name="Seller" roleTypes="//@typeDefinitions/@roleTypes.1">
+ <semanticAnnotations annotation="overlord.cdl.samples.LoanBroker at Broker" name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type SellerChannelType" name="SellerChannelType" referenceToken="//@typeDefinitions/@tokens.0" roleType="//@typeDefinitions/@roleTypes.1"/>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the ReqRespFault process" name="ReqRespFaultProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to Broker" name="BrokerChannel" type="//@typeDefinitions/@channelTypes.0" roleTypes="//@typeDefinitions/@roleTypes.1 //@typeDefinitions/@roleTypes.0"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheck" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction CreditCheck" name="CreditCheckRequestExchange" type="//@typeDefinitions/@informationTypes.0"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckValid" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckValid" name="CreditCheckValidRespondExchange" type="//@typeDefinitions/@informationTypes.2" action="Respond"/>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="CreditCheckInvalid" operation="checkCredit" channelVariable="//@choreographies.0/@variableDefinitions.0" relationship="//@typeDefinitions/@relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction CreditCheckInvalid" name="CreditCheckInvalidRespondExchange" type="//@typeDefinitions/@informationTypes.1" action="Respond" faultName="insufficientCredit"/>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
More information about the overlord-commits
mailing list