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 2014/12/12 20:37:23 UTC

[4/5] cxf git commit: CXF-6138 JAXB unmarshaller Properties get overwriten on a call to initialize()

CXF-6138 JAXB unmarshaller Properties get overwriten on a call to initialize()


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d8f5b21a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d8f5b21a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d8f5b21a

Branch: refs/heads/3.0.x-fixes
Commit: d8f5b21ac808cb8a905b0c6a3a0bd4fb2e1c568b
Parents: 6463da8
Author: paul <pk...@gmail.com>
Authored: Sat Dec 6 22:04:08 2014 +0000
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri Dec 12 14:37:09 2014 -0500

----------------------------------------------------------------------
 .../org/apache/cxf/jaxb/JAXBDataBinding.java    |  8 +++-
 .../DataBindingMarshallerPropertiesTest.java    | 39 ++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d8f5b21a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
index bae0752..38f5cdb 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
@@ -304,8 +304,12 @@ public class JAXBDataBinding extends AbstractInterceptorProvidingDataBinding
 
 
         contextClasses = new LinkedHashSet<Class<?>>();
-        Map<String, Object> unmarshallerProps = new HashMap<String, Object>();
-        this.setUnmarshallerProperties(unmarshallerProps);
+        
+        if (this.getUnmarshallerProperties() == null || this.getUnmarshallerProperties().isEmpty()) {
+            Map<String, Object> unmarshallerProps = new HashMap<String, Object>();
+            this.setUnmarshallerProperties(unmarshallerProps);
+        }
+        
         for (ServiceInfo serviceInfo : service.getServiceInfos()) {
             
             JAXBContextInitializer initializer

http://git-wip-us.apache.org/repos/asf/cxf/blob/d8f5b21a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java
new file mode 100644
index 0000000..82b594b
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.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.cxf.jaxb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class DataBindingMarshallerPropertiesTest extends TestBase {
+    @Test 
+    public void testInitializeUnmarshallerProperties() throws Exception {
+        JAXBDataBinding db = new JAXBDataBinding();
+        Map<String, Object> unmarshallerProperties = new HashMap<String, Object>();
+        unmarshallerProperties.put("someproperty", "somevalue");
+        db.setUnmarshallerProperties(unmarshallerProperties);
+        
+        db.initialize(service);
+        
+        assertTrue("somevalue".equals(db.getUnmarshallerProperties().get("someproperty")));
+    }
+}