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 --- .../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 ++++++++++++ 6 files changed, 269 insertions(+) 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 (limited to 'sca-java-2.x/contrib/modules/binding-websocket/src/test/java/registration') 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()); + } + +} -- cgit v1.2.3