From 5e52a072abe41981e2baa9a8237b87b00cf7090b Mon Sep 17 00:00:00 2001 From: fmoga Date: Fri, 8 Jul 2011 02:23:33 +0000 Subject: Update sample to demonstrate that runtime uses the same server for services with the same uri. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1144128 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/java/helloworld/HelloWorldClient.java | 33 -------------- .../src/test/java/helloworld/HelloWorldImpl.java | 28 ------------ .../test/java/helloworld/HelloWorldService.java | 28 ------------ .../src/test/java/sample/CiaoImpl.java | 27 +++++++++++ .../src/test/java/sample/CiaoService.java | 28 ++++++++++++ .../src/test/java/sample/Client.java | 48 ++++++++++++++++++++ .../src/test/java/sample/HelloImpl.java | 28 ++++++++++++ .../src/test/java/sample/HelloService.java | 28 ++++++++++++ .../src/test/java/sample/SalutImpl.java | 27 +++++++++++ .../src/test/java/sample/SalutService.java | 28 ++++++++++++ .../test/java/test/WebsocketBindingTestCase.java | 29 +++++++++--- .../src/test/resources/helloworld.composite | 37 --------------- .../src/test/resources/test.composite | 53 ++++++++++++++++++++++ 13 files changed, 289 insertions(+), 133 deletions(-) delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite (limited to 'sca-java-2.x/contrib/modules/binding-websocket/src/test') 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/helloworld/HelloWorldClient.java deleted file mode 100644 index 136c9baba8..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 helloworld; - -import org.oasisopen.sca.annotation.Reference; - -public class HelloWorldClient implements HelloWorldService { - - @Reference - public HelloWorldService ref; - - public String sayHello(String name) { - return ref.sayHello(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/helloworld/HelloWorldImpl.java deleted file mode 100644 index c307547f56..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 helloworld; - - -public class HelloWorldImpl implements HelloWorldService { - - 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/helloworld/HelloWorldService.java deleted file mode 100644 index 064d615c45..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 helloworld; - -import org.oasisopen.sca.annotation.Remotable; - -@Remotable -public interface HelloWorldService { - - String sayHello(String name); - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java new file mode 100644 index 0000000000..fc71681c52 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.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 CiaoImpl implements CiaoService { + + 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/sample/HelloImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java new file mode 100644 index 0000000000..055b04cc23 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.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; + + +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/sample/HelloService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java new file mode 100644 index 0000000000..a1c6efe870 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.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 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/helloworld.composite deleted file mode 100644 index a3cbf5084c..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite new file mode 100644 index 0000000000..e7b3e086d5 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3