summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast')
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java7
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java64
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java2
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java7
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java7
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java5
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java8
7 files changed, 95 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/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);
}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
index 33d2677ecd..fcd0d39162 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
@@ -134,6 +134,11 @@ public class BindingSCATestCase {
String id = client.create("Ray");
Assert.assertEquals("Ray", client.getName(id));
}
+
+ static void runClientNotFound(Client client) {
+ String id = "not-there";
+ Assert.assertNull(client.getName(id));
+ }
static String createCustomer(Node node) {
Client client = node.getService(Client.class, "ClientComponent/Client");
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
index 034136ca53..633e1a767c 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
@@ -36,7 +36,7 @@ public class ClientSharedLocalTestCase {
public static void setUpBeforeClass() throws Exception {
runner =
new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
- Customer.class.getName());
+ Customer.class.getName(), CustomerNotFoundException.class.getName());
runner.beforeClass();
client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
Thread.sleep(1000);
@@ -46,6 +46,12 @@ public class ClientSharedLocalTestCase {
public void testClient() throws Exception {
BindingSCATestCase.runClient(client);
}
+
+ @Test
+ public void testClientNotFound() throws Exception {
+ BindingSCATestCase.runClientNotFound(client);
+ }
+
@AfterClass
public static void tearDownAfterClass() throws Exception {