Add test code to demonstrate problem with WSDL generation when using @XmlJavaTypeAdapter (see TUSCANY-3779)

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk@1033586 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/itest/jaxws/src/main/java/jtest/TestAbstract.java b/itest/jaxws/src/main/java/jtest/TestAbstract.java
index a633908..cd2cf16 100644
--- a/itest/jaxws/src/main/java/jtest/TestAbstract.java
+++ b/itest/jaxws/src/main/java/jtest/TestAbstract.java
@@ -27,5 +27,15 @@
 @XmlJavaTypeAdapter(TestAdapter.class)

 public abstract class TestAbstract {

 

-    public abstract String getGreeting();

+    public String firstName = "?";

+

+    public String lastName = "??";

+

+    public String greeting = "???";

+

+    public String sender = "Anonymous";

+

+    public String getGreeting() {

+        return greeting;

+    }

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestAbstractImpl.java b/itest/jaxws/src/main/java/jtest/TestAbstractImpl.java
new file mode 100644
index 0000000..de1667c
--- /dev/null
+++ b/itest/jaxws/src/main/java/jtest/TestAbstractImpl.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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

+

+/**

+ * The test abstract class on-the-wire representation

+ */

+public class TestAbstractImpl {

+

+    public String className;

+

+    public String someMessage;

+

+}

diff --git a/itest/jaxws/src/main/java/jtest/TestAdapter.java b/itest/jaxws/src/main/java/jtest/TestAdapter.java
index 2c5e52c..44216d3 100644
--- a/itest/jaxws/src/main/java/jtest/TestAdapter.java
+++ b/itest/jaxws/src/main/java/jtest/TestAdapter.java
@@ -24,11 +24,16 @@
 /**

  * The test XML adapter class

  */

-public class TestAdapter extends XmlAdapter<String, TestAbstract> {

-    public TestAbstract unmarshal(String v) throws Exception {

-        return (TestAbstract)this.getClass().getClassLoader().loadClass(v).newInstance();

+public class TestAdapter extends XmlAdapter<TestAbstractImpl, TestAbstract> {

+    public TestAbstract unmarshal(TestAbstractImpl ai) throws Exception {

+        TestAbstract a = (TestAbstract)this.getClass().getClassLoader().loadClass(ai.className).newInstance();

+        a.sender = ai.someMessage;

+        return a;

     }

-    public String marshal(TestAbstract v) throws Exception {

-        return v.getClass().getName();

+    public TestAbstractImpl marshal(TestAbstract v) throws Exception {

+        TestAbstractImpl ai = new TestAbstractImpl();

+        ai.className = v.getClass().getName();

+        ai.someMessage = "YouKnowWho";

+        return ai;

     }

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestClient.java b/itest/jaxws/src/main/java/jtest/TestClient.java
index 7a54553..9839e98 100644
--- a/itest/jaxws/src/main/java/jtest/TestClient.java
+++ b/itest/jaxws/src/main/java/jtest/TestClient.java
@@ -26,5 +26,7 @@
 

     void runAbstractTypeTest();

 

+/*

     void runAbstractExceptionTest();

+*/

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestConcrete1.java b/itest/jaxws/src/main/java/jtest/TestConcrete1.java
index 47cf3db..2193316 100644
--- a/itest/jaxws/src/main/java/jtest/TestConcrete1.java
+++ b/itest/jaxws/src/main/java/jtest/TestConcrete1.java
@@ -24,7 +24,7 @@
  */

 public class TestConcrete1 extends TestAbstract {

 

-    public String getGreeting() {

-        return "Hello";

+    public TestConcrete1() {

+        greeting = "Hello";

     }

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestConcrete2.java b/itest/jaxws/src/main/java/jtest/TestConcrete2.java
index 660ecf3..059d18d 100644
--- a/itest/jaxws/src/main/java/jtest/TestConcrete2.java
+++ b/itest/jaxws/src/main/java/jtest/TestConcrete2.java
@@ -24,7 +24,7 @@
  */

 public class TestConcrete2 extends TestAbstract {

 

-    public String getGreeting() {

-        return "World";

+    public TestConcrete2() {

+        greeting = "World";

     }

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestService.java b/itest/jaxws/src/main/java/jtest/TestService.java
index 69488bb..ac5a01c 100644
--- a/itest/jaxws/src/main/java/jtest/TestService.java
+++ b/itest/jaxws/src/main/java/jtest/TestService.java
@@ -30,7 +30,9 @@
 @Remotable

 public interface TestService {

 

-    void sendAbstract(TestAbstract data1, TestAbstract data2);

+    void sendAbstract(TestAbstract data);

 

+/*

     void throwAbstract() throws AbstractException;

+*/

 }

diff --git a/itest/jaxws/src/main/java/jtest/TestWebService.java b/itest/jaxws/src/main/java/jtest/TestWebService.java
new file mode 100644
index 0000000..cd7b1f3
--- /dev/null
+++ b/itest/jaxws/src/main/java/jtest/TestWebService.java
@@ -0,0 +1,29 @@
+/*

+ * 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.jws.WebMethod;

+import javax.jws.WebService;

+

+@WebService

+public interface TestWebService {

+

+    @WebMethod

+    void sendAbstract(TestAbstract testData);

+}

diff --git a/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java b/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java
index 2eadd43..278f94f 100644
--- a/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java
+++ b/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java
@@ -39,10 +39,16 @@
 

     public void runAbstractTypeTest() {

         TestConcrete1 data1 = new TestConcrete1();

+        data1.firstName = "Bill";

+        data1.lastName = "Brown";

+        ref.sendAbstract(data1);

         TestConcrete2 data2 = new TestConcrete2();

-        ref.sendAbstract(data1, data2);

+        data2.firstName = "Sam";

+        data2.lastName = "Smith";

+        ref.sendAbstract(data2);

     }

 

+/*

     public void runAbstractExceptionTest() {

         try {

             ref.throwAbstract();

@@ -51,4 +57,5 @@
             System.out.println(e.getGreeting());

         }

     }

+*/

 }

diff --git a/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java b/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java
index dc51ae0..356b32d 100644
--- a/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java
+++ b/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java
@@ -32,13 +32,16 @@
 @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());

+    public void sendAbstract(TestAbstract data) {

+        System.out.println("data is instance of class " + data.getClass().getName());

+        System.out.println("data sent by " + data.sender);

+        System.out.println("data first+last name is " + data.firstName + " " + data.lastName);

+        System.out.println(data.getGreeting());

     }

 

+/*

     public void throwAbstract() throws AbstractException {

         throw new ConcreteException();

     }

+*/

 }

diff --git a/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java b/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java
new file mode 100644
index 0000000..974279c
--- /dev/null
+++ b/itest/jaxws/src/main/java/jtest/impl/TestWebServiceImpl.java
@@ -0,0 +1,32 @@
+/*

+ * 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 javax.jws.WebService;

+

+import jtest.TestAbstract;

+import jtest.TestWebService;

+

+@WebService(endpointInterface = "jtest.TestWebService")

+public class TestWebServiceImpl implements TestWebService {

+

+    public void sendAbstract(TestAbstract testData) {

+        System.out.println(testData.getGreeting());

+    }

+}

diff --git a/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java b/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java
index 6886d17..7ffcbeb 100644
--- a/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java
+++ b/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java
@@ -19,6 +19,7 @@
 

 package jtest;

 

+import org.apache.tuscany.sca.binding.ws.wsdlgen.WSDLServiceGenerator;

 import org.apache.tuscany.sca.node.SCAClient;

 import org.apache.tuscany.sca.node.SCAContribution;

 import org.apache.tuscany.sca.node.SCANode;

@@ -33,7 +34,8 @@
 

     @BeforeClass

     public static void setUpBeforeClass() throws Exception {

-        node = SCANodeFactory.newInstance().createSCANode("jtest.composite", 

+    WSDLServiceGenerator.printWSDL = true;

+    node = SCANodeFactory.newInstance().createSCANode("jtest.composite", 

                 new SCAContribution("payment", "./target/classes"));

         node.start();

     }

@@ -45,13 +47,14 @@
         testClient.runAbstractTypeTest();

     }

 

+/*

     @Test

-    @Ignore

     public void runAbstractExceptionTest() {

         SCAClient client = (SCAClient)node;

         TestClient testClient = client.getService(TestClient.class, "TestClient");

         testClient.runAbstractExceptionTest();

     }

+*/

     

     @AfterClass

     public static void tearDownAfterClass() throws Exception {