[savara-commits] savara SVN: r645 - in branches/experimental/2.0.x: bundles/org.savara.bpel/src/main/java/org/savara/bpel/util and 10 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Feb 9 18:15:28 EST 2011
Author: objectiser
Date: 2011-02-09 18:15:27 -0500 (Wed, 09 Feb 2011)
New Revision: 645
Added:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ProtocolToContractGeneratorTest.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at CreditCheckService.contract
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at PolicyQuoteProcessService.contract
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PolicyQuote.spr
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/ProtocolToWSDLGeneratorTest.java
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_CreditCheckService_rpc_0.wsdl
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_PolicyQuoteProcessService_rpc_0.wsdl
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/testmodels/contract/PolicyQuote.spr
Removed:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/GeneratorTest.java
Modified:
branches/experimental/2.0.x/bundles/org.savara.bpel/build.properties
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELModelUtil.java
branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java
branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Namespace.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract
branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_CreditAgency_rpc_0.wsdl
branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_Store_rpc_0.wsdl
branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
Log:
Fixed some bpel and wsdl generation issues, such as ensuring the namespace is provided. Added further testcases based on the policy quote choreography.
Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/build.properties
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/build.properties 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/build.properties 2011-02-09 23:15:27 UTC (rev 645)
@@ -2,5 +2,4 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- lib/jaxb-api.jar,\
- lib/jaxb-impl.jar
+ lib/
Modified: branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELModelUtil.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELModelUtil.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/BPELModelUtil.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -62,14 +62,13 @@
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper=null;
-
if (prefixes != null) {
- mapper = new NamespacePrefixMapperImpl(prefixes);
-
try {
+ com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper=
+ new NamespacePrefixMapperImpl(prefixes);
+
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
- } catch (Exception mex) {
+ } catch (RuntimeException mex) {
mex.printStackTrace();
}
}
Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Contract.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -154,11 +154,45 @@
return(m_namespaces);
}
+ /**
+ * This method returns the namespace associated with
+ * the specified URI.
+ *
+ * @param uri The URI
+ * @return The namespace or null if not found
+ */
+ public Namespace getNamespaceForURI(String uri) {
+ Namespace ret=null;
+
+ for (Namespace ns : m_namespaces) {
+ if (ns.getURI() != null && ns.getURI().equals(uri)) {
+ ret = ns;
+ break;
+ }
+ }
+
+ return(ret);
+ }
+
public String toString() {
StringBuffer buf=new StringBuffer();
buf.append("Contract {"+m_namespace+"}"+m_name+" {\r\n");
+ // Sort namespaces, so output is consistent
+ java.util.List<Namespace> nslist=new Vector<Namespace>(getNamespaces());
+
+ Collections.sort(nslist, new Comparator<Namespace>() {
+
+ public int compare(Namespace arg0, Namespace arg1) {
+ return(arg0.getURI().compareTo(arg1.getURI()));
+ }
+ });
+
+ for (Namespace ns : nslist) {
+ buf.append(ns.toString());
+ }
+
// Sort type definitions, so output is consistent
java.util.List<TypeDefinition> tdlist=new Vector<TypeDefinition>(getTypeDefinitions());
@@ -173,7 +207,7 @@
buf.append(td.toString());
}
- // Sort type definitions, so output is consistent
+ // Sort interfaces, so output is consistent
java.util.List<Interface> intflist=new Vector<Interface>(getInterfaces());
Collections.sort(intflist, new Comparator<Interface>() {
Modified: branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Namespace.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Namespace.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.contract/src/main/java/org/savara/contract/model/Namespace.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -88,4 +88,9 @@
public void setSchemaLocation(String schemaLocation) {
m_schemaLocation = schemaLocation;
}
+
+ public String toString() {
+ return("\tNamespace prefix="+m_prefix+
+ " uri="+m_uri+" schemaLocation="+m_schemaLocation+"\r\n");
+ }
}
Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractGeneratorImpl.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -22,9 +22,7 @@
import org.savara.contract.model.Contract;
import org.savara.protocol.contract.generator.ContractGenerator;
import org.scribble.common.logging.Journal;
-import org.scribble.protocol.ProtocolContext;
import org.scribble.protocol.model.Protocol;
-import org.scribble.protocol.model.ProtocolModel;
import org.scribble.protocol.model.Role;
/**
Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/contract/generator/impl/ContractIntrospector.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -25,12 +25,14 @@
import java.util.logging.Logger;
import org.savara.protocol.model.util.InteractionUtil;
+import org.savara.protocol.model.util.TypeSystem;
import org.savara.common.model.annotation.Annotation;
import org.savara.common.model.annotation.AnnotationDefinitions;
import org.savara.contract.model.Contract;
import org.savara.contract.model.FaultDetails;
import org.savara.contract.model.Interface;
import org.savara.contract.model.MessageExchangePattern;
+import org.savara.contract.model.Namespace;
import org.savara.contract.model.OneWayRequestMEP;
import org.savara.contract.model.RequestResponseMEP;
import org.savara.contract.model.Type;
@@ -510,6 +512,31 @@
if (til != null) {
td.setTypeSystem(til.getFormat());
+
+ if (til.getFormat() != null && TypeSystem.XSD.equals(til.getFormat()) &&
+ til.getLocation() != null &&
+ getContract().getNamespaceForURI(til.getLocation()) == null) {
+
+ // Check if namespace has been defined for location
+ //tref.getModel().getProtocol().
+ java.util.List<Annotation> annotations=
+ AnnotationDefinitions.getAnnotations(tref.getModel().getProtocol().getAnnotations(),
+ AnnotationDefinitions.TYPE);
+
+ for (Annotation ann : annotations) {
+ String nstxt=(String)ann.getProperties().get(AnnotationDefinitions.NAMESPACE_PROPERTY);
+
+ if (nstxt != null && nstxt.equals(til.getLocation())) {
+ Namespace ns=new Namespace();
+ ns.setURI(til.getLocation());
+ ns.setPrefix((String)ann.getProperties().get(AnnotationDefinitions.PREFIX_PROPERTY));
+ ns.setSchemaLocation((String)ann.getProperties().get(AnnotationDefinitions.LOCATION_PROPERTY));
+ getContract().getNamespaces().add(ns);
+
+ break;
+ }
+ }
+ }
}
}
Deleted: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,237 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.protocol.contract.generator;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-import org.savara.common.model.annotation.Annotation;
-import org.savara.common.model.annotation.AnnotationDefinitions;
-import org.savara.common.model.generator.ModelGenerator;
-import org.savara.contract.model.Contract;
-import org.scribble.common.logging.CachedJournal;
-import org.scribble.protocol.model.Role;
-import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
-import org.savara.protocol.contract.generator.ContractGenerator;
-import org.savara.protocol.contract.generator.ContractGeneratorFactory;
-import org.savara.protocol.util.ProtocolServices;
-
-public class GeneratorTest {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Protocol->Contract Generator Tests");
-
- suite.addTest(new ProtocolToContractTester("ESBBroker", "Broker"));
- suite.addTest(new ProtocolToContractTester("ESBBroker", "Buyer"));
- suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierTxnProcessor"));
- suite.addTest(new ProtocolToContractTester("ESBBroker", "CreditAgency"));
- suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierQuoteEngine"));
-
- suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Buyer"));
- suite.addTest(new ProtocolToContractTester("PurchaseGoods", "CreditAgency"));
- suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Store"));
-
- suite.addTest(new ProtocolToContractTester("ReqRespFault", "Buyer"));
- suite.addTest(new ProtocolToContractTester("ReqRespFault", "Seller"));
-
- return suite;
- }
-
- protected static class ProtocolToContractTester extends TestCase {
-
- /**
- * This constructor is initialized with the test
- * name.
- *
- * @param name The test name
- * @param role The role
- */
- public ProtocolToContractTester(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) {
-
- // Run test
- result.startTest(this);
-
- String filename="testmodels/protocol/"+m_name+".spr";
-
- java.io.InputStream is=
- ClassLoader.getSystemResourceAsStream(filename);
-
- if (is == null) {
- result.addError(this,
- new Throwable("Unable to locate resource: "+filename));
- } else {
- CachedJournal journal=new CachedJournal();
-
- org.scribble.protocol.model.ProtocolModel model=null;
-
- ANTLRProtocolParser parser=new ANTLRProtocolParser();
- parser.setAnnotationProcessor(new org.savara.protocol.parser.AnnotationProcessor());
-
- try {
- model = parser.parse(is, journal, null);
- } catch(Exception e) {
- result.addError(this, new Throwable("Parsing choreography failed"));
- }
-
- if (model == null) {
- result.addError(this, new Throwable("Model is null"));
- } else {
- ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
- if (cg != null) {
- Contract contract=cg.generate(model.getProtocol(), null, new Role(m_role), journal);
-
- if (contract != null) {
- checkResults(result, contract.toString());
- } else {
- result.addError(this, new Throwable("No contract"));
- }
- }
- }
- }
-
- 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) {
- boolean f_valid=false;
-
- String filename="results/contract/"+m_name+"@"+m_role+".contract";
-
- java.io.InputStream is=
- //ChoreographyToBPELTester.class.getResourceAsStream(filename);
- ClassLoader.getSystemResourceAsStream(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 Contract does not match stored version"));
- } else {
- f_valid = true;
- }
- } catch(Exception e) {
- result.addError(this, e);
- }
- } else {
- result.addError(this,
- new Throwable("Resulting Contract '"+filename+
- "' not found for comparison"));
- }
-
- if (f_valid == false) {
- String srcfile="testmodels/protocol/"+m_name+".spr";
-
- java.net.URL url=ClassLoader.getSystemResource(srcfile);
-
- /*
- try {
- url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
- } catch(Exception e) {
- e.printStackTrace();
- }
- */
-
- if (url != null) {
- // URL will point to copy of test models in the classes folder, so need
- // to obtain reference back to source version
- java.io.File f=null;
-
- if (url.getFile().indexOf("target/test-classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("target/test-classes","src/test/resources"));
- } else if (url.getFile().indexOf("target/classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("target/classes","src/test/resources"));
- } else if (url.getFile().indexOf("classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("classes","src/test/resources"));
- } else if (url.getFile().indexOf("bin") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("bin","src/test/resources"));
- } else {
- result.addError(this, new Exception("Could not locate results folder to record expected result"));
- }
-
- if (f != null && f.exists()) {
- f = f.getParentFile().getParentFile().getParentFile();
-
- java.io.File resultsDir=new java.io.File(f, "results/contract");
-
- if (resultsDir.exists() == false) {
- resultsDir.mkdirs();
- }
-
- java.io.File resultFile=new java.io.File(resultsDir,
- m_name+"@"+m_role+".generated");
-
- //if (resultFile.exists() == false) {
- try {
- java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
-
- fos.write(bpel.getBytes());
-
- fos.flush();
- fos.close();
-
- } catch(Exception e){
- result.addError(this, e);
- }
- /*
- } else {
- System.err.println("NOTE: Generated output '"+resultFile+
- "' already exists - not being overwritten");
- }
- */
- } else {
- result.addError(this, new Throwable("Unable to obtain URL for model source '"+
- m_name+"': "+url));
- }
- }
- }
- }
-
- private String m_name=null;
- private String m_role=null;
- }
-}
Copied: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ProtocolToContractGeneratorTest.java (from rev 639, branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/GeneratorTest.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ProtocolToContractGeneratorTest.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/java/org/savara/protocol/contract/generator/ProtocolToContractGeneratorTest.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.protocol.contract.generator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.savara.contract.model.Contract;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
+
+public class ProtocolToContractGeneratorTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Protocol->Contract Generator Tests");
+
+ suite.addTest(new ProtocolToContractTester("PolicyQuote", "CreditCheckService"));
+ suite.addTest(new ProtocolToContractTester("PolicyQuote", "PolicyQuoteProcessService"));
+
+ suite.addTest(new ProtocolToContractTester("ESBBroker", "Broker"));
+ suite.addTest(new ProtocolToContractTester("ESBBroker", "Buyer"));
+ suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierTxnProcessor"));
+ suite.addTest(new ProtocolToContractTester("ESBBroker", "CreditAgency"));
+ suite.addTest(new ProtocolToContractTester("ESBBroker", "SupplierQuoteEngine"));
+
+ suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Buyer"));
+ suite.addTest(new ProtocolToContractTester("PurchaseGoods", "CreditAgency"));
+ suite.addTest(new ProtocolToContractTester("PurchaseGoods", "Store"));
+
+ suite.addTest(new ProtocolToContractTester("ReqRespFault", "Buyer"));
+ suite.addTest(new ProtocolToContractTester("ReqRespFault", "Seller"));
+
+ return suite;
+ }
+
+ protected static class ProtocolToContractTester extends TestCase {
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ * @param role The role
+ */
+ public ProtocolToContractTester(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) {
+
+ // Run test
+ result.startTest(this);
+
+ String filename="testmodels/protocol/"+m_name+".spr";
+
+ java.io.InputStream is=
+ ClassLoader.getSystemResourceAsStream(filename);
+
+ if (is == null) {
+ result.addError(this,
+ new Throwable("Unable to locate resource: "+filename));
+ } else {
+ CachedJournal journal=new CachedJournal();
+
+ org.scribble.protocol.model.ProtocolModel model=null;
+
+ ANTLRProtocolParser parser=new ANTLRProtocolParser();
+ parser.setAnnotationProcessor(new org.savara.protocol.parser.AnnotationProcessor());
+
+ try {
+ model = parser.parse(is, journal, null);
+ } catch(Exception e) {
+ result.addError(this, new Throwable("Parsing choreography failed"));
+ }
+
+ if (model == null) {
+ result.addError(this, new Throwable("Model is null"));
+ } else {
+ ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
+ if (cg != null) {
+ Contract contract=cg.generate(model.getProtocol(), null, new Role(m_role), journal);
+
+ if (contract != null) {
+ checkResults(result, contract.toString());
+ } else {
+ result.addError(this, new Throwable("No contract"));
+ }
+ }
+ }
+ }
+
+ 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) {
+ boolean f_valid=false;
+
+ String filename="results/contract/"+m_name+"@"+m_role+".contract";
+
+ java.io.InputStream is=
+ //ChoreographyToBPELTester.class.getResourceAsStream(filename);
+ ClassLoader.getSystemResourceAsStream(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 Contract does not match stored version"));
+ } else {
+ f_valid = true;
+ }
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("Resulting Contract '"+filename+
+ "' not found for comparison"));
+ }
+
+ if (f_valid == false) {
+ String srcfile="testmodels/protocol/"+m_name+".spr";
+
+ java.net.URL url=ClassLoader.getSystemResource(srcfile);
+
+ /*
+ try {
+ url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ */
+
+ if (url != null) {
+ // URL will point to copy of test models in the classes folder, so need
+ // to obtain reference back to source version
+ java.io.File f=null;
+
+ if (url.getFile().indexOf("target/test-classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("target/test-classes","src/test/resources"));
+ } else if (url.getFile().indexOf("target/classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("target/classes","src/test/resources"));
+ } else if (url.getFile().indexOf("classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("classes","src/test/resources"));
+ } else if (url.getFile().indexOf("bin") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("bin","src/test/resources"));
+ } else {
+ result.addError(this, new Exception("Could not locate results folder to record expected result"));
+ }
+
+ if (f != null && f.exists()) {
+ f = f.getParentFile().getParentFile().getParentFile();
+
+ java.io.File resultsDir=new java.io.File(f, "results/contract");
+
+ if (resultsDir.exists() == false) {
+ resultsDir.mkdirs();
+ }
+
+ java.io.File resultFile=new java.io.File(resultsDir,
+ m_name+"@"+m_role+".generated");
+
+ //if (resultFile.exists() == false) {
+ try {
+ java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+
+ fos.write(bpel.getBytes());
+
+ fos.flush();
+ fos.close();
+
+ } catch(Exception e){
+ result.addError(this, e);
+ }
+ /*
+ } else {
+ System.err.println("NOTE: Generated output '"+resultFile+
+ "' already exists - not being overwritten");
+ }
+ */
+ } else {
+ result.addError(this, new Throwable("Unable to obtain URL for model source '"+
+ m_name+"': "+url));
+ }
+ }
+ }
+ }
+
+ private String m_name=null;
+ private String m_role=null;
+ }
+}
Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at CreditCheckService.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at CreditCheckService.contract (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at CreditCheckService.contract 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,10 @@
+Contract {http://creditagency.com/creditCheckService}CreditCheckService {
+ Namespace prefix=cred uri=http://creditagency.com/creditCheck schemaLocation=schema/creditCheck.xsd
+ TypeDef CreditCheckRequest type={http://creditagency.com/creditCheck}creditCheckRequest location=null typeSystem=xsd
+ TypeDef CreditCheckResponse type={http://creditagency.com/creditCheck}creditCheckResponse location=null typeSystem=xsd
+ Interface {http://creditagency.com/creditCheckService}CreditCheckService {
+ OneWayRequestMEP label0( )
+ RequestResponseMEP checkCredit( CreditCheckRequest ) : CreditCheckResponse
+ OneWayRequestMEP label1( )
+ }
+}
Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at PolicyQuoteProcessService.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at PolicyQuoteProcessService.contract (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PolicyQuote at PolicyQuoteProcessService.contract 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,14 @@
+Contract {http://www.example.org/policyQuoteProcessService}PolicyQuoteProcessService {
+ Namespace prefix=drv uri=http://dmv.com/drivingRecord schemaLocation=schema/drivingRecord.xsd
+ Namespace prefix=pol uri=http://www.example.org/policyQuote schemaLocation=schema/policyQuote.xsd
+ TypeDef DrivingRecordResponse type={http://dmv.com/drivingRecord}drivingRecordResponse location=null typeSystem=xsd
+ TypeDef PolicyQuote type={http://www.example.org/policyQuote}policyQuote location=null typeSystem=xsd
+ TypeDef PolicyQuoteFault type={http://www.example.org/policyQuote}policyQuoteFault location=null typeSystem=xsd
+ TypeDef PolicyQuoteReply type={http://www.example.org/policyQuote}policyQuoteReply location=null typeSystem=xsd
+ Interface {http://www.example.org/policyQuoteProcessService}PolicyQuoteProcessService {
+ RequestResponseMEP receivePolicyQuote( PolicyQuote ) : PolicyQuoteReply Fault policyQuoteFault( PolicyQuoteFault )
+ OneWayRequestMEP receiveDrivingRecord( DrivingRecordResponse )
+ OneWayRequestMEP label0( )
+ OneWayRequestMEP label1( )
+ }
+}
Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at CreditAgency.contract 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,4 +1,5 @@
Contract {java:org.jboss.savara.examples.purchasing}CreditAgency {
+ Namespace prefix=pur uri=java:org.jboss.savara.examples.purchasing schemaLocation=null
TypeDef CreditCheckInvalid type={java:org.jboss.savara.examples.purchasing}CreditCheckInvalid location=null typeSystem=xsd
TypeDef CreditCheckOk type={java:org.jboss.savara.examples.purchasing}CreditCheckOk location=null typeSystem=xsd
TypeDef CreditCheckRequest type={java:org.jboss.savara.examples.purchasing}CreditCheckRequest location=null typeSystem=xsd
Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/results/contract/PurchaseGoods at Store.contract 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,4 +1,5 @@
Contract {http://www.jboss.org/examples/store}Store {
+ Namespace prefix=sto uri=http://www.jboss.org/examples/store schemaLocation=null
TypeDef BuyConfirmed type={http://www.jboss.org/examples/store}BuyConfirmed location=null typeSystem=xsd
TypeDef BuyFailed type={http://www.jboss.org/examples/store}BuyFailed location=null typeSystem=xsd
TypeDef BuyRequest type={http://www.jboss.org/examples/store}BuyRequest location=null typeSystem=xsd
Added: branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PolicyQuote.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PolicyQuote.spr (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.protocol/src/test/resources/testmodels/protocol/PolicyQuote.spr 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,70 @@
+import xsd "{http://creditagency.com/creditCheck}creditCheckRequest" as CreditCheckRequest, "{http://creditagency.com/creditCheck}creditCheckResponse" as CreditCheckResponse from "http://creditagency.com/creditCheck";
+import xsd "{http://dmv.com/drivingRecord}drivingRecordRequest" as DrivingRecordRequest, "{http://dmv.com/drivingRecord}drivingRecordResponse" as DrivingRecordResponse from "http://dmv.com/drivingRecord";
+import xsd "{http://www.w3.org/2001/XMLSchema}string" as IDSSNType, "{http://www.w3.org/2001/XMLSchema}anyURI" as URITokenType from "http://www.w3.org/2001/XMLSchema";
+import xsd "{http://www.example.org/policyQuote}policyQuote" as PolicyQuote, "{http://www.example.org/policyQuote}policyQuoteFault" as PolicyQuoteFault, "{http://www.example.org/policyQuote}policyQuoteReply" as PolicyQuoteReply from "http://www.example.org/policyQuote";
+[[ SourceComponent(id=//@choreographies.0) ]]
+[[ Namespace(name=http://www.pi4soa.org/PolicyQuote,role=Driver) ]]
+[[ Namespace(name=http://creditagency.com/creditCheckService,role=CreditCheckService) ]]
+[[ Namespace(name=http://dmv.com/drivingRecordService,role=DrivingRecordService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteCalculationService,role=PolicyQuoteCalculationService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteEntityService,role=PolicyQuoteEntityService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteProcessService,role=PolicyQuoteProcessService) ]]
+[[ Type(prefix=tns,namespace=http://www.pi4soa.org/PolicyQuote) ]]
+[[ Type(prefix=xsd,namespace=http://www.w3.org/2001/XMLSchema) ]]
+[[ Type(location=schema/policyQuote.xsd,prefix=pol,namespace=http://www.example.org/policyQuote) ]]
+[[ Type(location=schema/drivingRecord.xsd,prefix=drv,namespace=http://dmv.com/drivingRecord) ]]
+[[ Type(location=schema/creditCheck.xsd,prefix=cred,namespace=http://creditagency.com/creditCheck) ]]
+[[ Type(prefix=pps,namespace=http://www.example.org/policyQuoteProcessService) ]]
+[[ Type(prefix=pcs,namespace=http://www.example.org/policyQuoteCalculationService) ]]
+[[ Type(prefix=pes,namespace=http://www.example.org/policyQuoteEntityService) ]]
+[[ Type(prefix=dmv,namespace=http://dmv.com/drivingRecordService) ]]
+[[ Type(prefix=ca,namespace=http://creditagency.com/creditCheckService) ]]
+protocol PolicyQuoteProcess {
+ role Driver, CreditCheckService, DrivingRecordService, PolicyQuoteCalculationService, PolicyQuoteEntityService, PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.0/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteProcessService) ]]
+ [[ Correlation(request=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuote) from Driver to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.1/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}DrivingRecordService) ]]
+ checkDrivingRecord(DrivingRecordRequest) from PolicyQuoteProcessService to DrivingRecordService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.2/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}DrivingRecordCallbackService) ]]
+ receiveDrivingRecord(DrivingRecordResponse) from DrivingRecordService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3) ]]
+ choice {
+ label0():
+ [[ Correlation(request=checkCredit) ]]
+ checkCredit(CreditCheckRequest) from PolicyQuoteProcessService to CreditCheckService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.0/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}CreditCheckService) ]]
+ [[ Correlation(replyTo=checkCredit) ]]
+ checkCredit(CreditCheckResponse) from CreditCheckService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.1/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteCalculationService) ]]
+ [[ Correlation(request=calculatePolicyQuote) ]]
+ calculatePolicyQuote(PolicyQuote) from PolicyQuoteProcessService to PolicyQuoteCalculationService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.1/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteCalculationService) ]]
+ [[ Correlation(replyTo=calculatePolicyQuote) ]]
+ calculatePolicyQuote(PolicyQuoteReply) from PolicyQuoteCalculationService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.2/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteEntityService) ]]
+ [[ Correlation(request=createPolicyQuote) ]]
+ createPolicyQuote(PolicyQuote) from PolicyQuoteProcessService to PolicyQuoteEntityService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.2/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteEntityService) ]]
+ [[ Correlation(replyTo=createPolicyQuote) ]]
+ createPolicyQuote(PolicyQuoteReply) from PolicyQuoteEntityService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.3/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteProcessService) ]]
+ [[ Correlation(replyTo=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuoteReply) from PolicyQuoteProcessService to Driver;
+
+ label1():
+ [[ Fault(name=policyQuoteFault) ]]
+ [[ Correlation(replyTo=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuoteFault) from PolicyQuoteProcessService to Driver;
+
+ }
+}
Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -27,6 +27,7 @@
import org.savara.common.model.annotation.AnnotationDefinitions;
import org.savara.contract.model.FaultDetails;
import org.savara.contract.model.Interface;
+import org.savara.contract.model.MessageExchangePattern;
import org.savara.contract.model.Namespace;
import org.savara.contract.model.RequestResponseMEP;
import org.savara.contract.model.Type;
@@ -217,8 +218,14 @@
}
for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
- createOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i), wsdlBinding);
+
+ // Only create operations for meps with type parameters
+ MessageExchangePattern mep=intf.getMessageExchangePatterns().get(i);
+
+ if (mep.getTypes().size() > 0) {
+ createOperation(wsdls, contract, ret,
+ mep, wsdlBinding);
+ }
}
// Only add portType to definition if they have atleast one operation
@@ -268,8 +275,13 @@
ret.setPortType(portType);
for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
- createBindingOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i), wsdlBinding);
+ // Only create operations for meps with type parameters
+ MessageExchangePattern mep=intf.getMessageExchangePatterns().get(i);
+
+ if (mep.getTypes().size() > 0) {
+ createBindingOperation(wsdls, contract, ret,
+ mep, wsdlBinding);
+ }
}
// Only add portType to definition if they have atleast one operation
Deleted: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/GeneratorTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/GeneratorTest.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/GeneratorTest.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,260 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.wsdl.generator;
-
-import javax.wsdl.Definition;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-import org.savara.contract.model.Contract;
-import org.scribble.common.logging.CachedJournal;
-import org.scribble.protocol.model.Role;
-import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
-import org.savara.protocol.contract.generator.ContractGenerator;
-import org.savara.protocol.contract.generator.ContractGeneratorFactory;
-import org.savara.wsdl.generator.soap.SOAPRPCWSDLBinding;
-
-public class GeneratorTest {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Protocol->WSDL Generator Tests");
-
- suite.addTest(new ProtocolToWSDLTester("ESBBroker", "Broker"));
- suite.addTest(new ProtocolToWSDLTester("ESBBroker", "Buyer"));
- suite.addTest(new ProtocolToWSDLTester("ESBBroker", "SupplierTxnProcessor"));
- suite.addTest(new ProtocolToWSDLTester("ESBBroker", "CreditAgency"));
- suite.addTest(new ProtocolToWSDLTester("ESBBroker", "SupplierQuoteEngine"));
-
- suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "Buyer"));
- suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "CreditAgency"));
- suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "Store"));
-
- suite.addTest(new ProtocolToWSDLTester("ReqRespFault", "Buyer"));
- suite.addTest(new ProtocolToWSDLTester("ReqRespFault", "Seller"));
-
- return suite;
- }
-
- protected static class ProtocolToWSDLTester extends TestCase {
-
- /**
- * This constructor is initialized with the test
- * name.
- *
- * @param name The test name
- * @param role The role
- */
- public ProtocolToWSDLTester(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) {
-
- // Run test
- result.startTest(this);
-
- String filename="testmodels/contract/"+m_name+".spr";
-
- java.io.InputStream is=
- ClassLoader.getSystemResourceAsStream(filename);
-
- if (is == null) {
- result.addError(this,
- new Throwable("Unable to locate resource: "+filename));
- } else {
- CachedJournal journal=new CachedJournal();
-
- org.scribble.protocol.model.ProtocolModel model=null;
-
- ANTLRProtocolParser parser=new ANTLRProtocolParser();
- parser.setAnnotationProcessor(new org.savara.protocol.parser.AnnotationProcessor());
-
- try {
- model = parser.parse(is, journal, null);
- } catch(Exception e) {
- result.addError(this, new Throwable("Parsing choreography failed"));
- }
-
- if (model == null) {
- result.addError(this, new Throwable("Model is null"));
- } else {
- ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
- if (cg != null) {
- Contract contract=cg.generate(model.getProtocol(), null, new Role(m_role), journal);
-
- if (contract != null) {
-
- // Convert to WSDL
- WSDLGenerator gen=WSDLGeneratorFactory.getWSDLGenerator();
-
- java.util.List<Definition> defns=gen.generate(contract, new SOAPRPCWSDLBinding());
-
- for (int i=0; i < defns.size(); i++) {
- Definition defn=defns.get(i);
-
- try {
- javax.wsdl.xml.WSDLWriter writer=
- javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
-
- java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
-
- writer.writeWSDL(defn, baos);
-
- byte[] b=baos.toByteArray();
-
- baos.close();
-
- checkResults(result, new String(b), "rpc", i);
- } catch(Exception e) {
- result.addError(this, e);
- }
- }
- } else {
- result.addError(this, new Throwable("No contract"));
- }
- }
- }
- }
-
- 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 wsdl, String binding, int num) {
- boolean f_valid=false;
-
- String filename="results/wsdl/"+m_name+"_"+m_role+"_"+binding+"_"+num+".wsdl";
-
- java.io.InputStream is=
- ClassLoader.getSystemResourceAsStream(filename);
-
- if (is != null) {
-
- try {
- byte[] b=new byte[is.available()];
-
- is.read(b);
-
- is.close();
-
- String orig=new String(b);
-
- if (orig.equals(wsdl) == false) {
- result.addError(this,
- new Throwable("Generated WSDL does not match stored version"));
- } else {
- f_valid = true;
- }
- } catch(Exception e) {
- result.addError(this, e);
- }
- } else {
- result.addError(this,
- new Throwable("Resulting WSDL '"+filename+
- "' not found for comparison"));
- }
-
- if (f_valid == false) {
- String srcfile="testmodels/contract/"+m_name+".spr";
-
- java.net.URL url=ClassLoader.getSystemResource(srcfile);
-
- /*
- try {
- url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
- } catch(Exception e) {
- e.printStackTrace();
- }
- */
-
- if (url != null) {
- // URL will point to copy of test models in the classes folder, so need
- // to obtain reference back to source version
- java.io.File f=null;
-
- if (url.getFile().indexOf("target/test-classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("target/test-classes","src/test/resources"));
- } else if (url.getFile().indexOf("target/classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("target/classes","src/test/resources"));
- } else if (url.getFile().indexOf("classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("classes","src/test/resources"));
- } else if (url.getFile().indexOf("bin") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("bin","src/test/resources"));
- } else {
- result.addError(this, new Exception("Could not locate results folder to record expected result"));
- }
-
- if (f != null && f.exists()) {
- f = f.getParentFile().getParentFile().getParentFile();
-
- java.io.File resultsDir=new java.io.File(f, "results/wsdl");
-
- if (resultsDir.exists() == false) {
- resultsDir.mkdirs();
- }
-
- java.io.File resultFile=new java.io.File(resultsDir,
- m_name+"_"+m_role+"_"+binding+"_"+num+".generated");
-
- //if (resultFile.exists() == false) {
- try {
- java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
-
- fos.write(wsdl.getBytes());
-
- fos.flush();
- fos.close();
-
- } catch(Exception e){
- result.addError(this, e);
- }
- /*
- } else {
- System.err.println("NOTE: Generated output '"+resultFile+
- "' already exists - not being overwritten");
- }
- */
- } else {
- result.addError(this, new Throwable("Unable to obtain URL for model source '"+
- m_name+"': "+url));
- }
- }
- }
- }
-
- private String m_name=null;
- private String m_role=null;
- }
-}
Copied: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/ProtocolToWSDLGeneratorTest.java (from rev 639, branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/GeneratorTest.java)
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/ProtocolToWSDLGeneratorTest.java (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/java/org/savara/wsdl/generator/ProtocolToWSDLGeneratorTest.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.wsdl.generator;
+
+import javax.wsdl.Definition;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.savara.contract.model.Contract;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.protocol.model.Role;
+import org.scribble.protocol.parser.antlr.ANTLRProtocolParser;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
+import org.savara.wsdl.generator.soap.SOAPRPCWSDLBinding;
+
+public class ProtocolToWSDLGeneratorTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Protocol->WSDL Generator Tests");
+
+ suite.addTest(new ProtocolToWSDLTester("PolicyQuote", "CreditCheckService"));
+ suite.addTest(new ProtocolToWSDLTester("PolicyQuote", "PolicyQuoteProcessService"));
+
+ suite.addTest(new ProtocolToWSDLTester("ESBBroker", "Broker"));
+ suite.addTest(new ProtocolToWSDLTester("ESBBroker", "Buyer"));
+ suite.addTest(new ProtocolToWSDLTester("ESBBroker", "SupplierTxnProcessor"));
+ suite.addTest(new ProtocolToWSDLTester("ESBBroker", "CreditAgency"));
+ suite.addTest(new ProtocolToWSDLTester("ESBBroker", "SupplierQuoteEngine"));
+
+ suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "Buyer"));
+ suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "CreditAgency"));
+ suite.addTest(new ProtocolToWSDLTester("PurchaseGoods", "Store"));
+
+ suite.addTest(new ProtocolToWSDLTester("ReqRespFault", "Buyer"));
+ suite.addTest(new ProtocolToWSDLTester("ReqRespFault", "Seller"));
+
+ return suite;
+ }
+
+ protected static class ProtocolToWSDLTester extends TestCase {
+
+ /**
+ * This constructor is initialized with the test
+ * name.
+ *
+ * @param name The test name
+ * @param role The role
+ */
+ public ProtocolToWSDLTester(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) {
+
+ // Run test
+ result.startTest(this);
+
+ String filename="testmodels/contract/"+m_name+".spr";
+
+ java.io.InputStream is=
+ ClassLoader.getSystemResourceAsStream(filename);
+
+ if (is == null) {
+ result.addError(this,
+ new Throwable("Unable to locate resource: "+filename));
+ } else {
+ CachedJournal journal=new CachedJournal();
+
+ org.scribble.protocol.model.ProtocolModel model=null;
+
+ ANTLRProtocolParser parser=new ANTLRProtocolParser();
+ parser.setAnnotationProcessor(new org.savara.protocol.parser.AnnotationProcessor());
+
+ try {
+ model = parser.parse(is, journal, null);
+ } catch(Exception e) {
+ result.addError(this, new Throwable("Parsing choreography failed"));
+ }
+
+ if (model == null) {
+ result.addError(this, new Throwable("Model is null"));
+ } else {
+ ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
+ if (cg != null) {
+ Contract contract=cg.generate(model.getProtocol(), null, new Role(m_role), journal);
+
+ if (contract != null) {
+
+ // Convert to WSDL
+ WSDLGenerator gen=WSDLGeneratorFactory.getWSDLGenerator();
+
+ java.util.List<Definition> defns=gen.generate(contract, new SOAPRPCWSDLBinding());
+
+ for (int i=0; i < defns.size(); i++) {
+ Definition defn=defns.get(i);
+
+ try {
+ javax.wsdl.xml.WSDLWriter writer=
+ javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+
+ java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
+
+ writer.writeWSDL(defn, baos);
+
+ byte[] b=baos.toByteArray();
+
+ baos.close();
+
+ checkResults(result, new String(b), "rpc", i);
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ }
+ } else {
+ result.addError(this, new Throwable("No contract"));
+ }
+ }
+ }
+ }
+
+ 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 wsdl, String binding, int num) {
+ boolean f_valid=false;
+
+ String filename="results/wsdl/"+m_name+"_"+m_role+"_"+binding+"_"+num+".wsdl";
+
+ java.io.InputStream is=
+ ClassLoader.getSystemResourceAsStream(filename);
+
+ if (is != null) {
+
+ try {
+ byte[] b=new byte[is.available()];
+
+ is.read(b);
+
+ is.close();
+
+ String orig=new String(b);
+
+ if (orig.equals(wsdl) == false) {
+ result.addError(this,
+ new Throwable("Generated WSDL does not match stored version"));
+ } else {
+ f_valid = true;
+ }
+ } catch(Exception e) {
+ result.addError(this, e);
+ }
+ } else {
+ result.addError(this,
+ new Throwable("Resulting WSDL '"+filename+
+ "' not found for comparison"));
+ }
+
+ if (f_valid == false) {
+ String srcfile="testmodels/contract/"+m_name+".spr";
+
+ java.net.URL url=ClassLoader.getSystemResource(srcfile);
+
+ /*
+ try {
+ url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ */
+
+ if (url != null) {
+ // URL will point to copy of test models in the classes folder, so need
+ // to obtain reference back to source version
+ java.io.File f=null;
+
+ if (url.getFile().indexOf("target/test-classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("target/test-classes","src/test/resources"));
+ } else if (url.getFile().indexOf("target/classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("target/classes","src/test/resources"));
+ } else if (url.getFile().indexOf("classes") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("classes","src/test/resources"));
+ } else if (url.getFile().indexOf("bin") != -1) {
+ f = new java.io.File(url.getFile().replaceFirst("bin","src/test/resources"));
+ } else {
+ result.addError(this, new Exception("Could not locate results folder to record expected result"));
+ }
+
+ if (f != null && f.exists()) {
+ f = f.getParentFile().getParentFile().getParentFile();
+
+ java.io.File resultsDir=new java.io.File(f, "results/wsdl");
+
+ if (resultsDir.exists() == false) {
+ resultsDir.mkdirs();
+ }
+
+ java.io.File resultFile=new java.io.File(resultsDir,
+ m_name+"_"+m_role+"_"+binding+"_"+num+".generated");
+
+ //if (resultFile.exists() == false) {
+ try {
+ java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+
+ fos.write(wsdl.getBytes());
+
+ fos.flush();
+ fos.close();
+
+ } catch(Exception e){
+ result.addError(this, e);
+ }
+ /*
+ } else {
+ System.err.println("NOTE: Generated output '"+resultFile+
+ "' already exists - not being overwritten");
+ }
+ */
+ } else {
+ result.addError(this, new Throwable("Unable to obtain URL for model source '"+
+ m_name+"': "+url));
+ }
+ }
+ }
+ }
+
+ private String m_name=null;
+ private String m_role=null;
+ }
+}
Added: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_CreditCheckService_rpc_0.wsdl
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_CreditCheckService_rpc_0.wsdl (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_CreditCheckService_rpc_0.wsdl 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="CreditCheckService" targetNamespace="http://creditagency.com/creditCheckService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://creditagency.com/creditCheckService" xmlns:cred="http://creditagency.com/creditCheck" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:message name="checkCreditRequest">
+ <wsdl:part name="content" type="cred:creditCheckRequest">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="checkCreditResponse">
+ <wsdl:part name="content" type="cred:creditCheckResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CreditCheckService">
+ <wsdl:operation name="checkCredit">
+ <wsdl:input message="tns:checkCreditRequest">
+ </wsdl:input>
+ <wsdl:output message="tns:checkCreditResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CreditCheckServiceBinding" type="tns:CreditCheckService">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="checkCredit">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://creditagency.com/creditCheckService"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://creditagency.com/creditCheckService"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CreditCheckServiceService">
+ <wsdl:port name="CreditCheckServicePort" binding="tns:CreditCheckServiceBinding">
+ <soap:address location="http://localhost:8080/CreditCheckServiceService/CreditCheckServicePort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_PolicyQuoteProcessService_rpc_0.wsdl
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_PolicyQuoteProcessService_rpc_0.wsdl (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PolicyQuote_PolicyQuoteProcessService_rpc_0.wsdl 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="PolicyQuoteProcessService" targetNamespace="http://www.example.org/policyQuoteProcessService" xmlns:drv="http://dmv.com/drivingRecord" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.example.org/policyQuoteProcessService" xmlns:pol="http://www.example.org/policyQuote" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:message name="policyQuoteFaultFault">
+ <wsdl:part name="content" type="pol:policyQuoteFault">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="receivePolicyQuoteResponse">
+ <wsdl:part name="content" type="pol:policyQuoteReply">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="receivePolicyQuoteRequest">
+ <wsdl:part name="content" type="pol:policyQuote">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="receiveDrivingRecordRequest">
+ <wsdl:part name="content" type="drv:drivingRecordResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="PolicyQuoteProcessService">
+ <wsdl:operation name="receivePolicyQuote">
+ <wsdl:input message="tns:receivePolicyQuoteRequest">
+ </wsdl:input>
+ <wsdl:output message="tns:receivePolicyQuoteResponse">
+ </wsdl:output>
+ <wsdl:fault name="policyQuoteFault" message="tns:policyQuoteFaultFault">
+ </wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="receiveDrivingRecord">
+ <wsdl:input message="tns:receiveDrivingRecordRequest">
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="PolicyQuoteProcessServiceBinding" type="tns:PolicyQuoteProcessService">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="receivePolicyQuote">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://www.example.org/policyQuoteProcessService"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://www.example.org/policyQuoteProcessService"/>
+ </wsdl:output>
+ <wsdl:fault name="policyQuoteFault">
+ <soap:fault name="policyQuoteFault" use="literal" namespace="http://www.example.org/policyQuoteProcessService"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="receiveDrivingRecord">
+ <soap:operation soapAction="" style="rpc"/>
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://www.example.org/policyQuoteProcessService"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="PolicyQuoteProcessServiceService">
+ <wsdl:port name="PolicyQuoteProcessServicePort" binding="tns:PolicyQuoteProcessServiceBinding">
+ <soap:address location="http://localhost:8080/PolicyQuoteProcessServiceService/PolicyQuoteProcessServicePort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_CreditAgency_rpc_0.wsdl
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_CreditAgency_rpc_0.wsdl 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_CreditAgency_rpc_0.wsdl 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions name="CreditAgency" targetNamespace="java:org.jboss.savara.examples.purchasing" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="java:org.jboss.savara.examples.purchasing" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+<wsdl:definitions name="CreditAgency" targetNamespace="java:org.jboss.savara.examples.purchasing" xmlns:pur="java:org.jboss.savara.examples.purchasing" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="java:org.jboss.savara.examples.purchasing" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:message name="checkCreditRequest">
- <wsdl:part name="content" type="tns:CreditCheckRequest">
+ <wsdl:part name="content" type="pur:CreditCheckRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="CreditCheckFailedFault">
- <wsdl:part name="content" type="tns:CreditCheckInvalid">
+ <wsdl:part name="content" type="pur:CreditCheckInvalid">
</wsdl:part>
</wsdl:message>
<wsdl:message name="checkCreditResponse">
- <wsdl:part name="content" type="tns:CreditCheckOk">
+ <wsdl:part name="content" type="pur:CreditCheckOk">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CreditAgency">
<wsdl:operation name="checkCredit">
- <wsdl:input message="tns:checkCreditRequest">
+ <wsdl:input message="pur:checkCreditRequest">
</wsdl:input>
- <wsdl:output message="tns:checkCreditResponse">
+ <wsdl:output message="pur:checkCreditResponse">
</wsdl:output>
- <wsdl:fault name="CreditCheckFailed" message="tns:CreditCheckFailedFault">
+ <wsdl:fault name="CreditCheckFailed" message="pur:CreditCheckFailedFault">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="CreditAgencyBinding" type="tns:CreditAgency">
+ <wsdl:binding name="CreditAgencyBinding" type="pur:CreditAgency">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="checkCredit">
<soap:operation soapAction="" style="rpc"/>
@@ -38,7 +38,7 @@
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CreditAgencyService">
- <wsdl:port name="CreditAgencyPort" binding="tns:CreditAgencyBinding">
+ <wsdl:port name="CreditAgencyPort" binding="pur:CreditAgencyBinding">
<soap:address location="http://localhost:8080/CreditAgencyService/CreditAgencyPort"/>
</wsdl:port>
</wsdl:service>
Modified: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_Store_rpc_0.wsdl
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_Store_rpc_0.wsdl 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/results/wsdl/PurchaseGoods_Store_rpc_0.wsdl 2011-02-09 23:15:27 UTC (rev 645)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions name="Store" targetNamespace="http://www.jboss.org/examples/store" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.jboss.org/examples/store" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+<wsdl:definitions name="Store" targetNamespace="http://www.jboss.org/examples/store" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.jboss.org/examples/store" xmlns:sto="http://www.jboss.org/examples/store" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:message name="BuyFailedFault">
<wsdl:part name="content" type="tns:BuyFailed">
</wsdl:part>
Added: branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/testmodels/contract/PolicyQuote.spr
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/testmodels/contract/PolicyQuote.spr (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.wsdl/src/test/resources/testmodels/contract/PolicyQuote.spr 2011-02-09 23:15:27 UTC (rev 645)
@@ -0,0 +1,70 @@
+import xsd "{http://creditagency.com/creditCheck}creditCheckRequest" as CreditCheckRequest, "{http://creditagency.com/creditCheck}creditCheckResponse" as CreditCheckResponse from "http://creditagency.com/creditCheck";
+import xsd "{http://dmv.com/drivingRecord}drivingRecordRequest" as DrivingRecordRequest, "{http://dmv.com/drivingRecord}drivingRecordResponse" as DrivingRecordResponse from "http://dmv.com/drivingRecord";
+import xsd "{http://www.w3.org/2001/XMLSchema}string" as IDSSNType, "{http://www.w3.org/2001/XMLSchema}anyURI" as URITokenType from "http://www.w3.org/2001/XMLSchema";
+import xsd "{http://www.example.org/policyQuote}policyQuote" as PolicyQuote, "{http://www.example.org/policyQuote}policyQuoteFault" as PolicyQuoteFault, "{http://www.example.org/policyQuote}policyQuoteReply" as PolicyQuoteReply from "http://www.example.org/policyQuote";
+[[ SourceComponent(id=//@choreographies.0) ]]
+[[ Namespace(name=http://www.pi4soa.org/PolicyQuote,role=Driver) ]]
+[[ Namespace(name=http://creditagency.com/creditCheckService,role=CreditCheckService) ]]
+[[ Namespace(name=http://dmv.com/drivingRecordService,role=DrivingRecordService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteCalculationService,role=PolicyQuoteCalculationService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteEntityService,role=PolicyQuoteEntityService) ]]
+[[ Namespace(name=http://www.example.org/policyQuoteProcessService,role=PolicyQuoteProcessService) ]]
+[[ Type(prefix=tns,namespace=http://www.pi4soa.org/PolicyQuote) ]]
+[[ Type(prefix=xsd,namespace=http://www.w3.org/2001/XMLSchema) ]]
+[[ Type(location=schema/policyQuote.xsd,prefix=pol,namespace=http://www.example.org/policyQuote) ]]
+[[ Type(location=schema/drivingRecord.xsd,prefix=drv,namespace=http://dmv.com/drivingRecord) ]]
+[[ Type(location=schema/creditCheck.xsd,prefix=cred,namespace=http://creditagency.com/creditCheck) ]]
+[[ Type(prefix=pps,namespace=http://www.example.org/policyQuoteProcessService) ]]
+[[ Type(prefix=pcs,namespace=http://www.example.org/policyQuoteCalculationService) ]]
+[[ Type(prefix=pes,namespace=http://www.example.org/policyQuoteEntityService) ]]
+[[ Type(prefix=dmv,namespace=http://dmv.com/drivingRecordService) ]]
+[[ Type(prefix=ca,namespace=http://creditagency.com/creditCheckService) ]]
+protocol PolicyQuoteProcess {
+ role Driver, CreditCheckService, DrivingRecordService, PolicyQuoteCalculationService, PolicyQuoteEntityService, PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.0/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteProcessService) ]]
+ [[ Correlation(request=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuote) from Driver to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.1/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}DrivingRecordService) ]]
+ checkDrivingRecord(DrivingRecordRequest) from PolicyQuoteProcessService to DrivingRecordService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.2/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}DrivingRecordCallbackService) ]]
+ receiveDrivingRecord(DrivingRecordResponse) from DrivingRecordService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3) ]]
+ choice {
+ label0():
+ [[ Correlation(request=checkCredit) ]]
+ checkCredit(CreditCheckRequest) from PolicyQuoteProcessService to CreditCheckService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.0/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}CreditCheckService) ]]
+ [[ Correlation(replyTo=checkCredit) ]]
+ checkCredit(CreditCheckResponse) from CreditCheckService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.1/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteCalculationService) ]]
+ [[ Correlation(request=calculatePolicyQuote) ]]
+ calculatePolicyQuote(PolicyQuote) from PolicyQuoteProcessService to PolicyQuoteCalculationService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.1/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteCalculationService) ]]
+ [[ Correlation(replyTo=calculatePolicyQuote) ]]
+ calculatePolicyQuote(PolicyQuoteReply) from PolicyQuoteCalculationService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.2/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteEntityService) ]]
+ [[ Correlation(request=createPolicyQuote) ]]
+ createPolicyQuote(PolicyQuote) from PolicyQuoteProcessService to PolicyQuoteEntityService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.2/@exchangeDetails.1) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteEntityService) ]]
+ [[ Correlation(replyTo=createPolicyQuote) ]]
+ createPolicyQuote(PolicyQuoteReply) from PolicyQuoteEntityService to PolicyQuoteProcessService;
+ [[ SourceComponent(id=//@choreographies.0/@activities.3/@activities.0/@activities.0/@activities.3/@exchangeDetails.0) ]]
+ [[ Interface(name={http://www.pi4soa.org/PolicyQuote}PolicyQuoteProcessService) ]]
+ [[ Correlation(replyTo=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuoteReply) from PolicyQuoteProcessService to Driver;
+
+ label1():
+ [[ Fault(name=policyQuoteFault) ]]
+ [[ Correlation(replyTo=receivePolicyQuote) ]]
+ receivePolicyQuote(PolicyQuoteFault) from PolicyQuoteProcessService to Driver;
+
+ }
+}
Modified: branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java
===================================================================
--- branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java 2011-02-08 23:26:51 UTC (rev 644)
+++ branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/src/java/org/savara/tools/bpel/generator/Generator.java 2011-02-09 23:15:27 UTC (rev 645)
@@ -41,6 +41,8 @@
import org.savara.contract.model.Contract;
import org.savara.contract.model.Interface;
import org.savara.contract.model.Namespace;
+import org.savara.protocol.contract.generator.ContractGenerator;
+import org.savara.protocol.contract.generator.ContractGeneratorFactory;
import org.savara.tools.core.ScribbleServices;
import org.savara.wsdl.generator.WSDLGeneratorFactory;
import org.savara.wsdl.generator.soap.SOAPDocLitWSDLBinding;
@@ -253,14 +255,15 @@
Object target=generator.generate(local, journal, null);
if (target instanceof TProcess) {
- generateRoleProject(projectName, localRole, (TProcess)target, local, cdmResource);
+ generateRoleProject(projectName, localRole, (TProcess)target, local, cdmResource,
+ journal);
}
}
}
protected void generateRoleProject(String projectName, Role role,
TProcess bpelProcess, ProtocolModel localcm,
- IFile cdmResource) throws Exception {
+ IFile cdmResource, Journal journal) throws Exception {
final IProject proj=createProject(projectName);
@@ -305,12 +308,12 @@
new org.eclipse.core.runtime.NullProgressMonitor());
// Write the WSDL files
- generateWSDL(role, proj, localcm, cdmResource);
+ generateWSDL(role, proj, localcm, cdmResource, journal);
java.util.List<Role> roles=localcm.getProtocol().getRoles();
for (int i=0; i < roles.size(); i++) {
- generateWSDL(roles.get(i), proj, localcm, cdmResource);
+ generateWSDL(roles.get(i), proj, localcm, cdmResource, journal);
}
// Generate WSDL with partner link types
@@ -322,14 +325,20 @@
}
protected void generateWSDL(Role role, IProject proj, ProtocolModel localcm,
- IFile cdmResource) throws Exception {
+ IFile cdmResource, Journal journal) throws Exception {
- if (role.getProperties().containsKey(Contract.class.getName())) {
+ ContractGenerator cg=ContractGeneratorFactory.getContractGenerator();
+ Contract contract=null;
+
+ if (cg != null) {
+ contract=cg.generate(m_protocolModel.getProtocol(), null, role, journal);
+ }
+
+ if (contract != null) {
javax.wsdl.xml.WSDLWriter writer=
javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
org.savara.wsdl.generator.WSDLGenerator generator=
WSDLGeneratorFactory.getWSDLGenerator();
- Contract contract=(Contract)role.getProperties().get(Contract.class.getName());
// Generate BPEL folder
IPath bpelFolderPath=proj.getFullPath().append(
More information about the savara-commits
mailing list