From a306a257346d7f4def9cfd20c9801e10b9c5a6db Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 24 Feb 2010 00:44:19 +0000 Subject: Add the client api tests and javadocs git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@915624 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/itest/bindingsca/BindingSCATestCase.java | 8 +++- .../ClientNodeSharedCustomerTestCase.java | 2 +- .../bindingsca/ClientNodeSharedLocalTestCase.java | 3 +- .../bindingsca/ClientSharedCustomerTestCase.java | 52 ++++++++++++++++++++ .../bindingsca/ClientSharedLocalTestCase.java | 55 ++++++++++++++++++++++ 5 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java create mode 100644 sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java (limited to 'sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test') 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(); + } + } +} -- cgit v1.2.3