From 42d974da048da6f2f56f0d998633031b0e2be1bd Mon Sep 17 00:00:00 2001 From: slaws Date: Sat, 29 Aug 2009 18:11:35 +0000 Subject: Add project where we can configure policy for the credit card service git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@809182 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven-eclipse.xml | 8 ++ .../creditcard-payment-jaxb-policy/pom.xml | 144 +++++++++++++++++++++ .../creditcard/impl/CreditCardPaymentImpl.java | 46 +++++++ .../src/main/resources/CreditCardPayment.wsdl | 134 +++++++++++++++++++ .../main/resources/META-INF/sca-contribution.xml | 24 ++++ .../src/main/resources/creditcard.composite | 33 +++++ .../src/main/resources/definitions.xml | 36 ++++++ .../creditcard/CreditCardPaymentTestCase.java | 100 ++++++++++++++ 8 files changed, 525 insertions(+) create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/maven-eclipse.xml create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/pom.xml create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/java/com/tuscanyscatours/payment/creditcard/impl/CreditCardPaymentImpl.java create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/CreditCardPayment.wsdl create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/creditcard.composite create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/definitions.xml create mode 100644 sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/test/java/scatours/payment/creditcard/CreditCardPaymentTestCase.java (limited to 'sandbox/travelsample') diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/maven-eclipse.xml b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/maven-eclipse.xml new file mode 100644 index 0000000000..4ceebd71f7 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/maven-eclipse.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/pom.xml b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/pom.xml new file mode 100644 index 0000000000..80702cd0a4 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/pom.xml @@ -0,0 +1,144 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6-SNAPSHOT + + + 1.0-SNAPSHOT + scatours-contribution-creditcard-payment-jaxb-policy + Apache Tuscany SCA Tours Credit Card Payment Contribution JAXB Policy + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + + + java.net2 + java.net Maven 2.x Repository + http://download.java.net/maven/2 + + false + + + + + + ${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 + + + wsimport + generate-sources + + wsimport + + + com.tuscanyscatours.payment.creditcard + ${basedir}/src/main/resources + + + CreditCardPayment.wsdl + + ${project.build.directory}/jaxws-source + + false + true + + + + + + + diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/java/com/tuscanyscatours/payment/creditcard/impl/CreditCardPaymentImpl.java b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/java/com/tuscanyscatours/payment/creditcard/impl/CreditCardPaymentImpl.java new file mode 100644 index 0000000000..253fcbe674 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/java/com/tuscanyscatours/payment/creditcard/impl/CreditCardPaymentImpl.java @@ -0,0 +1,46 @@ +/* + * 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 com.tuscanyscatours.payment.creditcard.impl; + +import com.tuscanyscatours.payment.creditcard.CreditCardDetailsType; +import com.tuscanyscatours.payment.creditcard.CreditCardPayment; +import org.osoa.sca.annotations.Service; + +/** + * + */ +@Service(CreditCardPayment.class) +public class CreditCardPaymentImpl implements CreditCardPayment { + + public String authorize(CreditCardDetailsType creditCard, float amount) { + if (creditCard != null){ + System.out.println("Checking card: name = " + + creditCard.getCardOwner().getName() + + " number = " + + creditCard.getCreditCardNumber() + + " for amount " + + amount); + } else { + System.out.println("Checking card is null"); + } + + return "OK"; + } +} diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/CreditCardPayment.wsdl b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/CreditCardPayment.wsdl new file mode 100644 index 0000000000..f313043bf8 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/CreditCardPayment.wsdl @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3b889caefd --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/creditcard.composite b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/creditcard.composite new file mode 100644 index 0000000000..e594f677d8 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/creditcard.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/definitions.xml b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/definitions.xml new file mode 100644 index 0000000000..5a2c58eaed --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/main/resources/definitions.xml @@ -0,0 +1,36 @@ + + + + + + + + myname + mypassword + + + + \ No newline at end of file diff --git a/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/test/java/scatours/payment/creditcard/CreditCardPaymentTestCase.java b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/test/java/scatours/payment/creditcard/CreditCardPaymentTestCase.java new file mode 100644 index 0000000000..fb989ae897 --- /dev/null +++ b/sandbox/travelsample/contributions/creditcard-payment-jaxb-policy/src/test/java/scatours/payment/creditcard/CreditCardPaymentTestCase.java @@ -0,0 +1,100 @@ +/* + * 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.creditcard; + +import com.tuscanyscatours.payment.creditcard.AuthorizeFault_Exception; +import com.tuscanyscatours.payment.creditcard.CreditCardDetailsType; +import com.tuscanyscatours.payment.creditcard.CreditCardPayment; +import com.tuscanyscatours.payment.creditcard.CreditCardTypeType; +import com.tuscanyscatours.payment.creditcard.ObjectFactory; +import com.tuscanyscatours.payment.creditcard.PayerType; + +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.Ignore; +import org.junit.Test; + +/** + * + */ +public class CreditCardPaymentTestCase { + private static SCANode node; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + try { + node = SCANodeFactory.newInstance().createSCANode(null, + new SCAContribution("creditcard", "./target/classes")); + + node.start(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @Test + public void testCreditCardPayment() { + SCAClient client = (SCAClient) node; + CreditCardPayment cc = client.getService(CreditCardPayment.class, "CreditCardPayment"); + + ObjectFactory objectFactory = new ObjectFactory(); + CreditCardDetailsType ccDetails = objectFactory.createCreditCardDetailsType(); + ccDetails.setCreditCardType(CreditCardTypeType.fromValue("Visa")); + PayerType ccOwner = objectFactory.createPayerType(); + ccOwner.setName("Fred"); + ccDetails.setCardOwner(ccOwner); + + try { + System.out.println(cc.authorize(ccDetails, 100.00f)); + } catch (AuthorizeFault_Exception e) { + System.err.println("Fault: " + e.getFaultInfo().getErrorCode()); + } + } + + @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