summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/contributions/payment-spring-policy/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-05 21:14:49 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-05 21:14:49 +0000
commit8c049462ff6387d8c3f69f4e42a4c4b36e38a90c (patch)
tree3e6b1ec1ab2e2a724d9228ca55052394c3034060 /sandbox/travelsample/contributions/payment-spring-policy/src
parent68c3920fc0ba41c6a9ebf062bd41e5ebf647e51b (diff)
Format the code
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@833174 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/contributions/payment-spring-policy/src')
-rw-r--r--sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java1
-rw-r--r--sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java11
-rw-r--r--sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java28
-rw-r--r--sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/PaymentTestCase.java27
-rw-r--r--sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java3
5 files changed, 37 insertions, 33 deletions
diff --git a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java
index fdced0d659..b08f76e0fa 100644
--- a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java
+++ b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java
@@ -19,7 +19,6 @@
package com.tuscanyscatours.customer;
-
public class CustomerNotFoundException extends Exception {
private static final long serialVersionUID = -129752837478357452L;
diff --git a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java
index 809afb5b84..4381029543 100644
--- a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java
+++ b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.osoa.sca.annotations.Destroy;
import org.osoa.sca.annotations.EagerInit;
import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Requires;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
@@ -63,12 +62,12 @@ public class CustomerRegistryImpl implements CustomerRegistry {
cc.setExpYear(2012);
createCustomer("John Smith", "john@xyz.com", cc);
}
-
+
@Destroy
public void destroy() {
// Save the customers
}
-
+
public Customer createCustomer(String name, String email, CreditCardDetailsType creditCard) {
Customer customer = new Customer();
customer.setId("c-" + idGenerator++);
@@ -89,11 +88,11 @@ public class CustomerRegistryImpl implements CustomerRegistry {
public Customer getCustomer(String id) throws CustomerNotFoundException {
Customer customer = customers.get(id);
-
- if (customer == null){
+
+ if (customer == null) {
throw new CustomerNotFoundException("Customer " + id + " not found");
}
-
+
return customer;
}
diff --git a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java
index 8dfe4b2b40..a35f761dc7 100644
--- a/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java
+++ b/sandbox/travelsample/contributions/payment-spring-policy/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java
@@ -33,45 +33,45 @@ public class PaymentImpl implements Payment {
private CustomerRegistry customerRegistry;
private EmailGateway emailGateway;
private float transactionFee;
-
+
public void setCreditCardPayment(CreditCardPayment creditCardPayment) {
this.creditCardPayment = creditCardPayment;
}
-
+
public void setCustomerRegistry(CustomerRegistry customerRegistry) {
this.customerRegistry = customerRegistry;
- }
-
+ }
+
public void setEmailGateway(EmailGateway emailGateway) {
this.emailGateway = emailGateway;
}
-
+
public void setTransactionFee(Float transactionFee) {
this.transactionFee = transactionFee;
}
-
+
public String makePaymentMember(String customerId, float amount) {
try {
Customer customer = customerRegistry.getCustomer(customerId);
-
+
amount += transactionFee;
-
+
String status = creditCardPayment.authorize(customer.getCreditCard(), amount);
-
- com.tuscanyscatours.emailgateway.ObjectFactory emailFactory
- = new com.tuscanyscatours.emailgateway.ObjectFactory();
+
+ com.tuscanyscatours.emailgateway.ObjectFactory emailFactory =
+ new com.tuscanyscatours.emailgateway.ObjectFactory();
EmailType email = emailFactory.createEmailType();
email.setTitle("Payment Received");
email.setTo(customerId);
-
+
emailGateway.sendEmail(email);
-
+
return status;
} catch (CustomerNotFoundException ex) {
return "Payment failed due to " + ex.getMessage();
} catch (Throwable t) {
return "Payment failed due to system error " + t.getMessage();
- }
+ }
}
}
diff --git a/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/PaymentTestCase.java b/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/PaymentTestCase.java
index 7d02dccc57..0bff419ccd 100644
--- a/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/PaymentTestCase.java
+++ b/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/PaymentTestCase.java
@@ -19,7 +19,6 @@
package scatours.payment;
-import com.tuscanyscatours.payment.Payment;
import org.apache.tuscany.sca.node.SCAClient;
import org.apache.tuscany.sca.node.SCAContribution;
import org.apache.tuscany.sca.node.SCANode;
@@ -28,6 +27,8 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.tuscanyscatours.payment.Payment;
+
/**
*
*/
@@ -36,22 +37,26 @@ public class PaymentTestCase {
private static SCANode creditCardNode;
@BeforeClass
- public static void setUpBeforeClass() throws Exception {
- creditCardNode = SCANodeFactory.newInstance().createSCANode("creditcard.composite",
- new SCAContribution("creditcard", "../creditcard-payment-jaxb-policy/target/classes"));
-
+ public static void setUpBeforeClass() throws Exception {
+ creditCardNode =
+ SCANodeFactory.newInstance()
+ .createSCANode("creditcard.composite",
+ new SCAContribution("creditcard", "../creditcard-payment-jaxb-policy/target/classes"));
+
creditCardNode.start();
-
- paymentNode = SCANodeFactory.newInstance().createSCANode(null,
- new SCAContribution("payment-spring-policy", "./target/classes"),
- new SCAContribution("payment-spring-policy-test", "./target/test-classes"));
+
+ paymentNode =
+ SCANodeFactory.newInstance()
+ .createSCANode(null,
+ new SCAContribution("payment-spring-policy", "./target/classes"),
+ new SCAContribution("payment-spring-policy-test", "./target/test-classes"));
paymentNode.start();
}
-
+
@Test
public void testPayment() {
- SCAClient client = (SCAClient) paymentNode;
+ SCAClient client = (SCAClient)paymentNode;
Payment payment = client.getService(Payment.class, "PaymentClient");
System.out.println("Result = " + payment.makePaymentMember("c-0", 100.00f));
}
diff --git a/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java b/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java
index d602f57dfc..4f64b20c4e 100644
--- a/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java
+++ b/sandbox/travelsample/contributions/payment-spring-policy/src/test/java/scatours/payment/client/impl/PaymentClientImpl.java
@@ -19,10 +19,11 @@
package scatours.payment.client.impl;
-import com.tuscanyscatours.payment.Payment;
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