From 035f871e8e7be71f83420056194d7855962947a2 Mon Sep 17 00:00:00 2001 From: nash Date: Fri, 3 Dec 2010 20:52:19 +0000 Subject: Add more tests git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041988 13f79535-47bb-0310-9956-ffa450edef68 --- .../itest/jaxws/src/main/java/jtest/Bean1.java | 63 ++++++++++++++++++++++ .../itest/jaxws/src/main/java/jtest/Bean2.java | 59 ++++++++++++++++++++ .../jaxws/src/main/java/jtest/TestClient.java | 8 +++ .../jaxws/src/main/java/jtest/TestService.java | 12 +++++ .../jaxws/src/main/java/jtest/TestWebService.java | 10 ++++ .../itest/jaxws/src/main/java/jtest/WrapBean.java | 38 +++++++++++++ .../itest/jaxws/src/main/java/jtest/WrapMap.java | 37 +++++++++++++ .../src/main/java/jtest/impl/TestClientImpl.java | 32 +++++++++++ .../src/main/java/jtest/impl/TestServiceImpl.java | 28 ++++++++++ .../main/java/jtest/impl/TestWebServiceImpl.java | 17 ++++++ .../src/test/java/jtest/DatatypesTestCase.java | 30 ++++++++++- 11 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean1.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean2.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapBean.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapMap.java (limited to 'sca-java-1.x/trunk') diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean1.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean1.java new file mode 100644 index 0000000000..c93b7d8d65 --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean1.java @@ -0,0 +1,63 @@ +/* + * 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 jtest; + +/** + * @version $Rev: 832193 $ $Date: 2009-11-02 23:31:15 +0000 (Mon, 02 Nov 2009) $ + */ +public class Bean1 { + private T item; + + public Bean1() { + } + + public Bean1(T item) { + this.item = item; + } + + public void setItem(T item) { + this.item = item; + } + + public T getItem() { + return item; + } + + public boolean equals(Object that) { + if(that == null) { + return false; + } + if(that.getClass() != this.getClass()) { + return false; + } + + Bean1 that1 = (Bean1)that; + if(this == that1) { + return true; + } else if(this.item != null) { + return this.item.equals(that1.item); + } else { + return that1.item == null; + } + } + + public String toString() { + return this.getClass().getSimpleName()+"[item = "+item+"]"; + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean2.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean2.java new file mode 100644 index 0000000000..ff2d334a12 --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/Bean2.java @@ -0,0 +1,59 @@ +/* + * 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 jtest; + +//import javax.xml.bind.annotation.XmlSeeAlso; + +/** + * @version $Rev: 832193 $ $Date: 2009-11-02 23:31:15 +0000 (Mon, 02 Nov 2009) $ + */ +//@XmlSeeAlso({Bean3.class, Bean3[].class, Bean31.class, Bean31[].class}) +public class Bean2 { + private String name; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public boolean equals(Object that) { + if(that == null) { + return false; + } + + if(this.getClass() != that.getClass()) { + return false; + } + + if(this == that) { + return true; + } else if(this.name != null) { + return this.name.equals(((Bean2)that).name); + } else { + return ((Bean2)that).name == null; + } + } + + public String toString() { + return this.getClass().getSimpleName()+"[name = "+name+"]"; + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.java index f9cd464d4c..576df240bb 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.java @@ -29,4 +29,12 @@ public interface TestClient { void runAbstractExceptionTest(); void runListTypeTest(); + + void runMapTypeTest(); + + void runWrapMapTypeTest(); + + void runWildcardExtendsTest(); + + void runWrapBeanTest(); } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.java index 4ade8d85af..6810ed7826 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.java @@ -19,7 +19,10 @@ package jtest; +//import java.util.HashMap; import java.util.List; +import java.util.Map; +//import javax.xml.bind.annotation.XmlSeeAlso; import org.osoa.sca.annotations.Remotable; @@ -30,6 +33,7 @@ import jtest.TestAbstract; * The test service interface */ @Remotable +//@XmlSeeAlso(Bean2.class) public interface TestService { void sendAbstract(TestAbstract data); @@ -37,4 +41,12 @@ public interface TestService { void throwAbstract() throws AbstractException; void sendList(List data); + + Map returnMap(); + + WrapMap returnWrapMap(); + + void sendWildcardExtends(Bean1 arg); + + void sendWrapBean(WrapBean arg); } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestWebService.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestWebService.java index 6891b04e13..6ec23d9cb0 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestWebService.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestWebService.java @@ -19,6 +19,7 @@ package jtest; import java.util.List; +import java.util.Map; import javax.jws.WebMethod; import javax.jws.WebService; @@ -28,9 +29,18 @@ public interface TestWebService { @WebMethod void sendAbstract(TestAbstract testData); + @WebMethod + String sendConcrete(TestConcrete1 testData); + @WebMethod void throwAbstract() throws AbstractException; @WebMethod void sendList(List data); + + @WebMethod + Map returnMap(); + + @WebMethod + void sendWildcardExtends(Bean1 arg); } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapBean.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapBean.java new file mode 100644 index 0000000000..d364555e72 --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapBean.java @@ -0,0 +1,38 @@ +/* + * 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 jtest; + +import javax.xml.bind.annotation.XmlSeeAlso; + +/** + * The wrapped bean class + */ +@XmlSeeAlso(Bean2.class) +public class WrapBean { + private Bean1 bean; + + public Bean1 getBean() { + return bean; + } + + public void setBean(Bean1 bean) { + this.bean = bean; + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapMap.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapMap.java new file mode 100644 index 0000000000..7c4394413a --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/WrapMap.java @@ -0,0 +1,37 @@ +/* + * 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 jtest; + +import java.util.Map; + +/** + * The wrapped map class + */ +public class WrapMap { + private Map map; + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java index 12fd257b54..7461d18af8 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java @@ -20,14 +20,19 @@ package jtest.impl; import java.util.ArrayList; +import java.util.Map; import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Service; import jtest.AbstractException; +import jtest.Bean1; +import jtest.Bean2; import jtest.TestClient; import jtest.TestConcrete1; import jtest.TestConcrete2; import jtest.TestService; +import jtest.WrapBean; +import jtest.WrapMap; /** * The test client implementation @@ -64,4 +69,31 @@ public class TestClientImpl implements TestClient { data.add("World!"); ref.sendList(data); } + + public void runMapTypeTest() { + Map myMap = ref.returnMap(); + System.out.println(myMap.get("greeting")); + } + + public void runWrapMapTypeTest() { + WrapMap myWrapMap = ref.returnWrapMap(); + Map myMap = myWrapMap.getMap(); + System.out.println(myMap.get("greeting")); + } + + public void runWildcardExtendsTest() { + Bean2 temp = new Bean2(); + temp.setName("Me"); + Bean1 arg = new Bean1(temp); + ref.sendWildcardExtends(arg); + } + + public void runWrapBeanTest() { + Bean2 temp = new Bean2(); + temp.setName("Me"); + Bean1 arg = new Bean1(temp); + WrapBean bean = new WrapBean(); + bean.setBean(arg); + ref.sendWrapBean(bean); + } } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java index 8537635590..77a7cfb6cf 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java @@ -19,14 +19,20 @@ package jtest.impl; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.osoa.sca.annotations.Service; import jtest.AbstractException; +import jtest.Bean1; +import jtest.Bean2; import jtest.ConcreteException; import jtest.TestAbstract; import jtest.TestService; +import jtest.WrapBean; +import jtest.WrapMap; /** * The test service implementation @@ -48,4 +54,26 @@ public class TestServiceImpl implements TestService { public void sendList(List data) { System.out.println(data.get(0) + " " + data.get(1)); } + + public Map returnMap() { + Map yourMap = new HashMap(); + yourMap.put("greeting", "Hello, World Map!"); + return yourMap; + } + + public WrapMap returnWrapMap() { + Map yourMap = new HashMap(); + yourMap.put("greeting", "Hello, World Map!"); + WrapMap wrapped = new WrapMap(); + wrapped.setMap(yourMap); + return wrapped; + } + + public void sendWildcardExtends(Bean1 arg) { + System.out.println("TestServiceImpl received generic bean " + arg); + } + + public void sendWrapBean(WrapBean arg) { + System.out.println("TestServiceImpl received wrapped bean " + arg.getBean()); + } } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java index 2c429358f3..eb089e8be1 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java @@ -19,11 +19,15 @@ package jtest.impl; import java.util.List; +import java.util.Map; import javax.jws.WebService; import jtest.AbstractException; +import jtest.Bean1; +import jtest.Bean2; import jtest.ConcreteException; import jtest.TestAbstract; +import jtest.TestConcrete1; import jtest.TestWebService; @WebService(endpointInterface = "jtest.TestWebService") @@ -33,6 +37,11 @@ public class TestWebServiceImpl implements TestWebService { System.out.println(testData.getGreeting()); } + public String sendConcrete(TestConcrete1 testData) { + System.out.println(testData.getGreeting()); + return "Hi!"; + } + public void throwAbstract() throws AbstractException { throw new ConcreteException(); } @@ -40,4 +49,12 @@ public class TestWebServiceImpl implements TestWebService { public void sendList(List data) { System.out.println(data.get(0) + " " + data.get(1)); } + + public Map returnMap() { + return null; + } + + public void sendWildcardExtends(Bean1 arg) { + System.out.println(arg); + } } diff --git a/sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java b/sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java index ffa9ac03aa..04450986c0 100644 --- a/sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java +++ b/sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java @@ -54,7 +54,7 @@ public class DatatypesTestCase { TestClient testClient = client.getService(TestClient.class, "TestClient"); testClient.runAbstractExceptionTest(); } - + @Test public void runListTypeTest() { SCAClient client = (SCAClient)node; @@ -62,6 +62,34 @@ public class DatatypesTestCase { testClient.runListTypeTest(); } + @Test + public void runWrapMapTypeTest() { + SCAClient client = (SCAClient)node; + TestClient testClient = client.getService(TestClient.class, "TestClient"); + testClient.runWrapMapTypeTest(); + } + + @Test + public void runMapTypeTest() { + SCAClient client = (SCAClient)node; + TestClient testClient = client.getService(TestClient.class, "TestClient"); + testClient.runMapTypeTest(); + } + + @Test + public void runWildcardExtendsTest() { + SCAClient client = (SCAClient)node; + TestClient testClient = client.getService(TestClient.class, "TestClient"); + testClient.runWildcardExtendsTest(); + } + + @Test + public void runWrapBeanTest() { + SCAClient client = (SCAClient)node; + TestClient testClient = client.getService(TestClient.class, "TestClient"); + testClient.runWrapBeanTest(); + } + @AfterClass public static void tearDownAfterClass() throws Exception { if (node != null) { -- cgit v1.2.3