diff options
Diffstat (limited to '')
9 files changed, 183 insertions, 27 deletions
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java index 136c9baba8..fc71681c52 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java @@ -16,18 +16,12 @@ * specific language governing permissions and limitations
* under the License.
*/
+package sample;
-package helloworld;
+public class CiaoImpl implements CiaoService {
-import org.oasisopen.sca.annotation.Reference;
-
-public class HelloWorldClient implements HelloWorldService {
-
- @Reference
- public HelloWorldService ref;
-
- public String sayHello(String name) {
- return ref.sayHello(name);
+ public String sayCiao(String name) {
+ return "Ciao " + name;
}
}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java new file mode 100644 index 0000000000..87ff1c1355 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java @@ -0,0 +1,28 @@ +/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CiaoService {
+
+ String sayCiao(String name);
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java new file mode 100644 index 0000000000..b4bf3df678 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java @@ -0,0 +1,48 @@ +/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class Client implements HelloService, SalutService, CiaoService {
+
+ @Reference
+ public HelloService hello;
+ @Reference
+ public SalutService salut;
+ @Reference
+ public CiaoService ciao;
+
+ @Override
+ public String sayHello(String name) {
+ return hello.sayHello(name);
+ }
+
+ @Override
+ public String saySalut(String name) {
+ return salut.saySalut(name);
+ }
+
+ @Override
+ public String sayCiao(String name) {
+ return ciao.sayCiao(name);
+ }
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java index c307547f56..055b04cc23 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations
* under the License.
*/
-package helloworld;
+package sample;
-public class HelloWorldImpl implements HelloWorldService {
+public class HelloImpl implements HelloService {
public String sayHello(String name) {
return "Hello " + name;
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java index 064d615c45..a1c6efe870 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations
* under the License.
*/
-package helloworld;
+package sample;
import org.oasisopen.sca.annotation.Remotable;
@Remotable
-public interface HelloWorldService {
+public interface HelloService {
String sayHello(String name);
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java new file mode 100644 index 0000000000..b2747df52e --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java @@ -0,0 +1,27 @@ +/*
+ * 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 sample;
+
+public class SalutImpl implements SalutService {
+
+ public String saySalut(String name) {
+ return "Salut " + name;
+ }
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java new file mode 100644 index 0000000000..5bc8c56c99 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java @@ -0,0 +1,28 @@ +/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface SalutService {
+
+ String saySalut(String name);
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java index cd8f20c11e..3161b73a7a 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java @@ -18,7 +18,6 @@ */
package test;
-import helloworld.HelloWorldService;
import junit.framework.Assert;
import org.apache.tuscany.sca.node.Node;
@@ -27,21 +26,37 @@ import org.junit.AfterClass; import org.junit.BeforeClass;
import org.junit.Test;
+import sample.CiaoService;
+import sample.HelloService;
+import sample.SalutService;
+
public class WebsocketBindingTestCase {
private static Node node;
-
+
+ @Test
+ public void testHello() {
+ HelloService helloClient = node.getService(HelloService.class, "ClientComponent/HelloService");
+ Assert.assertEquals("Hello Tuscany", helloClient.sayHello("Tuscany"));
+ }
+
@Test
- public void testSayHello() {
- HelloWorldService service = node.getService(HelloWorldService.class, "HelloWorldClient/HelloWorldService");
- Assert.assertEquals("Hello boo", service.sayHello("boo"));
+ public void testSalut() {
+ SalutService salutClient = node.getService(SalutService.class, "ClientComponent/SalutService");
+ Assert.assertEquals("Salut Tuscany", salutClient.saySalut("Tuscany"));
+ }
+
+ @Test
+ public void testCiao() {
+ CiaoService ciaoClient = node.getService(CiaoService.class, "ClientComponent/CiaoService");
+ Assert.assertEquals("Ciao Tuscany", ciaoClient.sayCiao("Tuscany"));
}
@BeforeClass
public static void init() throws Exception {
- node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+ node = NodeFactory.newInstance().createNode("test.composite").start();
}
-
+
@AfterClass
public static void destroy() throws Exception {
if (node != null) {
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite index a3cbf5084c..e7b3e086d5 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite @@ -22,16 +22,32 @@ targetNamespace="http://itest"
name="HelloWorldComposite">
- <component name="HelloWorldComponent">
- <implementation.java class="helloworld.HelloWorldImpl"/>
- <service name="HelloWorldService" >
+ <component name="HelloComponent">
+ <implementation.java class="sample.HelloImpl"/>
+ <service name="HelloService" >
<tuscany:binding.websocket uri="ws://127.0.0.1:5555" />
</service>
</component>
- <component name="HelloWorldClient">
- <implementation.java class="helloworld.HelloWorldClient"/>
- <reference name="ref" target="HelloWorldComponent/HelloWorldService" />
+ <component name="SalutComponent">
+ <implementation.java class="sample.SalutImpl"/>
+ <service name="SalutService" >
+ <tuscany:binding.websocket uri="ws://127.0.0.1:5555" />
+ </service>
+ </component>
+
+ <component name="CiaoComponent">
+ <implementation.java class="sample.CiaoImpl"/>
+ <service name="CiaoService" >
+ <tuscany:binding.websocket uri="ws://127.0.0.1:6666" />
+ </service>
+ </component>
+
+ <component name="ClientComponent">
+ <implementation.java class="sample.Client"/>
+ <reference name="hello" target="HelloComponent/HelloService" />
+ <reference name="salut" target="SalutComponent/SalutService" />
+ <reference name="ciao" target="CiaoComponent/CiaoService" />
</component>
</composite>
|