From 276568f71482569a401c26448b18f276434d7e31 Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 28 Mar 2010 12:36:56 +0000 Subject: Add jython version of the payment component. Just because we can. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@928390 13f79535-47bb-0310-9956-ffa450edef68 --- .../contributions/payment-python/build.xml | 40 +++++ .../contributions/payment-python/pom.xml | 162 +++++++++++++++++++++ .../src/main/resources/CreditCardPayment.wsdl | 116 +++++++++++++++ .../src/main/resources/EmailGateway.wsdl | 89 +++++++++++ .../main/resources/META-INF/sca-contribution.xml | 24 +++ .../payment-python/src/main/resources/Payment.wsdl | 83 +++++++++++ .../src/main/resources/payment.composite | 38 +++++ .../src/main/resources/payment/PaymentImpl.py | 26 ++++ .../java/scatours/payment/PaymentTestCase.java | 82 +++++++++++ .../payment/client/impl/PaymentClientImpl.java | 37 +++++ .../test/resources/META-INF/sca-contribution.xml | 23 +++ .../src/test/resources/payment-client.composite | 32 ++++ 12 files changed, 752 insertions(+) create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/build.xml create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/pom.xml create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/CreditCardPayment.wsdl create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/EmailGateway.wsdl create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/Payment.wsdl create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment.composite create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment/PaymentImpl.py create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/PaymentTestCase.java create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/payment-client.composite (limited to 'sca-java-1.x/trunk') diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/build.xml b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/build.xml new file mode 100644 index 0000000000..1c29162343 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/build.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/pom.xml b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/pom.xml new file mode 100644 index 0000000000..93c63ed973 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/pom.xml @@ -0,0 +1,162 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + scatours + 1.0-SNAPSHOT + ../../pom.xml + + 1.0-SNAPSHOT + scatours-contribution-payment-python + Apache Tuscany SCA Tours Payment Python Contribution + + + + + org.apache.tuscany.sca + tuscany-implementation-script + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-node-impl + ${tuscany.version} + test + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-source + + + + target/jaxws-source + + + + + + + org.codehaus.mojo + jaxws-maven-plugin + 1.12 + + + payment + generate-sources + + wsimport + + + com.tuscanyscatours.payment + ${basedir}/src/main/resources + + Payment.wsdl + + ${project.build.directory}/jaxws-source + ${project.build.directory}/jaxws-source/stale/payment.stale + false + true + + + + payment.creditcard + process-sources + + wsimport + + + com.tuscanyscatours.payment.creditcard + ${basedir}/src/main/resources + + CreditCardPayment.wsdl + + ${project.build.directory}/jaxws-source + ${project.build.directory}/jaxws-source/stale/creditcard.stale + false + true + + + + emailgateway + process-sources + + wsimport + + + com.tuscanyscatours.emailgateway + ${basedir}/src/main/resources + + EmailGateway.wsdl + + ${project.build.directory}/jaxws-source + ${project.build.directory}/jaxws-source/stale/emailgateway.stale + false + true + + + + + + + diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/CreditCardPayment.wsdl b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/CreditCardPayment.wsdl new file mode 100644 index 0000000000..1813c77436 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/CreditCardPayment.wsdl @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/EmailGateway.wsdl b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/EmailGateway.wsdl new file mode 100644 index 0000000000..a097d9b7e4 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/EmailGateway.wsdl @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..36e2990be1 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/Payment.wsdl b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/Payment.wsdl new file mode 100644 index 0000000000..2519d7642e --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/Payment.wsdl @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment.composite b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment.composite new file mode 100644 index 0000000000..a0de3e9d67 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + 0.02 + + diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment/PaymentImpl.py b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment/PaymentImpl.py new file mode 100644 index 0000000000..095c549789 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/main/resources/payment/PaymentImpl.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from com.tuscanyscatours.emailgateway import EmailType + +def makePaymentMember(customerId, amount): + finalAmount = amount + transactionFee; + print "Total amount = ", finalAmount + email = EmailType() + email.setTo(customerId) + emailGateway.sendEmail(email) + return "Success" diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/PaymentTestCase.java b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/PaymentTestCase.java new file mode 100644 index 0000000000..66f393b275 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/PaymentTestCase.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package scatours.payment; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.tuscanyscatours.payment.Payment; + +/** + * + */ +public class PaymentTestCase { + + private static SCANode paymentNode; + private static SCANode creditCardNode; + private static SCANode emailGatewayNode; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + creditCardNode = + SCANodeFactory.newInstance() + .createSCANode("creditcard.composite", + new SCAContribution("creditcard", "../creditcard-payment-jaxb/target/classes")); + + creditCardNode.start(); + + emailGatewayNode = + SCANodeFactory.newInstance().createSCANode("emailgateway.composite", + new SCAContribution("emailgateway", + "../emailgateway/target/classes"), + new SCAContribution("emailgateway-test", + "../emailgateway/target/test-classes")); + + emailGatewayNode.start(); + + paymentNode = + SCANodeFactory.newInstance().createSCANode(null, + new SCAContribution("payment-python", "./target/classes"), + new SCAContribution("payment-python-test", + "./target/test-classes")); + + paymentNode.start(); + } + + @Test + public void testPayment() { + SCAClient client = (SCAClient)paymentNode; + Payment payment = client.getService(Payment.class, "PaymentClient"); + System.out.println("Result = " + payment.makePaymentMember("Fred", 100.00f)); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + paymentNode.stop(); + creditCardNode.stop(); + emailGatewayNode.stop(); + } + +} diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java new file mode 100644 index 0000000000..4f64b20c4e --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package scatours.payment.client.impl; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.tuscanyscatours.payment.Payment; + +@Service(Payment.class) +public class PaymentClientImpl implements Payment { + @Reference + protected Payment payment; + + public String makePaymentMember(String customerId, float amount) { + // Delegate the external web service + return payment.makePaymentMember(customerId, amount); + } + +} diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/META-INF/sca-contribution.xml b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..378e09009b --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/payment-client.composite b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/payment-client.composite new file mode 100644 index 0000000000..353c1cea04 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/travelsample/contributions/payment-python/src/test/resources/payment-client.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + -- cgit v1.2.3