From 9381c02e0b02064a86de6da350ee480a588dfcb0 Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 27 Oct 2010 21:26:27 +0000 Subject: Merge remaining r743192 changes from 2.x to 1.x and add a new itest for @XmlJavaTypeAdapter git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1028105 13f79535-47bb-0310-9956-ffa450edef68 --- .../jaxws/src/main/java/jtest/TestAbstract.java | 31 +++++++++++++ .../jaxws/src/main/java/jtest/TestAdapter.java | 34 ++++++++++++++ .../jaxws/src/main/java/jtest/TestClient.java | 28 +++++++++++ .../jaxws/src/main/java/jtest/TestConcrete1.java | 30 ++++++++++++ .../jaxws/src/main/java/jtest/TestConcrete2.java | 30 ++++++++++++ .../jaxws/src/main/java/jtest/TestService.java | 33 +++++++++++++ .../src/main/java/jtest/impl/TestClientImpl.java | 44 ++++++++++++++++++ .../src/main/java/jtest/impl/TestServiceImpl.java | 38 +++++++++++++++ .../itest/jaxws/src/main/resources/jtest.composite | 38 +++++++++++++++ .../src/test/java/jtest/DatatypesTestCase.java | 54 ++++++++++++++++++++++ .../sca/interfacedef/java/jaxws/BeanInterface.java | 28 +++++++++++ .../interfacedef/java/jaxws/BeanInterfaceImpl.java | 35 ++++++++++++++ .../sca/interfacedef/java/jaxws/TestAdapter.java | 39 ++++++++++++++++ .../sca/interfacedef/java/jaxws/TestInterface.java | 10 ++-- 14 files changed, 469 insertions(+), 3 deletions(-) create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAbstract.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAdapter.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete1.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete2.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/main/resources/jtest.composite create mode 100644 sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java create mode 100644 sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java create mode 100644 sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java create mode 100644 sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java (limited to 'sca-java-1.x/trunk') diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAbstract.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAbstract.java new file mode 100644 index 0000000000..a633908bc3 --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAbstract.java @@ -0,0 +1,31 @@ +/* + * 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.adapters.XmlJavaTypeAdapter; + +/** + * The test abstract class + */ +@XmlJavaTypeAdapter(TestAdapter.class) +public abstract class TestAbstract { + + public abstract String getGreeting(); +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAdapter.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAdapter.java new file mode 100644 index 0000000000..2c5e52caba --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestAdapter.java @@ -0,0 +1,34 @@ +/* + * 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.adapters.XmlAdapter; + +/** + * The test XML adapter class + */ +public class TestAdapter extends XmlAdapter { + public TestAbstract unmarshal(String v) throws Exception { + return (TestAbstract)this.getClass().getClassLoader().loadClass(v).newInstance(); + } + public String marshal(TestAbstract v) throws Exception { + return v.getClass().getName(); + } +} 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 new file mode 100644 index 0000000000..6eedfc14ae --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestClient.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 jtest; + +/** + * The test client interface + */ +public interface TestClient { + + void runTest(); +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete1.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete1.java new file mode 100644 index 0000000000..47cf3db41d --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete1.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 jtest; + +/** + * A test concrete class + */ +public class TestConcrete1 extends TestAbstract { + + public String getGreeting() { + return "Hello"; + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete2.java b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete2.java new file mode 100644 index 0000000000..660ecf30ba --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestConcrete2.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 jtest; + +/** + * A test concrete class + */ +public class TestConcrete2 extends TestAbstract { + + public String getGreeting() { + return "World"; + } +} 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 new file mode 100644 index 0000000000..90b2e011ca --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/TestService.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 jtest; + +import org.osoa.sca.annotations.Remotable; + +import jtest.TestAbstract; + +/** + * The test service interface + */ +@Remotable +public interface TestService { + + void sendAbstract(TestAbstract data1, TestAbstract data2); +} 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 new file mode 100644 index 0000000000..7249cfc7d1 --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java @@ -0,0 +1,44 @@ +/* + * 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.impl; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import jtest.TestClient; +import jtest.TestConcrete1; +import jtest.TestConcrete2; +import jtest.TestService; + +/** + * The test client implementation + */ +@Service(TestClient.class) +public class TestClientImpl implements TestClient { + + @Reference + protected TestService ref; + + public void runTest() { + TestConcrete1 data1 = new TestConcrete1(); + TestConcrete2 data2 = new TestConcrete2(); + ref.sendAbstract(data1, data2); + } +} 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 new file mode 100644 index 0000000000..3cc8ca0bce --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.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.impl; + +import org.osoa.sca.annotations.Service; + +import jtest.TestAbstract; +import jtest.TestService; + +/** + * The test service implementation + */ +@Service(TestService.class) +public class TestServiceImpl implements TestService { + + public void sendAbstract(TestAbstract data1, TestAbstract data2) { + System.out.println("data1 is instance of class " + data1.getClass().getName()); + System.out.println("data2 is instance of class " + data2.getClass().getName()); + System.out.println(data1.getGreeting() + " " + data2.getGreeting()); + } +} diff --git a/sca-java-1.x/trunk/itest/jaxws/src/main/resources/jtest.composite b/sca-java-1.x/trunk/itest/jaxws/src/main/resources/jtest.composite new file mode 100644 index 0000000000..74aee987fb --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/main/resources/jtest.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + 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 new file mode 100644 index 0000000000..7a9f27d32e --- /dev/null +++ b/sca-java-1.x/trunk/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java @@ -0,0 +1,54 @@ +/* + * 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 org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class DatatypesTestCase { + private static SCANode node; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + node = SCANodeFactory.newInstance().createSCANode("jtest.composite", + new SCAContribution("payment", "./target/classes")); + node.start(); + } + + @Test + public void runTest() { + SCAClient client = (SCAClient)node; + TestClient testClient = client.getService(TestClient.class, "TestClient"); + testClient.runTest(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node = null; + } + } +} diff --git a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java new file mode 100644 index 0000000000..71a860d152 --- /dev/null +++ b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.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 org.apache.tuscany.sca.interfacedef.java.jaxws; + +/** + * Bean Interface + */ +public interface BeanInterface { + String getAttr(); + void setAttr(String attr); +} diff --git a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java new file mode 100644 index 0000000000..684f7b4c01 --- /dev/null +++ b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 org.apache.tuscany.sca.interfacedef.java.jaxws; + +/** + * Impl of BeanInterface + */ +public class BeanInterfaceImpl implements BeanInterface { + private String attr; + + public String getAttr() { + return attr; + } + + public void setAttr(String attr) { + this.attr = attr; + } +} diff --git a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java new file mode 100644 index 0000000000..c1314d788c --- /dev/null +++ b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java @@ -0,0 +1,39 @@ +/* + * 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 org.apache.tuscany.sca.interfacedef.java.jaxws; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * Test XML Adapter + */ +public class TestAdapter extends XmlAdapter { + + @Override + public BeanInterfaceImpl marshal(BeanInterface v) throws Exception { + return (BeanInterfaceImpl)v; + } + + @Override + public BeanInterface unmarshal(BeanInterfaceImpl v) throws Exception { + return v; + } + +} diff --git a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java index a6a3375eff..5c20892d91 100644 --- a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java +++ b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java @@ -27,6 +27,7 @@ import java.util.Map; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.ws.Holder; import org.osoa.sca.annotations.Remotable; @@ -60,7 +61,10 @@ public interface TestInterface { @WebMethod @WebResult(name = "output") - String webMethod(@WebParam(name = "input", mode = WebParam.Mode.IN) - String in, @WebParam(name = "holder", mode = WebParam.Mode.INOUT) - Holder holder); + String webMethod(@WebParam(name = "input", mode = WebParam.Mode.IN) String in, + @WebParam(name = "holder", mode = WebParam.Mode.INOUT) Holder holder); + + @XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class) + BeanInterface beanMethod(@XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class) BeanInterface in, + String str); } -- cgit v1.2.3