You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2016/01/28 21:17:40 UTC
[1/2] cxf git commit: Update some versions used for testing
Repository: cxf
Updated Branches:
refs/heads/master dd167df85 -> 25c151ed9
Update some versions used for testing
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f98785bd
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f98785bd
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f98785bd
Branch: refs/heads/master
Commit: f98785bd8490c4717353f1a9688cae3e7a823ec2
Parents: dd167df
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jan 28 12:37:29 2016 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Jan 28 12:37:40 2016 -0500
----------------------------------------------------------------------
parent/pom.xml | 2 +-
rt/transports/jms/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/f98785bd/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index ec60317..ffb7c60 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -66,7 +66,7 @@
<cxf.osgi.javax.xml.ws.version>[0.0,3)</cxf.osgi.javax.xml.ws.version>
<!-- please maintain alphabetical order here -->
<cxf.abdera.version>1.1.3</cxf.abdera.version>
- <cxf.activemq.version>5.12.0</cxf.activemq.version>
+ <cxf.activemq.version>5.12.1</cxf.activemq.version>
<cxf.ahc.version>1.9.8</cxf.ahc.version>
<cxf.apacheds.version>2.0.0-M21</cxf.apacheds.version>
<cxf.atmosphere.version>2.3.5</cxf.atmosphere.version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/f98785bd/rt/transports/jms/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/jms/pom.xml b/rt/transports/jms/pom.xml
index 3ba997c..4b2df8a 100644
--- a/rt/transports/jms/pom.xml
+++ b/rt/transports/jms/pom.xml
@@ -119,7 +119,7 @@
<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-transaction</artifactId>
- <version>3.1.1</version>
+ <version>3.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
[2/2] cxf git commit: Add some test cases for CXF-6764 and log a
message if the mapper fails
Posted by dk...@apache.org.
Add some test cases for CXF-6764 and log a message if the mapper fails
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/25c151ed
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/25c151ed
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/25c151ed
Branch: refs/heads/master
Commit: 25c151ed9fdb2147564f50fb7ec97d3cec6bbd98
Parents: f98785b
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jan 28 15:17:11 2016 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Jan 28 15:17:11 2016 -0500
----------------------------------------------------------------------
.../org/apache/cxf/common/jaxb/JAXBUtils.java | 31 ++++---
.../apache/cxf/jaxb/JAXBDataBindingTest.java | 91 +++++++++++++++++---
2 files changed, 97 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/25c151ed/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index 6440c37..f8a21d0 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -74,6 +74,7 @@ import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.ASMHelper;
import org.apache.cxf.common.util.ASMHelper.ClassWriter;
import org.apache.cxf.common.util.ASMHelper.FieldVisitor;
@@ -91,6 +92,7 @@ import org.apache.cxf.common.xmlschema.SchemaCollection;
import org.apache.cxf.helpers.JavaUtils;
public final class JAXBUtils {
+ public static final Logger LOG = LogUtils.getL7dLogger(JAXBUtils.class);
public enum IdentifierType {
CLASS,
@@ -623,15 +625,17 @@ public final class JAXBUtils {
public static Object setNamespaceMapper(final Map<String, String> nspref,
Marshaller marshaller) throws PropertyException {
Object mapper = createNamespaceWrapper(marshaller.getClass(), nspref);
- if (marshaller.getClass().getName().contains(".internal.")) {
- marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",
- mapper);
- } else if (marshaller.getClass().getName().contains("com.sun")) {
- marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
- mapper);
- } else if (marshaller.getClass().getName().contains("eclipse")) {
- marshaller.setProperty("eclipselink.namespace-prefix-mapper",
- mapper);
+ if (mapper != null) {
+ if (marshaller.getClass().getName().contains(".internal.")) {
+ marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",
+ mapper);
+ } else if (marshaller.getClass().getName().contains("com.sun")) {
+ marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
+ mapper);
+ } else if (marshaller.getClass().getName().contains("eclipse")) {
+ marshaller.setProperty("eclipselink.namespace-prefix-mapper",
+ mapper);
+ }
}
return mapper;
}
@@ -1084,6 +1088,7 @@ public final class JAXBUtils {
String className = "org.apache.cxf.jaxb.NamespaceMapper";
className += postFix;
Class<?> cls = helper.findClass(className, JAXBUtils.class);
+ Throwable t = null;
if (cls == null) {
try {
ClassWriter cw = helper.createClassWriter();
@@ -1092,15 +1097,17 @@ public final class JAXBUtils {
}
} catch (RuntimeException ex) {
// continue
+ t = ex;
}
}
if (cls == null
- && (mcls.getName().contains(".internal.") || mcls.getName().contains("com.sun"))) {
+ && (!mcls.getName().contains(".internal.") && mcls.getName().contains("com.sun"))) {
try {
cls = ClassLoaderUtils.loadClass("org.apache.cxf.common.jaxb.NamespaceMapper",
JAXBUtils.class);
- } catch (ClassNotFoundException ex2) {
+ } catch (Throwable ex2) {
// ignore
+ t = ex2;
}
}
if (cls != null) {
@@ -1108,8 +1115,10 @@ public final class JAXBUtils {
return cls.getConstructor(Map.class).newInstance(map);
} catch (Exception e) {
// ignore
+ t = e;
}
}
+ LOG.log(Level.INFO, "Could not create a NamespaceMapper compatible with Marshaller class " + mcls.getName(), t);
return null;
}
/*
http://git-wip-us.apache.org/repos/asf/cxf/blob/25c151ed/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
index 4621481..980f2de 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
@@ -38,6 +38,7 @@ import javax.wsdl.Definition;
import javax.wsdl.Service;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
+import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -54,6 +55,8 @@ import org.w3c.dom.Node;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.BindingFactoryManager;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ASMHelper;
+import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.databinding.DataReader;
import org.apache.cxf.databinding.DataWriter;
import org.apache.cxf.helpers.CastUtils;
@@ -205,32 +208,92 @@ public class JAXBDataBindingTest extends Assert {
assertTrue(xml, xml.contains("uri:ultima:thule"));
}
- @Test
- public void testDeclaredNamespaceMapping() throws Exception {
+ JAXBDataBinding createJaxbContext(boolean internal) throws Exception {
JAXBDataBinding db = new JAXBDataBinding();
Map<String, String> nsMap = new HashMap<String, String>();
nsMap.put("uri:ultima:thule", "greenland");
db.setNamespaceMap(nsMap);
Map<String, Object> contextProperties = new HashMap<String, Object>();
- //contextProperties.put("com.sun.xml.bind.defaultNamespaceRemap", "uri:ultima:thule");
db.setContextProperties(contextProperties);
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(QualifiedBean.class);
- db.setContext(db.createJAXBContext(classes));
- DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
- XMLOutputFactory writerFactory = XMLOutputFactory.newInstance();
- StringWriter stringWriter = new StringWriter();
- XMLStreamWriter xmlWriter = writerFactory.createXMLStreamWriter(stringWriter);
- QualifiedBean bean = new QualifiedBean();
- bean.setAriadne("spider");
- writer.write(bean, xmlWriter);
- xmlWriter.flush();
- String xml = stringWriter.toString();
- assertTrue(xml, xml.contains("greenland=\"uri:ultima:thule"));
+
+ //have to fastboot to avoid conflicts of generated accessors
+ System.setProperty("com.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot", "true");
+ System.setProperty("com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.fastBoot", "true");
+ if (internal) {
+ System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, "com.sun.xml.internal.bind.v2.ContextFactory");
+ db.setContext(db.createJAXBContext(classes));
+ System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY);
+ } else {
+ db.setContext(db.createJAXBContext(classes));
+ }
+ System.clearProperty("com.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot");
+ System.clearProperty("com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.fastBoot");
+ return db;
}
+ void doNamespaceMappingTest(boolean internal, boolean asm) throws Exception {
+ if (internal) {
+ try {
+ Class.forName("com.sun.xml.internal.bind.v2.ContextFactory");
+ } catch (Throwable t) {
+ //on a JVM (likely IBM's) that doesn't rename the ContextFactory package to include "internal"
+ return;
+ }
+ }
+ try {
+ if (!asm) {
+ ReflectionUtil.setAccessible(ReflectionUtil.getDeclaredField(ASMHelper.class, "badASM"))
+ .set(null, Boolean.TRUE);
+ }
+
+ JAXBDataBinding db = createJaxbContext(internal);
+
+ DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
+ XMLOutputFactory writerFactory = XMLOutputFactory.newInstance();
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter xmlWriter = writerFactory.createXMLStreamWriter(stringWriter);
+ QualifiedBean bean = new QualifiedBean();
+ bean.setAriadne("spider");
+ writer.write(bean, xmlWriter);
+ xmlWriter.flush();
+ String xml = stringWriter.toString();
+ assertTrue("Failed to map namespace " + xml, xml.contains("greenland=\"uri:ultima:thule"));
+ } finally {
+ if (!asm) {
+ ReflectionUtil.setAccessible(ReflectionUtil.getDeclaredField(ASMHelper.class, "badASM"))
+ .set(null, Boolean.FALSE);
+ }
+ }
+ }
+
+ @Test
+ public void testDeclaredNamespaceMappingRI() throws Exception {
+ doNamespaceMappingTest(false, true);
+ }
@Test
+ public void testDeclaredNamespaceMappingInternal() throws Exception {
+ doNamespaceMappingTest(true, true);
+ }
+ @Test
+ public void testDeclaredNamespaceMappingRINoAsm() throws Exception {
+ doNamespaceMappingTest(false, false);
+ }
+
+ @Test
+ public void testDeclaredNamespaceMappingInternalNoAsm() throws Exception {
+ try {
+ doNamespaceMappingTest(true, false);
+ fail("Internal needs ASM");
+ } catch (AssertionError er) {
+ er.getMessage().contains("Failed to map namespace");
+ }
+ }
+
+
+ @Test
public void testResursiveType() throws Exception {
Set<Class<?>> classes = new HashSet<Class<?>>();
Collection<Object> typeReferences = new ArrayList<Object>();