summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-24 00:44:19 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-02-24 00:44:19 +0000
commita306a257346d7f4def9cfd20c9801e10b9c5a6db (patch)
tree5e259dd053e9e97afd4a3df718d1b3aa23645698 /sca-java-2.x/trunk/itest/nodes/binding-sca-tribes
parente925641526447819b9adecc9a4710f436cf1d471 (diff)
Add the client api tests and javadocs
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@915624 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java52
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java8
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java2
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java3
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java52
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java55
6 files changed, 168 insertions, 4 deletions
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
new file mode 100644
index 0000000000..eb7fbf06e0
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import java.net.URI;
+
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ *
+ */
+public class SCAClientImpl implements Client {
+ private Local local;
+ private Remote remote;
+
+ public SCAClientImpl(String domainURI) throws Exception {
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ local = factory.getService(Local.class, "LocalComponent/Local");
+ remote = factory.getService(Remote.class, "RemoteComponent/Remote");
+ }
+
+ public String getName(String id) {
+ Customer customer = remote.getCustomer(id);
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
index 003c357b50..baf4d69508 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
@@ -32,7 +32,7 @@ import org.oasisopen.sca.SCARuntimeException;
* Test binding.sca in the same classloader
*/
public class BindingSCATestCase {
- private static final String DOMAIN_URI = "my-domain";
+ static final String DOMAIN_URI = "my-domain";
private static final String REGISTRY_URI = "tribes://228.0.0.100:50000";
private static final String PKG = "org/apache/tuscany/sca/itest/bindingsca/";
private static final String CLIENT = "Client.composite";
@@ -110,10 +110,14 @@ public class BindingSCATestCase {
*/
static void runClient(Node node) {
Client client = node.getService(Client.class, "ClientComponent/Client");
+ runClient(client);
+ }
+
+ static void runClient(Client client) {
String id = client.create("Ray");
Assert.assertEquals("Ray", client.getName(id));
}
-
+
/**
* One node factory and one node for both composites
*/
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
index 4e6deafd24..d9436e8ea5 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
/**
- * This shows how to test the Calculator service component.
+ * Running the client node and service node with two different classloaders that share the Customer class
*/
public class ClientNodeSharedCustomerTestCase {
private static Node clientNode;
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
index b3d3af014b..c29dfe4ae4 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
@@ -26,7 +26,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
/**
- * This shows how to test the Calculator service component.
+ * Running the client node and service node with two different classloaders that share the Local class
+ * (but not Customer)
*/
public class ClientNodeSharedLocalTestCase {
private static Node clientNode;
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
new file mode 100644
index 0000000000..13dd048f1f
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Customer class
+ */
+public class ClientSharedCustomerTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
new file mode 100644
index 0000000000..d48b18f83a
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Local class
+ * (but not Customer)
+ */
+public class ClientSharedLocalTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner =
+ new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
+ Customer.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ }
+}