From 98e926ec59cca9e5696e5376ea59940ceb7cae3b Mon Sep 17 00:00:00 2001 From: rfeng Date: Thu, 11 Mar 2010 04:44:11 +0000 Subject: Fix for TUSCANY-3489 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@921689 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/itest/bindingsca/ClientImpl.java | 7 ++- .../bindingsca/CustomerNotFoundException.java | 64 ++++++++++++++++++++++ .../tuscany/sca/itest/bindingsca/Remote.java | 2 +- .../sca/itest/bindingsca/RemoteServiceImpl.java | 7 ++- .../sca/itest/bindingsca/SCAClientImpl.java | 7 ++- 5 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java (limited to 'sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java') diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java index 30ae3cc0fb..96a0f2dadd 100644 --- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java +++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java @@ -34,7 +34,12 @@ public class ClientImpl implements Client { protected Remote remote; public String getName(String id) { - Customer customer = remote.getCustomer(id); + Customer customer = null; + try { + customer = remote.getCustomer(id); + } catch (CustomerNotFoundException e) { + return null; + } customer.dump("Client.getName()"); return local.getName(customer); } diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java new file mode 100644 index 0000000000..a6e80c9eca --- /dev/null +++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java @@ -0,0 +1,64 @@ +/* + * 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 org.apache.tuscany.sca.itest.bindingsca; + +/** + * + */ +public class CustomerNotFoundException extends Exception { + private String customerId; + + /** + * + */ + public CustomerNotFoundException() { + } + + /** + * @param message + */ + public CustomerNotFoundException(String message) { + super(message); + } + + /** + * @param cause + */ + public CustomerNotFoundException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public CustomerNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + +} diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java index eaa2298c49..050d35007b 100644 --- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java +++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java @@ -30,7 +30,7 @@ public interface Remote { String getId(Customer customer); - Customer getCustomer(String id); + Customer getCustomer(String id) throws CustomerNotFoundException; Customer createCustomer(String id, String name); } diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java index baf32ad959..6c432a500a 100644 --- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java +++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java @@ -45,8 +45,13 @@ public class RemoteServiceImpl implements Remote { return customer.getId(); } - public Customer getCustomer(String id) { + public Customer getCustomer(String id) throws CustomerNotFoundException { Customer customer = customers.get(id); + if (customer == null) { + CustomerNotFoundException ex = new CustomerNotFoundException("Customer not found"); + ex.setCustomerId(id); + throw ex; + } customer.dump("Remote.getCustomer()"); return customer; } diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java index eb7fbf06e0..3573eea978 100644 --- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java +++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java @@ -37,7 +37,12 @@ public class SCAClientImpl implements Client { } public String getName(String id) { - Customer customer = remote.getCustomer(id); + Customer customer = null; + try { + customer = remote.getCustomer(id); + } catch (CustomerNotFoundException e) { + return null; + } customer.dump("Client.getName()"); return local.getName(customer); } -- cgit v1.2.3