wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r813395 - in /incubator/wink/trunk: wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/ wink-common/src/main/java/org/apache/wink/common/model/ wink-common/src/test/java/org/apache/wink/common/model/app/ wink-com...
Date Thu, 10 Sep 2009 12:06:57 GMT
Author: elman
Date: Thu Sep 10 12:06:56 2009
New Revision: 813395

URL: http://svn.apache.org/viewvc?rev=813395&view=rev
Log:
Refactoring of XmlFormattingOptions. Related to [WINK-169]

Added:
    incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/FormattingOptionsContextResolver.java
    incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/FormattingOptionsContextResolver.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java
  (with props)
Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/XmlFormattingOptions.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java
    incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/JaxbTest.java
    incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/PreconditionsTest.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBProvider.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
Thu Sep 10 12:06:56 2009
@@ -41,9 +41,12 @@
 import javax.xml.namespace.QName;
 
 import org.apache.wink.common.internal.i18n.Messages;
+import org.apache.wink.common.internal.utils.JAXBUtils;
 import org.apache.wink.common.internal.utils.MediaTypeUtils;
 import org.apache.wink.common.internal.utils.SimpleMap;
 import org.apache.wink.common.internal.utils.SoftConcurrentMap;
+import org.apache.wink.common.model.XmlFormattingOptions;
+import org.apache.wink.common.utils.ProviderUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -73,7 +76,22 @@
     protected final Marshaller getMarshaller(Class<?> type, MediaType mediaType)
         throws JAXBException {
         JAXBContext context = getContext(type, mediaType);
-        return context.createMarshaller();
+        Marshaller marshaller = context.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_ENCODING, ProviderUtils.getCharset(mediaType));
+
+        ContextResolver<XmlFormattingOptions> contextResolver =
+            providers.getContextResolver(XmlFormattingOptions.class, mediaType);
+        XmlFormattingOptions formatingOptions = null;
+        if (contextResolver != null) {
+            formatingOptions = contextResolver.getContext(type);
+        }
+        if (formatingOptions != null) {
+            JAXBUtils.setXmlFormattingOptions(marshaller, formatingOptions);
+        } else {
+            JAXBUtils.setXmlFormattingOptions(marshaller, XmlFormattingOptions
+                .getDefaultXmlFormattingOptions());
+        }
+        return marshaller;
     }
 
     protected boolean isSupportedMediaType(MediaType mediaType) {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
Thu Sep 10 12:06:56 2009
@@ -41,9 +41,6 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.wink.common.internal.i18n.Messages;
-import org.apache.wink.common.internal.utils.JAXBUtils;
-import org.apache.wink.common.model.XmlFormattingOptions;
-import org.apache.wink.common.utils.ProviderUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,14 +107,8 @@
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         try {
             Marshaller marshaller = getMarshaller(type, mediaType);
-
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, ProviderUtils.getCharset(mediaType));
-
             Object entityToMarshal = getEntityToMarshal(t, type);
 
-            JAXBUtils.setXmlFormattingOptions(marshaller, XmlFormattingOptions
-                .getDefaultXmlFormattingOptions());
-
             // Use an OutputStream directly instead of a Writer for performance.
             marshaller.marshal(entityToMarshal, entityStream);
         } catch (JAXBException e) {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/XmlFormattingOptions.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/XmlFormattingOptions.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/XmlFormattingOptions.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/XmlFormattingOptions.java
Thu Sep 10 12:06:56 2009
@@ -32,10 +32,10 @@
  */
 public class XmlFormattingOptions implements Cloneable {
 
-    private boolean                     omitXmlDeclaration;
-    private boolean                     indenting;
-
-    private static XmlFormattingOptions defaultXmlFormattingOptions = new XmlFormattingOptions();
+    private final boolean                     omitXmlDeclaration;
+    private final boolean                     indenting;
+    private final static XmlFormattingOptions defaultXmlFormattingOptions =
+                                                                              new XmlFormattingOptions();
 
     public XmlFormattingOptions() {
         this(true, true);
@@ -50,31 +50,11 @@
         return indenting;
     }
 
-    public void setIndenting(boolean indenting) {
-        this.indenting = indenting;
-    }
-
-    public static XmlFormattingOptions getDefaultXmlFormattingOptions() {
-        return defaultXmlFormattingOptions.safeClone();
-    }
-
-    public static void setDefaultXmlFormattingOptions(XmlFormattingOptions defaultXmlFormattingOptions)
{
-        XmlFormattingOptions.defaultXmlFormattingOptions = defaultXmlFormattingOptions.safeClone();
-    }
-
-    public void setOmitXmlDeclaration(boolean omitXmlDeclaration) {
-        this.omitXmlDeclaration = omitXmlDeclaration;
-    }
-
     public boolean isOmitXmlDeclaration() {
         return omitXmlDeclaration;
     }
 
-    private XmlFormattingOptions safeClone() {
-        try {
-            return (XmlFormattingOptions)this.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e); // this can not happen
-        }
+    public static XmlFormattingOptions getDefaultXmlFormattingOptions() {
+        return defaultXmlFormattingOptions;
     }
 }

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
Thu Sep 10 12:06:56 2009
@@ -25,7 +25,9 @@
 import java.io.StringReader;
 import java.util.List;
 
+import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
@@ -34,6 +36,7 @@
 
 import org.apache.wink.common.RestException;
 import org.apache.wink.common.internal.model.ModelUtils;
+import org.apache.wink.common.internal.utils.JAXBUtils;
 import org.apache.wink.common.model.atom.AtomCategory;
 import org.apache.wink.common.model.atom.AtomText;
 import org.apache.wink.test.mock.TestUtils;
@@ -89,20 +92,18 @@
                                                          + "    </workspace>\n"
                                                          + "</service>\n";
 
-    // private static JAXBContext ctx;
-    //    
-    // static {
-    // try {
-    // ctx = JAXBContext.newInstance(AppService.class.getPackage().getName());
-    // } catch (JAXBException e) {
-    // throw new RuntimeException(e);
-    // }
-    // }
+    private static JAXBContext  ctx;
+
+    static {
+        try {
+            ctx = JAXBContext.newInstance(AppService.class.getPackage().getName());
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
     public void testAppMarshal() throws Exception {
-        // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new
-        // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_APP));
-        Marshaller m = AppService.getMarshaller();
+        Marshaller m = JAXBUtils.createMarshaller(ctx);
 
         AppService service = getService();
         JAXBElement<AppService> element = (new ObjectFactory()).createService(service);
@@ -113,8 +114,7 @@
     }
 
     public void testAppUnmarshal() throws IOException {
-        // Unmarshaller u = AtomJAXBUtils.createUnmarshaller(ctx);
-        Unmarshaller u = AppService.getUnmarshaller();
+        Unmarshaller u = JAXBUtils.createUnmarshaller(ctx);
         Object element = ModelUtils.unmarshal(u, new StringReader(SERVICE_DOCUMENT));
         assertNotNull(element);
         assertTrue(element instanceof AppService);
@@ -126,11 +126,8 @@
     }
 
     public void testAppUnmarshalMarshal() throws Exception {
-        // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new
-        // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_APP));
-        Marshaller m = AppService.getMarshaller();
-        // Unmarshaller u = AtomJAXBUtils.createUnmarshaller(ctx);
-        Unmarshaller u = AppService.getUnmarshaller();
+        Marshaller m = JAXBUtils.createMarshaller(ctx);
+        Unmarshaller u = JAXBUtils.createUnmarshaller(ctx);
 
         Object service = ModelUtils.unmarshal(u, new StringReader(SERVICE_DOCUMENT));
         JAXBElement<AppService> element = (new ObjectFactory()).createService((AppService)service);

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java
Thu Sep 10 12:06:56 2009
@@ -25,7 +25,9 @@
 import java.io.StringReader;
 import java.math.BigInteger;
 
+import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
@@ -33,6 +35,7 @@
 import junit.framework.TestCase;
 
 import org.apache.wink.common.internal.model.ModelUtils;
+import org.apache.wink.common.internal.utils.JAXBUtils;
 import org.apache.wink.test.mock.TestUtils;
 
 public class OpenSearchTest extends TestCase {
@@ -59,26 +62,18 @@
                                                    + "    <InputEncoding>input encoding
2</InputEncoding>\n"
                                                    + "</OpenSearchDescription>\n";
 
-    // private static JAXBContext ctx;
-    //    
-    // static {
-    // try {
-    // ctx =
-    // JAXBContext.newInstance(OpenSearchDescription.class.getPackage().getName());
-    // } catch (JAXBException e) {
-    // throw new RuntimeException(e);
-    // }
-    // }
+    private static JAXBContext  ctx;
+
+    static {
+        try {
+            ctx = JAXBContext.newInstance(OpenSearchDescription.class.getPackage().getName());
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
     public void testOpenSearchMarshal() throws Exception {
-        // Map<String,String> p2n = new HashMap<String,String>();
-        // p2n.put("otherAttrNs", "other");
-        // JAXBNamespacePrefixMapper namespacePrefixMapper =
-        // new JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_OPENSEARCH,
-        // p2n);
-        // Marshaller m = AtomJAXBUtils.createMarshaller(ctx,
-        // namespacePrefixMapper);
-        Marshaller m = OpenSearchDescription.getMarshaller();
+        Marshaller m = JAXBUtils.createMarshaller(ctx);
 
         OpenSearchDescription osd = getOpenSearchDescription();
         JAXBElement<OpenSearchDescription> element =
@@ -90,8 +85,7 @@
     }
 
     public void testOpenSearchUnmarshal() throws IOException {
-        // Unmarshaller u = AtomJAXBUtils.createUnmarshaller(ctx);
-        Unmarshaller u = OpenSearchDescription.getUnmarshaller();
+        Unmarshaller u = JAXBUtils.createUnmarshaller(ctx);
         Object element = ModelUtils.unmarshal(u, new StringReader(OPENSEARCH));
         assertNotNull(element);
         assertTrue(element instanceof OpenSearchDescription);
@@ -103,11 +97,8 @@
     }
 
     public void testOpenSearchUnmarshalMarshal() throws Exception {
-        // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new
-        // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_OPENSEARCH));
-        Marshaller m = OpenSearchDescription.getMarshaller();
-        // Unmarshaller u = AtomJAXBUtils.createUnmarshaller(ctx);
-        Unmarshaller u = OpenSearchDescription.getUnmarshaller();
+        Marshaller m = JAXBUtils.createMarshaller(ctx);
+        Unmarshaller u = JAXBUtils.createUnmarshaller(ctx);
 
         Object service = ModelUtils.unmarshal(u, new StringReader(OPENSEARCH));
         JAXBElement<OpenSearchDescription> element =

Added: incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/FormattingOptionsContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/FormattingOptionsContextResolver.java?rev=813395&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/FormattingOptionsContextResolver.java
(added)
+++ incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/FormattingOptionsContextResolver.java
Thu Sep 10 12:06:56 2009
@@ -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 org.apache.wink.example.jaxb;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.wink.common.model.XmlFormattingOptions;
+
+@Provider
+public class FormattingOptionsContextResolver implements ContextResolver<XmlFormattingOptions>
{
+
+    public XmlFormattingOptions getContext(Class<?> type) {
+
+        if (type.getPackage().getName().equals(JaxbResource.class.getPackage().getName()))
{
+            return new XmlFormattingOptions(false, false);
+        }
+
+        return null;
+    }
+
+}

Modified: incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/JaxbTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/JaxbTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/JaxbTest.java
(original)
+++ incubator/wink/trunk/wink-examples/core/Jaxb/src/test/java/org/apache/wink/example/jaxb/JaxbTest.java
Thu Sep 10 12:06:56 2009
@@ -23,8 +23,6 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.apache.wink.common.model.XmlFormattingOptions;
-import org.apache.wink.example.jaxb.JaxbResource;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.apache.wink.test.mock.TestUtils;
@@ -54,13 +52,12 @@
 
     @Override
     protected Class<?>[] getClasses() {
-        return new Class[] {JaxbResource.class};
+        return new Class[] {JaxbResource.class, FormattingOptionsContextResolver.class};
     }
     
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        XmlFormattingOptions.setDefaultXmlFormattingOptions(new XmlFormattingOptions(false,
false));
     }
 
     public void testAllGet() throws Exception {

Added: incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/FormattingOptionsContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/FormattingOptionsContextResolver.java?rev=813395&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/FormattingOptionsContextResolver.java
(added)
+++ incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/FormattingOptionsContextResolver.java
Thu Sep 10 12:06:56 2009
@@ -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.wink.example.locking;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.wink.common.model.XmlFormattingOptions;
+import org.apache.wink.example.locking.legacy.DefectBean;
+
+@Provider
+public class FormattingOptionsContextResolver implements ContextResolver<XmlFormattingOptions>
{
+
+    public XmlFormattingOptions getContext(Class<?> type) {
+
+        if (type.getPackage().getName().equals(DefectBean.class.getPackage().getName()))
{
+            return new XmlFormattingOptions(false, false);
+        }
+
+        return null;
+    }
+
+}

Modified: incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/PreconditionsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/PreconditionsTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/PreconditionsTest.java
(original)
+++ incubator/wink/trunk/wink-examples/core/Preconditions/src/test/java/org/apache/wink/example/locking/PreconditionsTest.java
Thu Sep 10 12:06:56 2009
@@ -23,7 +23,6 @@
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 
-import org.apache.wink.common.model.XmlFormattingOptions;
 import org.apache.wink.example.locking.resources.DefectResource;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
@@ -36,12 +35,11 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        XmlFormattingOptions.setDefaultXmlFormattingOptions(new XmlFormattingOptions(false,
false));
     }
-    
+
     @Override
     protected Class<?>[] getClasses() {
-        return new Class[] {DefectResource.class};
+        return new Class[] {DefectResource.class, FormattingOptionsContextResolver.class};
     }
 
     public void testLockingExample() throws Exception {
@@ -102,7 +100,7 @@
         response = invoke(request);
         assertEquals("status", 200, response.getStatus());
         etag = (String)response.getHeader(HttpHeaders.ETAG);
-        
+
         // now, after the collection was modified
         // 200 should return
         request =

Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBProvider.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBProvider.java
Thu Sep 10 12:06:56 2009
@@ -47,7 +47,6 @@
 
 import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.providers.entity.xml.AbstractJAXBProvider;
-import org.apache.wink.common.utils.ProviderUtils;
 import org.codehaus.jettison.badgerfish.BadgerFishXMLInputFactory;
 import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter;
 import org.codehaus.jettison.mapped.Configuration;
@@ -168,7 +167,6 @@
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         try {
             Marshaller marshaller = getMarshaller(type, mediaType);
-            marshaller.setProperty(Marshaller.JAXB_ENCODING, ProviderUtils.getCharset(mediaType));
             Object entityToMarshal = getEntityToMarshal(t, type);
 
             // Use an OutputStream directly instead of a Writer for performance.

Added: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java?rev=813395&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java
(added)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java
Thu Sep 10 12:06:56 2009
@@ -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 org.apache.wink.server.internal.providers.entity.jettison;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.wink.common.model.XmlFormattingOptions;
+
+@Provider
+public class FormattingOptionsContextResolver implements ContextResolver<XmlFormattingOptions>
{
+
+    public XmlFormattingOptions getContext(Class<?> type) {
+        return new XmlFormattingOptions(false, false);
+    }
+
+}

Propchange: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/FormattingOptionsContextResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
Thu Sep 10 12:06:56 2009
@@ -51,7 +51,7 @@
 
     @Override
     protected Class<?>[] getClasses() {
-        return new Class<?>[] {TestResource.class, PersonResource.class};
+        return new Class<?>[] {TestResource.class, PersonResource.class, FormattingOptionsContextResolver.class};
     }
 
     @Override

Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java?rev=813395&r1=813394&r2=813395&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
Thu Sep 10 12:06:56 2009
@@ -52,7 +52,8 @@
 
     @Override
     protected Class<?>[] getClasses() {
-        return new Class<?>[] {TestResource.class, PersonResource.class};
+        return new Class<?>[] {TestResource.class, PersonResource.class,
+            FormattingOptionsContextResolver.class};
     }
 
     @Override
@@ -236,7 +237,7 @@
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
         assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
-                                    .objectForString(response.getContentAsString())));
+            .objectForString(response.getContentAsString())));
     }
 
     private static final String ENTRY_STR      =



Mime
View raw message