wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r812909 - in /incubator/wink/trunk: wink-client/src/test/java/org/apache/wink/client/ wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/ wink-common/src/main/java/org/apache/wink/common/internal/providers/entity...
Date Wed, 09 Sep 2009 11:58:34 GMT
Author: elman
Date: Wed Sep  9 11:58:33 2009
New Revision: 812909

URL: http://svn.apache.org/viewvc?rev=812909&view=rev
Log:
remove redundant providers and fix JAXBProvider. See [WINK-169]

Removed:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/AppCategoriesProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/AppServiceProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntryJAXBElementProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntryProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedJAXBElementProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomFeedProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/opensearch/OpenSearchDescriptionProvider.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/providers/entity/OpenSearchProviderTest.java
Modified:
    incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ProvidersTest.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/CategoriesProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.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/opensearch/OpenSearchDescription.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
    incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers
    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-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
    incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java

Modified: incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ProvidersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ProvidersTest.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ProvidersTest.java
(original)
+++ incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ProvidersTest.java
Wed Sep  9 11:58:33 2009
@@ -22,20 +22,31 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.text.MessageFormat;
+import java.util.Set;
 
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Providers;
 
-import org.apache.wink.client.MockHttpServer;
-import org.apache.wink.client.Resource;
-import org.apache.wink.client.RestClient;
-import org.apache.wink.common.internal.providers.entity.atom.AtomFeedProvider;
+import junit.framework.TestCase;
+
+import org.apache.wink.common.internal.application.ApplicationFileLoader;
+import org.apache.wink.common.internal.application.ApplicationValidator;
+import org.apache.wink.common.internal.contexts.ProvidersImpl;
+import org.apache.wink.common.internal.lifecycle.LifecycleManagersRegistry;
+import org.apache.wink.common.internal.lifecycle.ScopeLifecycleManager;
+import org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider;
+import org.apache.wink.common.internal.registry.ProvidersRegistry;
+import org.apache.wink.common.internal.registry.metadata.ProviderMetadataCollector;
+import org.apache.wink.common.internal.runtime.AbstractRuntimeContext;
+import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
 import org.apache.wink.common.model.atom.AtomFeed;
 import org.apache.wink.test.mock.TestUtils;
 
-import junit.framework.TestCase;
-
 public class ProvidersTest extends TestCase {
 
     private static int          SERVER_PORT = 3456;
@@ -82,6 +93,38 @@
                                                     + "    </entry>\n"
                                                     + "</feed>\n";
 
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        LifecycleManagersRegistry ofFactoryRegistry = new LifecycleManagersRegistry();
+        ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
+        ProvidersRegistry providersRegistry =
+            new ProvidersRegistry(ofFactoryRegistry, new ApplicationValidator());
+
+        Set<Class<?>> classes = new ApplicationFileLoader().getClasses();
+        if (classes != null) {
+            for (Class<?> cls : classes) {
+                if (ProviderMetadataCollector.isProvider(cls)) {
+                    providersRegistry.addProvider(cls);
+                }
+            }
+        }
+        AbstractRuntimeContext runtimeContext = new AbstractRuntimeContext() {
+
+            public OutputStream getOutputStream() throws IOException {
+                return null;
+            }
+
+            public InputStream getInputStream() throws IOException {
+                return null;
+            }
+        };
+        runtimeContext.setAttribute(Providers.class, new ProvidersImpl(providersRegistry,
+                                                                       runtimeContext));
+        RuntimeContextTLS.setRuntimeContext(runtimeContext);
+    }
+
     public void testAtomFeedReadWrite() throws Exception {
         MockHttpServer server = new MockHttpServer(SERVER_PORT);
         server.setMockResponseCode(200);
@@ -93,8 +136,12 @@
             Resource resource =
                 client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
                     .getServerPort())));
-
-            AtomFeedProvider afp = new AtomFeedProvider();
+            Providers providers = RuntimeContextTLS.getRuntimeContext().getProviders();
+            MessageBodyReader<AtomFeed> afp =
+                providers.getMessageBodyReader(AtomFeed.class,
+                                               AtomFeed.class,
+                                               null,
+                                               MediaType.APPLICATION_ATOM_XML_TYPE);
             AtomFeed entryToPost =
                 afp.readFrom(AtomFeed.class,
                              null,
@@ -108,7 +155,12 @@
                                                                            entryToPost);
 
             ByteArrayOutputStream os = new ByteArrayOutputStream();
