From eb06796859bc8746cb3f25e065d3211fdadf2d6b Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 8 Feb 2009 10:34:50 +0000 Subject: re-org the modules git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@742040 13f79535-47bb-0310-9956-ffa450edef68 --- .../paymentprocess/PaymentProcessClientImpl.java | 38 +++++++++++ .../paymentprocess/PaymentProcessTestCase.java | 76 ++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java create mode 100644 sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java (limited to 'sandbox/travelsample/chapter-06/paymentprocess-contribution/test') diff --git a/sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java b/sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessClientImpl.java new file mode 100644 index 0000000000..8d9c2f918c --- /dev/null +++ b/sandbox/travelsample/chapter-06/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/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java b/sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java new file mode 100644 index 0000000000..f1b4bc6aba --- /dev/null +++ b/sandbox/travelsample/chapter-06/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java @@ -0,0 +1,76 @@ +/* + * 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.Ignore; +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 + @Ignore + public void testPaymentProcess() { + SCAClient client = (SCAClient) node; + PaymentProcess pp = client.getService(PaymentProcess.class, "PaymentProcessClient"); + System.out.println("Result = " + pp.makePayment("Fred", 100.00f)); + } + + @Test + //@Ignore + public void testWaitForInput() { + System.out.println("Press a key to end"); + try { + System.in.read(); + } catch (Exception ex) { + } + System.out.println("Shutting down"); + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node = null; + } + } + +} -- cgit v1.2.3