wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r909044 - 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/atom/ wink-common/src/main/java/org/apache/wink/common/model/synd/
Date Thu, 11 Feb 2010 16:03:34 GMT
Author: rott
Date: Thu Feb 11 16:03:23 2010
New Revision: 909044

URL: http://svn.apache.org/viewvc?rev=909044&view=rev
Log:
WINK-254: fix SyndContent to support use of providers during client call to getValue

Modified:
    incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientAtomTest.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndContent.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndSimpleContent.java

Modified: incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientAtomTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientAtomTest.java?rev=909044&r1=909043&r2=909044&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientAtomTest.java
(original)
+++ incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientAtomTest.java
Thu Feb 11 16:03:23 2010
@@ -31,17 +31,15 @@
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.Providers;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider;
 import org.apache.wink.common.model.atom.AtomEntry;
+import org.apache.wink.common.model.synd.SyndEntry;
 
 public class ClientAtomTest extends BaseTest {
     
@@ -139,7 +137,7 @@
     "</content>" +
     "</entry>";
     
-    public void testAtomContentRetrieval() {
+    public void testAtomContentRetrievalFromAtomEntry() {
         server.setMockResponseCode(200);
         server.setMockResponseContentType(MediaType.APPLICATION_ATOM_XML);
         server.setMockResponseContent(responseString);
@@ -160,4 +158,25 @@
 
     }
     
+    public void testAtomContentRetrievalFromSyndEntry() {
+        server.setMockResponseCode(200);
+        server.setMockResponseContentType(MediaType.APPLICATION_ATOM_XML);
+        server.setMockResponseContent(responseString);
+        RestClient client = getRestClient();
+        Resource resource = client.resource(serviceURL + "/atomresource/entry");
+        
+        // do get with response
+        ClientResponse clientResponse = resource.get();
+        // unwrap the AtomEntry, AtomContent value
+        MyPojo myPojo = (MyPojo)clientResponse.getEntity(SyndEntry.class).getContent().getValue(MyPojo.class);
+        
+        // Confirm that the custom MyProvider is used during AtomContent.getValue(MyPojo.class)
call.
+        // Custom providers are stored on the client-server transaction's thread local store.
 This assertion
+        // ensures that the custom providers are held long enough for a client application
to use them during
+        // retrieval of the value from the AtomContent object, which occurs in its own thread.
+        
+        assertEquals("wheeee!!! -- MyProvider was here.", myPojo.getTitle());
+
+    }
+    
 }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java?rev=909044&r1=909043&r2=909044&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/atom/AtomEntrySyndEntryProvider.java
Thu Feb 11 16:03:23 2010
@@ -39,8 +39,8 @@
 
 import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
 import org.apache.wink.common.internal.utils.MediaTypeUtils;
-import org.apache.wink.common.model.atom.AtomContent;
 import org.apache.wink.common.model.atom.AtomEntry;
+import org.apache.wink.common.model.synd.SyndContent;
 import org.apache.wink.common.model.synd.SyndEntry;
 
 @Provider
@@ -90,12 +90,13 @@
          * providers, and could cause an infinite loop when ModelUtils.readValue calls back
through
          * the providers.
          */
-        AtomContent content = entry.getContent();
+        SyndEntry returnVal = entry.toSynd(new SyndEntry());
+        SyndContent content = returnVal.getContent();
         if (content != null) {
             content.setProviders(RuntimeContextTLS.getRuntimeContext().getAttribute(Providers.class));
         }
         
-        return entry.toSynd(new SyndEntry());
+        return returnVal;
     }
 
     public boolean isWriteable(Class<?> type,

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndContent.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndContent.java?rev=909044&r1=909043&r2=909044&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndContent.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndContent.java
Thu Feb 11 16:03:23 2010
@@ -20,6 +20,8 @@
 
 package org.apache.wink.common.model.synd;
 
+import javax.ws.rs.ext.Providers;
+
 public class SyndContent extends SyndSimpleContent {
 
     private String src;
@@ -108,4 +110,16 @@
         return true;
     }
 
+    /**
+     * Sets the Providers on a local field so that the registry of custom and system
+     * providers is available when a client application retrieves the value, expecting
+     * it to be seamlessly unmarshalled or converted to the expected type declared in
+     * getValue(Class).
+     * 
+     * Client applications should NOT call this method.
+     */
+    public void setProviders(Providers _providers) {
+        providers = _providers;
+    }
+
 }

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndSimpleContent.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndSimpleContent.java?rev=909044&r1=909043&r2=909044&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndSimpleContent.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndSimpleContent.java
Thu Feb 11 16:03:23 2010
@@ -36,6 +36,7 @@
 
     private Object   value;
     protected String type;
+    protected Providers providers;
 
     public SyndSimpleContent() {
     }
@@ -63,7 +64,7 @@
         try {
             return getValue(cls,
                             cls,
-                            null,
+                            providers,
                             ModelUtils.EMPTY_ARRAY,
                             ModelUtils.EMPTY_STRING_MAP,
                             ModelUtils.determineMediaType(type));



Mime
View raw message