-            afp.writeTo(responseEntity,
+            MessageBodyWriter<AtomFeed> writer = 
+                providers.getMessageBodyWriter(AtomFeed.class,
+                                               AtomFeed.class,
+                                               null,
+                                               MediaType.APPLICATION_ATOM_XML_TYPE);
+            writer.writeTo(responseEntity,
                         AtomFeed.class,
                         null,
                         null,

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/CategoriesProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/CategoriesProvider.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/CategoriesProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/app/CategoriesProvider.java
Wed Sep  9 11:58:33 2009
@@ -35,6 +35,8 @@
 import javax.ws.rs.ext.Provider;
 import javax.ws.rs.ext.Providers;
 
+import org.apache.wink.common.annotations.Scope;
+import org.apache.wink.common.annotations.Scope.ScopeType;
 import org.apache.wink.common.categories.Categories;
 import org.apache.wink.common.internal.utils.MediaTypeUtils;
 import org.apache.wink.common.model.app.AppCategories;
@@ -48,6 +50,7 @@
  * CollectionCategories interface
  */
 @Provider
+@Scope(ScopeType.PROTOTYPE)
 @Produces(MediaTypeUtils.ATOM_CATEGORIES_DOCUMENT)
 public class CategoriesProvider implements MessageBodyWriter<Categories> {
 
@@ -92,7 +95,7 @@
                         MultivaluedMap<String, Object> httpHeaders,
                         OutputStream entityStream) throws IOException, WebApplicationException
{
         AppCategories catDoc = buildAppCatDoc(categories);
-        appCatProvider.writeTo(catDoc, null, null, null, mediaType, httpHeaders, entityStream);
+        appCatProvider.writeTo(catDoc, AppCategories.class, AppCategories.class, annotations,
mediaType, httpHeaders, entityStream);
     }
 
     private AppCategories buildAppCatDoc(Categories cats) {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBElementXmlProvider.java
Wed Sep  9 11:58:33 2009
@@ -21,10 +21,12 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.nio.charset.Charset;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
@@ -42,6 +44,9 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.wink.common.internal.i18n.Messages;
+import org.apache.wink.common.internal.model.ModelUtils;
+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;
@@ -75,8 +80,16 @@
 
         try {
             unmarshaller = getUnmarshaller(classToFill, mediaType);
-            unmarshaledResource =
-                unmarshaller.unmarshal(new StreamSource(entityStream), classToFill);
+            String charset = ProviderUtils.getCharsetOrNull(mediaType);
+            if (charset == null) {
+                // use default
+                // performance is better, though the charset cannot be ensured
+                unmarshaledResource =
+                    unmarshaller.unmarshal(new StreamSource(entityStream), classToFill);
+            } else {
+                ModelUtils.unmarshal(unmarshaller, new InputStreamReader(entityStream, Charset
+                    .forName(charset)));
+            }
         } catch (JAXBException e) {
             logger.error(Messages.getMessage("jaxbFailToUnmarshal"), type.getName());
             throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
@@ -109,6 +122,9 @@
         try {
             Marshaller marshaller = getMarshaller(t.getDeclaredType(), mediaType);
             marshaller.setProperty(Marshaller.JAXB_ENCODING, ProviderUtils.getCharset(mediaType));
+            JAXBUtils.setXmlFormattingOptions(marshaller, XmlFormattingOptions
+                .getDefaultXmlFormattingOptions());
+
             marshaller.marshal(t, entityStream);
         } catch (JAXBException e) {
             logger.error(Messages.getMessage("jaxbFailToMarshal"), t.getName());

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=812909&r1=812908&r2=812909&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
Wed Sep  9 11:58:33 2009
@@ -41,6 +41,8 @@
 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;
@@ -113,6 +115,9 @@
 
             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/opensearch/OpenSearchDescription.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/opensearch/OpenSearchDescription.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/opensearch/OpenSearchDescription.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/opensearch/OpenSearchDescription.java
Wed Sep  9 11:58:33 2009
@@ -39,6 +39,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAnyAttribute;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
@@ -346,6 +347,7 @@
  *      &lt;OutputEncoding&gt;UTF-8&lt;/OutputEncoding&gt;
  * </pre>
  */
+//@XmlRootElement(namespace = "http://a9.com/-/spec/opensearch/1.1/", name = "Contact")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "OpenSearchDescription", propOrder = {"shortName", "description", "tags",
                                                       "contact", "url", "longName", "image",

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
Wed Sep  9 11:58:33 2009
@@ -43,7 +43,13 @@
 
 public class ProviderUtils {
 
-    public static final String getCharset(MediaType m) {
+    public static String getCharsetOrNull(MediaType m) {
+        String name = (m == null) ? null : m.getParameters().get("charset");
+        return (name == null) ? null : name;
+    }
+
+    
+    public static String getCharset(MediaType m) {
         String name = (m == null) ? null : m.getParameters().get("charset");
         return (name == null) ? "UTF-8" : name;
     }

Modified: incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers (original)
+++ incubator/wink/trunk/wink-common/src/main/resources/META-INF/core/wink-providers Wed Sep
 9 11:58:33 2009
@@ -44,21 +44,12 @@
 org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider
 
 # Atom 
-org.apache.wink.common.internal.providers.entity.atom.AtomFeedProvider
 org.apache.wink.common.internal.providers.entity.atom.AtomFeedSyndFeedProvider
-org.apache.wink.common.internal.providers.entity.atom.AtomFeedJAXBElementProvider
-org.apache.wink.common.internal.providers.entity.atom.AtomEntryProvider
 org.apache.wink.common.internal.providers.entity.atom.AtomEntrySyndEntryProvider
-org.apache.wink.common.internal.providers.entity.atom.AtomEntryJAXBElementProvider
 
 # APP
-org.apache.wink.common.internal.providers.entity.app.AppServiceProvider
-org.apache.wink.common.internal.providers.entity.app.AppCategoriesProvider
 org.apache.wink.common.internal.providers.entity.app.CategoriesProvider
 
-# Open Search
-org.apache.wink.common.internal.providers.entity.opensearch.OpenSearchDescriptionProvider
-
 # Json
 org.apache.wink.common.internal.providers.entity.json.JsonProvider
 org.apache.wink.common.internal.providers.entity.json.JsonArrayProvider

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=812909&r1=812908&r2=812909&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
Wed Sep  9 11:58:33 2009
@@ -23,9 +23,11 @@
 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;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
@@ -54,6 +56,12 @@
     protected Class<?>[] getClasses() {
         return new Class[] {JaxbResource.class};
     }
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        XmlFormattingOptions.setDefaultXmlFormattingOptions(new XmlFormattingOptions(false,
false));
+    }
 
     public void testAllGet() throws Exception {
         MockHttpServletRequest request =
@@ -62,7 +70,9 @@
                                                         MediaType.APPLICATION_XML_TYPE);
         MockHttpServletResponse response = invoke(request);
         assertEquals("status", 200, response.getStatus());
-        assertEquals(PERSON_1, response.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(PERSON_1, response.getContentAsString());
+        assertNull(msg, msg);
 
         request =
             MockRequestConstructor.constructMockRequest("GET",

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=812909&r1=812908&r2=812909&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
Wed Sep  9 11:58:33 2009
@@ -23,6 +23,7 @@
 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;
@@ -33,6 +34,12 @@
 public class PreconditionsTest extends MockServletInvocationTest {
 
     @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        XmlFormattingOptions.setDefaultXmlFormattingOptions(new XmlFormattingOptions(false,
false));
+    }
+    
+    @Override
     protected Class<?>[] getClasses() {
         return new Class[] {DefectResource.class};
     }

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/AssetProviderTest.java
Wed Sep  9 11:58:33 2009
@@ -42,6 +42,7 @@
 import org.apache.wink.common.model.json.JSONUtils;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
+import org.apache.wink.test.mock.TestUtils;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.springframework.mock.web.MockHttpServletRequest;
@@ -56,7 +57,11 @@
 
     private static final String STRING = "hello message";
     private static final String XML    =
-                                           "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><entry><id>entry:id</id><title
type=\"text\">entry title</title></entry>";
+                                           "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ 
+                                           "<entry>\r\n" + 
+                                           "    <id>entry:id</id>\r\n" + 
+                                           "    <title type=\"text\">entry title</title>\r\n"
+ 
+                                           "</entry>\r\n";
     private static final String JSON   =
                                            "{\"entry\": {\n" + "  \"id\": {\"$\": \"entry:id\"},\n"
                                                + "  \"title\": {\n"
@@ -163,7 +168,9 @@
             MockRequestConstructor.constructMockRequest("GET", "/test", "application/xml");
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(XML, response.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(XML, response.getContentAsString());
+        assertNull(msg, msg);
     }
 
     public void testAssetGetString() throws Exception {
@@ -183,7 +190,9 @@
                                                         XML.getBytes());
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(XML, response.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(XML, response.getContentAsString());
+        assertNull(msg, msg);
     }
 
     public void testAssetPostStringGetString() throws Exception {
@@ -219,6 +228,8 @@
                                                         STRING.getBytes());
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(XML, response.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(XML, response.getContentAsString());
+        assertNull(msg, msg);
     }
 }

Modified: incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java?rev=812909&r1=812908&r2=812909&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
(original)
+++ incubator/wink/trunk/wink-server/src/test/java/org/apache/wink/server/internal/providers/entity/JAXBElementProviderTest.java
Wed Sep  9 11:58:33 2009
@@ -45,6 +45,7 @@
 import org.apache.wink.common.model.atom.ObjectFactory;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
+import org.apache.wink.test.mock.TestUtils;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
@@ -60,13 +61,19 @@
                                                                 "<JAXBXmlRootElement><id>ID</id><name>NAME</name></JAXBXmlRootElement>";
     private static final byte[] JAXBXmlRootElement_BYTES    = JAXBXmlRootElement_REQUEST.getBytes();
     private static final String JAXBXmlRootElement_RESPONSE =
-                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\" standalone=\"yes\"?><JAXBXmlRootElement><id>ID</id><name>NAME</name></JAXBXmlRootElement>";
+                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\r\n" + "<JAXBXmlRootElement>\r\n"
+                                                                    + "    <id>ID</id>\r\n"
+                                                                    + "    <name>NAME</name>\r\n"
+                                                                    + "</JAXBXmlRootElement>";
 
     private static final String JAXBXmlType_REQUEST         =
                                                                 "<JAXBXmlType><id>ID</id><name>NAME</name></JAXBXmlType>";
     private static final byte[] JAXBXmlType_REQUEST_BYTES   = JAXBXmlType_REQUEST.getBytes();
     private static final String JAXBXmlType_RESPONSE        =
-                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\" standalone=\"yes\"?><JAXBXmlType><id>ID</id><name>NAME</name></JAXBXmlType>";
+                                                                "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\r\n" + "<JAXBXmlType>\r\n"
+                                                                    + "    <id>ID</id>\r\n"
+                                                                    + "    <name>NAME</name>\r\n"
+                                                                    + "</JAXBXmlType>";
 
     JAXBElement<AtomFeed>       atomfeed;
 
@@ -193,6 +200,7 @@
                                                                                         
 "plain")));
     }
 
+    @SuppressWarnings("unchecked")
     public void testJAXBElementProviderInvocation() throws Exception {
         MockHttpServletRequest request =
             MockRequestConstructor.constructMockRequest("POST",
@@ -214,6 +222,7 @@
         assertEquals(expectedResponse.getValue().getId(), response.getValue().getId());
     }
 
+    @SuppressWarnings("unchecked")
     public void testJAXBXmlElementProviderInvocation() throws Exception {
         MockHttpServletRequest request =
             MockRequestConstructor.constructMockRequest("POST",
@@ -244,7 +253,10 @@
                                                         null);
         MockHttpServletResponse invoke = invoke(request);
         assertEquals(200, invoke.getStatus());
-        assertEquals(JAXBXmlType_RESPONSE, invoke.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(JAXBXmlType_RESPONSE, invoke
+                .getContentAsString());
+        assertNull(msg, msg);
     }
 
     public void testJAXBXmlElementProviderInvocationXmltype() throws Exception {
@@ -256,7 +268,10 @@
                                                         JAXBXmlType_REQUEST_BYTES);
         MockHttpServletResponse invoke = invoke(request);
         assertEquals(200, invoke.getStatus());
-        assertEquals(JAXBXmlType_RESPONSE, invoke.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(JAXBXmlType_RESPONSE, invoke
+                .getContentAsString());
+        assertNull(msg, msg);
     }
 
     public void testJAXBXmlElementProviderInvocationXmlRoot() throws Exception {
@@ -268,7 +283,10 @@
                                                         JAXBXmlRootElement_BYTES);
         MockHttpServletResponse invoke = invoke(request);
         assertEquals(200, invoke.getStatus());
-        assertEquals(JAXBXmlRootElement_RESPONSE, invoke.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(JAXBXmlRootElement_RESPONSE,
invoke
+                .getContentAsString());
+        assertNull(msg, msg);
 
         request =
             MockRequestConstructor.constructMockRequest("POST",
@@ -289,7 +307,10 @@
                                                         JAXBXmlType_REQUEST_BYTES);
         MockHttpServletResponse invoke = invoke(request);
         assertEquals(200, invoke.getStatus());
-        assertEquals(JAXBXmlType_RESPONSE, invoke.getContentAsString());
+        String msg =
+            TestUtils.diffIgnoreUpdateWithAttributeQualifier(JAXBXmlType_RESPONSE, invoke
+                .getContentAsString());
+        assertNull(msg, msg);
     }
 
     public void testJAXBXmlElementProviderReaderWriter() throws SecurityException,



Mime
View raw message