Author: jim.ma
Date: 2014-02-10 21:57:55 -0500 (Mon, 10 Feb 2014)
New Revision: 18336
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Cl1ToCl2Adapter.java
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass1.java
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass2.java
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterEcho.java
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterException.java
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Log:
[JBPAPP-10973][CXF-5219]:@XmlJavaTypeAdapter ignored for exception members
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java 2014-02-10
11:02:18 UTC (rev 18335)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -366,6 +366,14 @@
Field fields[] = cls.getDeclaredFields();
for (Field f : fields) {
if (isFieldAccepted(f, accessType)) {
+ XmlJavaTypeAdapter xjta = Utils.getFieldXJTA(f);
+ if (xjta != null) {
+ Type t = Utils.getTypeFromXmlAdapter(xjta);
+ if (t != null) {
+ addType(t);
+ continue;
+ }
+ }
addType(f.getGenericType());
}
}
@@ -376,6 +384,14 @@
Method methods[] = cls.getDeclaredMethods();
for (Method m : methods) {
if (isMethodAccepted(m, accessType)) {
+ XmlJavaTypeAdapter xjta = Utils.getMethodXJTA(m);
+ if (xjta != null) {
+ Type t = Utils.getTypeFromXmlAdapter(xjta);
+ if (t != null) {
+ addType(t);
+ continue;
+ }
+ }
addType(m.getGenericReturnType());
for (Type t : m.getGenericParameterTypes()) {
addType(t);
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Cl1ToCl2Adapter.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Cl1ToCl2Adapter.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Cl1ToCl2Adapter.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -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 org.apache.cxf.tools.fortest.exception;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class Cl1ToCl2Adapter extends XmlAdapter<MyClass2, MyClass1> {
+ @Override
+ public MyClass1 unmarshal(MyClass2 v) throws Exception {
+ MyClass1 mc1 = new MyClass1();
+ mc1.setName(v.getFile());
+ return mc1;
+ }
+
+ @Override
+ public MyClass2 marshal(MyClass1 v) throws Exception {
+ MyClass2 mc2 = new MyClass2();
+ mc2.setFile(v.getName());
+ return mc2;
+ }
+}
Property changes on:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Cl1ToCl2Adapter.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass1.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass1.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass1.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -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 org.apache.cxf.tools.fortest.exception;
+
+public class MyClass1 {
+ private String name;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Property changes on:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass1.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass2.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass2.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass2.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -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 org.apache.cxf.tools.fortest.exception;
+
+public class MyClass2 {
+ private String file;
+
+ public String getFile() {
+ return this.file;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+}
Property changes on:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyClass2.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterEcho.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterEcho.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterEcho.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -0,0 +1,26 @@
+/**
+ * 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.cxf.tools.fortest.exception;
+
+import javax.jws.WebService;
+
+@WebService
+public interface TypeAdapterEcho {
+ void test() throws TypeAdapterException;
+}
Property changes on:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterEcho.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterException.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterException.java
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterException.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -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 org.apache.cxf.tools.fortest.exception;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+public class TypeAdapterException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private MyClass1 adapted;
+
+ @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
+ public MyClass1 getAdapted() {
+ return this.adapted;
+ }
+
+ public void setAdapted(MyClass1 adapted) {
+ this.adapted = adapted;
+ }
+}
Property changes on:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/TypeAdapterException.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java 2014-02-10
11:02:18 UTC (rev 18335)
+++
thirdparty/cxf/branches/cxf-2.2.12/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java 2014-02-11
02:57:55 UTC (rev 18336)
@@ -21,7 +21,9 @@
import java.io.File;
import java.net.URI;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.Port;
@@ -30,12 +32,15 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.apache.cxf.common.WSDLConstants;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.WSDLHelper;
import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.XPathUtils;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.tools.common.ProcessorTestBase;
import org.apache.cxf.tools.common.ToolConstants;
import org.apache.cxf.tools.common.ToolContext;
@@ -625,4 +630,33 @@
assertTrue(xsd, xsd.indexOf("ref=") == -1);
}
+
+ @Test
+ public void testExceptionTypeAdapter() throws Exception {
+ env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() +
"/exception-type-adapter.wsdl");
+ env.put(ToolConstants.CFG_CLASSNAME,
"org.apache.cxf.tools.fortest.exception.TypeAdapterEcho");
+ env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+ try {
+ processor.setEnvironment(env);
+ processor.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ File wsdlFile = new File(output, "exception-type-adapter.wsdl");
+ assertTrue(wsdlFile.exists());
+ Document doc = StaxUtils.read(new java.io.FileInputStream(wsdlFile));
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("xsd", "http://www.w3.org/2001/XMLSchema");
+ XPathUtils util = new XPathUtils(map);
+ Node nd =
util.getValueNode("//xsd:complexType[@name='myClass2']", doc);
+ assertNotNull(nd);
+
+ nd = util.getValueNode("//xsd:element[@name='adapted']", doc);
+ assertNotNull(nd);
+
+ String at = ((Element)nd).getAttribute("type");
+ assertTrue(at.contains("myClass2"));
+ assertEquals("true",
((Element)nd).getAttribute("nillable"));
+ }
}