From 4105b42e3460245f8f7b5178a4829408e2235353 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 17 Nov 2008 11:18:46 +0000 Subject: Start adding in a BPEL process for payment processing. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718221 13f79535-47bb-0310-9956-ffa450edef68 --- .../paymentprocess/PaymentProcessClientImpl.java | 38 +++++++++++++ .../paymentprocess/PaymentProcessTestCase.java | 63 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java create mode 100644 sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java (limited to 'sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess') diff --git a/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java new file mode 100644 index 0000000000..8d9c2f918c --- /dev/null +++ b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java @@ -0,0 +1,38 @@ +/* + * 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.paymentprocess; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * + */ +@Service(PaymentProcess.class) +public class PaymentProcessClientImpl implements PaymentProcess { + @Reference + protected PaymentProcess paymentProcess; + + public String makePayment(String customerId, float amount) { + // Delegate the external web service + return paymentProcess.makePayment(customerId, amount); + } + +} diff --git a/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java new file mode 100644 index 0000000000..793e1eb887 --- /dev/null +++ b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java @@ -0,0 +1,63 @@ +/* + * 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.paymentprocess; + +import org.apache.tuscany.sca.node.SCAClient; +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; + +/** + * + */ +public class PaymentProcessTestCase { + private static SCANode node; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANodeFromClassLoader("paymentprocesstest.composite", PaymentProcess.class.getClassLoader()); + node.start(); + } + + @Test + public void testPaymentProcess() { + SCAClient client = (SCAClient) node; + PaymentProcess pp = client.getService(PaymentProcess.class, "PaymentProcessClient"); + System.out.println(pp.makePayment("Fred", 100.00f)); + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node = null; + } + } + +} -- cgit v1.2.3