Merge remaining r743192 changes from 2.x to 1.x and add a new itest for @XmlJavaTypeAdapter

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk@1028105 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
new file mode 100644
index 0000000..a633908
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/TestAdapter.java b/itest/jaxws/src/main/java/jtest/TestAdapter.java
new file mode 100644
index 0000000..2c5e52c
--- /dev/null
+++ b/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<String, TestAbstract> {

+    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/itest/jaxws/src/main/java/jtest/TestClient.java b/itest/jaxws/src/main/java/jtest/TestClient.java
new file mode 100644
index 0000000..6eedfc1
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/TestConcrete1.java b/itest/jaxws/src/main/java/jtest/TestConcrete1.java
new file mode 100644
index 0000000..47cf3db
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/TestConcrete2.java b/itest/jaxws/src/main/java/jtest/TestConcrete2.java
new file mode 100644
index 0000000..660ecf3
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/TestService.java b/itest/jaxws/src/main/java/jtest/TestService.java
new file mode 100644
index 0000000..90b2e01
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java b/itest/jaxws/src/main/java/jtest/impl/TestClientImpl.java
new file mode 100644
index 0000000..7249cfc
--- /dev/null
+++ b/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/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java b/itest/jaxws/src/main/java/jtest/impl/TestServiceImpl.java
new file mode 100644
index 0000000..3cc8ca0
--- /dev/null
+++ b/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/itest/jaxws/src/main/resources/jtest.composite b/itest/jaxws/src/main/resources/jtest.composite
new file mode 100644
index 0000000..74aee98
--- /dev/null
+++ b/itest/jaxws/src/main/resources/jtest.composite
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--

+ * 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.    

+-->

+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" 

+           targetNamespace="http://jtest/"

+           name="jtest">

+           

+    <component name="TestClient">

+        <implementation.java class="jtest.impl.TestClientImpl" />

+        <reference name="ref">

+            <binding.ws uri="http://localhost:8081/TestService" />

+        </reference>

+    </component>

+

+    <component name="TestService">

+        <implementation.java class="jtest.impl.TestServiceImpl" />

+        <service name="TestService">

+            <binding.ws uri="http://localhost:8081/TestService" />

+        </service>

+    </component>

+    

+</composite>

diff --git a/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java b/itest/jaxws/src/test/java/jtest/DatatypesTestCase.java
new file mode 100644
index 0000000..7a9f27d
--- /dev/null
+++ b/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/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java b/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java
new file mode 100644
index 0000000..71a860d
--- /dev/null
+++ b/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/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java b/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java
new file mode 100644
index 0000000..684f7b4
--- /dev/null
+++ b/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/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java b/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java
new file mode 100644
index 0000000..c1314d7
--- /dev/null
+++ b/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<BeanInterfaceImpl, BeanInterface> {

+

+    @Override

+    public BeanInterfaceImpl marshal(BeanInterface v) throws Exception {

+        return (BeanInterfaceImpl)v;

+    }

+

+    @Override

+    public BeanInterface unmarshal(BeanInterfaceImpl v) throws Exception {

+        return v;

+    }

+

+}

diff --git a/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java b/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java
index a6a3375..5c20892 100644
--- a/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java
+++ b/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java
@@ -27,6 +27,7 @@
 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 @@
     
     @WebMethod
     @WebResult(name = "output")
-    String webMethod(@WebParam(name = "input", mode = WebParam.Mode.IN)
-    String in, @WebParam(name = "holder", mode = WebParam.Mode.INOUT)
-    Holder<String> holder);
+    String webMethod(@WebParam(name = "input", mode = WebParam.Mode.IN) String in,
+                     @WebParam(name = "holder", mode = WebParam.Mode.INOUT) Holder<String> holder);
+
+    @XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class)
+    BeanInterface beanMethod(@XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class) BeanInterface in,
+                             String str);
 }