From 4afc05d60e11878b7391eb9eda10a1cb5dff85c9 Mon Sep 17 00:00:00 2001 From: fmoga Date: Fri, 8 Jul 2011 04:02:26 +0000 Subject: Add test to demonstrate data conversion to/from JSON. Fix bug in the JSON array parser. Refactor salutes test. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1144149 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/websocket/runtime/JSONUtil.java | 6 +- .../runtime/WebsocketServiceBindingProvider.java | 1 - .../src/test/java/registration/Address.java | 60 +++++++++++++++++++ .../src/test/java/registration/Confirmation.java | 50 ++++++++++++++++ .../src/test/java/registration/Person.java | 60 +++++++++++++++++++ .../test/java/registration/RegistrationClient.java | 36 +++++++++++ .../java/registration/RegistrationService.java | 30 ++++++++++ .../java/registration/RegistrationServiceImpl.java | 33 +++++++++++ .../src/test/java/salutes/CiaoService.java | 28 +++++++++ .../src/test/java/salutes/CiaoServiceImpl.java | 27 +++++++++ .../src/test/java/salutes/Client.java | 48 +++++++++++++++ .../src/test/java/salutes/HelloService.java | 28 +++++++++ .../src/test/java/salutes/HelloServiceImpl.java | 28 +++++++++ .../src/test/java/salutes/SalutService.java | 28 +++++++++ .../src/test/java/salutes/SalutServiceImpl.java | 27 +++++++++ .../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/RegistrationWebsocketBindingTestCase.java | 69 ++++++++++++++++++++++ .../java/test/SalutesWebsocketBindingTestCase.java | 67 +++++++++++++++++++++ .../test/java/test/WebsocketBindingTestCase.java | 67 --------------------- .../src/test/resources/registration.composite | 37 ++++++++++++ .../src/test/resources/salutes.composite | 53 +++++++++++++++++ .../src/test/resources/test.composite | 53 ----------------- 28 files changed, 714 insertions(+), 336 deletions(-) create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Address.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Confirmation.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Person.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationClient.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationServiceImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoServiceImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/Client.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/HelloService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/HelloServiceImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutServiceImpl.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/RegistrationWebsocketBindingTestCase.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/SalutesWebsocketBindingTestCase.java delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/registration.composite create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/salutes.composite delete mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java index 30a14dd8bb..e21a2402b1 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java @@ -49,6 +49,7 @@ public class JSONUtil { List objects = new ArrayList(); int bracketNum = 0; int parNum = 0; + int quoteNum = 0; int startPos = 1; for (int i = 0; i < jsonArray.length(); i++) { switch (jsonArray.charAt(i)) { @@ -64,8 +65,11 @@ public class JSONUtil { case ']': parNum--; break; + case '\"': + quoteNum++; + break; case ',': - if ((bracketNum == 0) && (parNum == 1)) { + if ((bracketNum == 0) && (parNum == 1) && quoteNum % 2 == 0) { objects.add(jsonArray.substring(startPos, i)); startPos = i + 1; } diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java index efab714e5c..461b364b2f 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java @@ -85,7 +85,6 @@ public class WebsocketServiceBindingProvider implements ServiceBindingProvider { } } websocketServers.clear(); - websocketServers = null; } } diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Address.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Address.java new file mode 100644 index 0000000000..149199c55b --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Address.java @@ -0,0 +1,60 @@ +/* + * 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 registration; + +public class Address { + + private String street; + private String city; + private int zip; + + public Address() { + } + + public Address(String street, String city, int zip) { + this.street = street; + this.city = city; + this.zip = zip; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public int getZip() { + return zip; + } + + public void setZip(int zip) { + this.zip = zip; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Confirmation.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Confirmation.java new file mode 100644 index 0000000000..4bc3a5c27e --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Confirmation.java @@ -0,0 +1,50 @@ +/* + * 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 registration; + +public class Confirmation { + + private String message; + private int messageLength; + + public Confirmation() { + } + + public Confirmation(String confirmationMessage, int messageLength) { + this.message = confirmationMessage; + this.messageLength = messageLength; + } + + public String getMessage() { + return message; + } + + public void setMessage(String confirmationMessage) { + this.message = confirmationMessage; + } + + public int getMessageLength() { + return messageLength; + } + + public void setMessageLength(int messageLength) { + this.messageLength = messageLength; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Person.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Person.java new file mode 100644 index 0000000000..8f0ae1b6e9 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/Person.java @@ -0,0 +1,60 @@ +/* + * 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 registration; + +public class Person { + + private String name; + private Address address; + private long ssn; + + public Person() { + } + + public Person(String name, Address address, long ssn) { + this.name = name; + this.address = address; + this.ssn = ssn; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public long getSsn() { + return ssn; + } + + public void setSsn(long ssn) { + this.ssn = ssn; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationClient.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationClient.java new file mode 100644 index 0000000000..f9c79778e7 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationClient.java @@ -0,0 +1,36 @@ +/* + * 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 registration; + +import java.util.Date; + +import org.oasisopen.sca.annotation.Reference; + +public class RegistrationClient implements RegistrationService { + + @Reference + public RegistrationService service; + + @Override + public Confirmation register(Person person, Date date) { + return service.register(person, date); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationService.java new file mode 100644 index 0000000000..3fbe0cac10 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationService.java @@ -0,0 +1,30 @@ +/* + * 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 registration; + +import java.util.Date; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface RegistrationService { + + Confirmation register(Person person, Date date); + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationServiceImpl.java new file mode 100644 index 0000000000..b3cefa76da --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration/RegistrationServiceImpl.java @@ -0,0 +1,33 @@ +/* + * 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 registration; + +import java.util.Date; + +public class RegistrationServiceImpl implements RegistrationService { + + @Override + public Confirmation register(Person person, Date date) { + String message = person.getName() + " from " + person.getAddress().getStreet() + ", " + + person.getAddress().getCity() + ", " + person.getAddress().getZip() + " with SSN " + person.getSsn() + + " registered on " + date.toString(); + return new Confirmation(message, message.length()); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoService.java new file mode 100644 index 0000000000..145eb5d720 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/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 salutes; + +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/salutes/CiaoServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoServiceImpl.java new file mode 100644 index 0000000000..503fc5b51d --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/CiaoServiceImpl.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 salutes; + +public class CiaoServiceImpl implements CiaoService { + + public String sayCiao(String name) { + return "Ciao " + name; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/Client.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/Client.java new file mode 100644 index 0000000000..18d29b649a --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/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 salutes; + +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/salutes/HelloService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/HelloService.java new file mode 100644 index 0000000000..a16ce18a1c --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/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 salutes; + +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/salutes/HelloServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/HelloServiceImpl.java new file mode 100644 index 0000000000..d0b93387f0 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/HelloServiceImpl.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 salutes; + + +public class HelloServiceImpl implements HelloService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutService.java new file mode 100644 index 0000000000..e1dac86e1c --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/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 salutes; + +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/salutes/SalutServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutServiceImpl.java new file mode 100644 index 0000000000..eb9bea7e46 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/salutes/SalutServiceImpl.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 salutes; + +public class SalutServiceImpl 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/CiaoImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java deleted file mode 100644 index fc71681c52..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoImpl.java +++ /dev/null @@ -1,27 +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 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 deleted file mode 100644 index 87ff1c1355..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/CiaoService.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 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 deleted file mode 100644 index b4bf3df678..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/Client.java +++ /dev/null @@ -1,48 +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 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 deleted file mode 100644 index 055b04cc23..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloImpl.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 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 deleted file mode 100644 index a1c6efe870..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/HelloService.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 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 deleted file mode 100644 index b2747df52e..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutImpl.java +++ /dev/null @@ -1,27 +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 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 deleted file mode 100644 index 5bc8c56c99..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sample/SalutService.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 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/RegistrationWebsocketBindingTestCase.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/RegistrationWebsocketBindingTestCase.java new file mode 100644 index 0000000000..d179b18858 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/RegistrationWebsocketBindingTestCase.java @@ -0,0 +1,69 @@ +/* + * 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 test; + +import java.util.Date; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import registration.Address; +import registration.Confirmation; +import registration.Person; +import registration.RegistrationService; + +public class RegistrationWebsocketBindingTestCase { + + private static Node node; + + @Test + public void testJSONSerialization() { + RegistrationService registrationClient = node.getService(RegistrationService.class, + "ClientComponent/RegistrationService"); + Address address = new Address("Queen Elizabeth", "London", 12345); + Person person = new Person("John Locke", address, 1122334455); + Date date = new Date(); + + Confirmation confirmation = registrationClient.register(person, date); + + String expectedMessage = person.getName() + " from " + person.getAddress().getStreet() + ", " + + person.getAddress().getCity() + ", " + person.getAddress().getZip() + " with SSN " + person.getSsn() + + " registered on " + date.toString(); + Assert.assertEquals(expectedMessage, confirmation.getMessage()); + Assert.assertEquals(expectedMessage.length(), confirmation.getMessageLength()); + } + + @BeforeClass + public static void init() throws Exception { + node = NodeFactory.newInstance().createNode("registration.composite").start(); + } + + @AfterClass + public static void destroy() throws Exception { + if (node != null) { + node.stop(); + } + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/SalutesWebsocketBindingTestCase.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/SalutesWebsocketBindingTestCase.java new file mode 100644 index 0000000000..22d0861c81 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/SalutesWebsocketBindingTestCase.java @@ -0,0 +1,67 @@ +/* + * 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 test; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import salutes.CiaoService; +import salutes.HelloService; +import salutes.SalutService; + +public class SalutesWebsocketBindingTestCase { + + 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 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("salutes.composite").start(); + } + + @AfterClass + public static void destroy() throws Exception { + if (node != null) { + node.stop(); + } + } + +} 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 deleted file mode 100644 index 3161b73a7a..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java +++ /dev/null @@ -1,67 +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 test; - -import junit.framework.Assert; - -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; -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 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("test.composite").start(); - } - - @AfterClass - public static void destroy() throws Exception { - if (node != null) { - node.stop(); - } - } - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/registration.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/registration.composite new file mode 100644 index 0000000000..60bbda50ec --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/registration.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/salutes.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/salutes.composite new file mode 100644 index 0000000000..35126ba267 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/salutes.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 deleted file mode 100644 index e7b3e086d5..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/test.composite +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3