abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1201185 [2/2] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/extra/ client/src/main/java/org/apache/abdera2/protocol/client/ common/src/main/java/...
Date Sat, 12 Nov 2011 04:25:25 GMT
Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreExecutors2.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
Sat Nov 12 04:25:22 2011
@@ -111,15 +111,5 @@ public abstract class AbstractMessage 
       }
       return links;
     }
-    
-    public Iterable<Preference> getPreferApplied() {
-      List<Preference> links = new ArrayList<Preference>();
-      Iterable<Object> headers = this.getHeaders("Preference-Applied");
-      for (Object obj : headers) {
-        Iterable<Preference> list = Preference.parse(obj.toString());
-        for (Preference link : list)
-          links.add(link);
-      }
-      return links;
-    }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
Sat Nov 12 04:25:22 2011
@@ -291,8 +291,5 @@ public abstract class AbstractResponseCo
     public <T extends ResponseContext>T setPrefer(Preference pref, Preference... prefs)
{
       return (T)setHeader("Prefer", Preference.toString(pref,prefs));
     }
-    
-    public <T extends ResponseContext>T setPreferApplied(Preference pref, Preference...
prefs) {
-      return (T)setHeader("Preference-Applied", Preference.toString(pref,prefs));
-    }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
Sat Nov 12 04:25:22 2011
@@ -245,10 +245,6 @@ public class BaseRequestContextWrapper
       return request.getPrefer();
     }
     
-    public Iterable<Preference> getPreferApplied() {
-      return request.getPreferApplied();
-    }
-
     public <T> T getHeader(String name, Function<String, T> transform) {
       return request.getHeader(name,transform);
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
Sat Nov 12 04:25:22 2011
@@ -305,10 +305,6 @@ public class BaseResponseContextWrapper 
     public Iterable<Preference> getPrefer() {
       return response.getPrefer();
     }
-    
-    public Iterable<Preference> getPreferApplied() {
-      return response.getPreferApplied();
-    }
 
     public <T extends ResponseContext> T setWebLinks(WebLink link,
         WebLink... links) {
@@ -322,12 +318,6 @@ public class BaseResponseContextWrapper 
       return (T)this;
     }
 
-    public <T extends ResponseContext> T setPreferApplied(Preference pref,
-        Preference... prefs) {
-      response.setPreferApplied(pref, prefs);
-      return (T)this;
-    }
-
     public <T> T getHeader(String name, Function<String, T> transform) {
       return response.getHeader(name,transform);
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java Sat
Nov 12 04:25:22 2011
@@ -109,8 +109,4 @@ public interface Message {
      */
     Iterable<Preference> getPrefer();
     
-    /**
-     * Return the Applied Preferences
-     */
-    Iterable<Preference> getPreferApplied();
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java
Sat Nov 12 04:25:22 2011
@@ -210,6 +210,5 @@ public interface ResponseContext extends
     <B extends ResponseContext>B setWebLinks(WebLink link, WebLink... links);
     
     <B extends ResponseContext>B setPrefer(Preference pref, Preference... prefs);
-    
-    <B extends ResponseContext>B setPreferApplied(Preference pref, Preference... prefs);
+
 }

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaBody.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponse.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaResponseHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java
(from r1187599, abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java?p2=abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java&p1=abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java&r1=1187599&r2=1201185&rev=1201185&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java
Sat Nov 12 04:25:22 2011
@@ -77,11 +77,6 @@ public class AbderaSession extends Sessi
      * @param options The request options
      */
     public <T extends ClientResponse>T post(String uri, Base base, RequestOptions options)
{
-        if (base instanceof Document) {
-            Document<?> d = (Document<?>)base;
-            if (options.getSlug() == null && d.getSlug() != null)
-                options.setSlug(d.getSlug());
-        }
         return (T)wrap(execute("POST", uri, new AbderaEntity(base), options));
     }
 
@@ -95,7 +90,7 @@ public class AbderaSession extends Sessi
      * @param media The media object that will be sent as the second element of the multipart/related
object
      */
     public <T extends ClientResponse>T post(String uri, Entry entry, ContentBody media)
{
-        return (T)wrap(post(uri, entry, media, getDefaultRequestOptions()));
+        return (T)wrap(post(uri, entry, media, getDefaultRequestOptions().get()));
     }
 
     /**
@@ -133,20 +128,27 @@ public class AbderaSession extends Sessi
      * @param provider An EntityProvider implementation providing the payload of the request
      * @param options The request options
      */
-    public <T extends ClientResponse>T put(String uri, EntityProvider provider, RequestOptions
options) {
-        if (options == null)
-            options = getDefaultRequestOptions();
-        if (options.isConditionalPut()) {
-            EntityTag etag = provider.getEntityTag();
-            if (etag != null)
-                options.setIfMatch(etag);
-            else {
-                DateTime lm = provider.getLastModified();
-                if (lm != null)
-                    options.setIfUnmodifiedSince(lm);
-            }
+    public <T extends ClientResponse>T put(
+      String uri, 
+      EntityProvider provider, 
+      RequestOptions options) {
+      if (options == null)
+          options = getDefaultRequestOptions().get();
+      if (options.isConditionalPut() && 
+          !(options.has("If-Match") || 
+            options.has("If-Unmodified-Since"))) {
+        EntityTag etag = provider.getEntityTag();
+        RequestOptions.Builder builder = options.template();
+        if (etag != null)
+          builder.ifMatch(etag);
+        else {
+          DateTime lm = provider.getLastModified();
+          if (lm != null)
+            builder.ifUnmodifiedSince(lm);
         }
-        return (T)wrap(put(uri, new EntityProviderEntity(getAbdera(), provider), options));
+        options = builder.get();
+      }
+      return (T)wrap(put(uri, new EntityProviderEntity(getAbdera(), provider), options));
     }
 
     /**
@@ -158,18 +160,19 @@ public class AbderaSession extends Sessi
      */
     public <T extends ClientResponse>T put(String uri, Base base, RequestOptions options)
{
         if (options == null)
-            options = getDefaultRequestOptions();
+            options = getDefaultRequestOptions().get();
         if (base instanceof Document) {
-            Document<?> d = (Document<?>)base;
-            if (options.getSlug() == null && d.getSlug() != null)
-                options.setSlug(d.getSlug());
-
-            if (options.isConditionalPut()) {
-                if (d.getEntityTag() != null)
-                    options.setIfMatch(d.getEntityTag());
-                else if (d.getLastModified() != null)
-                    options.setIfUnmodifiedSince(d.getLastModified());
-            }
+          Document<?> d = (Document<?>) base;
+          if (options.isConditionalPut() && 
+              !(options.has("If-Match") || 
+                options.has("If-Unmodified-Since"))) {
+            RequestOptions.Builder builder = options.template();
+            if (d.getEntityTag() != null)
+              builder.ifMatch(d.getEntityTag());
+            else if (d.getLastModified() != null)
+              builder.ifUnmodifiedSince(d.getLastModified());
+            options = builder.get();
+          }
         }
         return (T)wrap(execute("PUT", uri, new AbderaEntity(base), options));
     }
@@ -181,7 +184,7 @@ public class AbderaSession extends Sessi
      * @param provider An EntityProvider implementation providing the payload the request
      */
     public <T extends ClientResponse>T post(String uri, EntityProvider provider) {
-        return (T)wrap(post(uri, provider, getDefaultRequestOptions()));
+      return (T)wrap(post(uri, provider, getDefaultRequestOptions().get()));
     }
 
     /**
@@ -191,7 +194,7 @@ public class AbderaSession extends Sessi
      * @param base A FOM Document or Element providing the payload of the request
      */
     public <T extends ClientResponse>T post(String uri, Base base) {
-        return (T)wrap(post(uri, base, getDefaultRequestOptions()));
+      return (T)wrap(post(uri, base, getDefaultRequestOptions().get()));
     }
 
     /**
@@ -201,7 +204,7 @@ public class AbderaSession extends Sessi
      * @param provider An EntityProvider implementation providing the payload of the request
      */
     public <T extends ClientResponse>T put(String uri, EntityProvider provider) {
-        return (T)wrap(put(uri, provider, getDefaultRequestOptions()));
+      return (T)wrap(put(uri, provider, getDefaultRequestOptions().get()));
     }
 
     /**
@@ -211,7 +214,7 @@ public class AbderaSession extends Sessi
      * @param base A FOM Document or Element providing the payload of the request
      */
     public <T extends ClientResponse>T put(String uri, Base base) {
-        return (T)wrap(put(uri, base, getDefaultRequestOptions()));
+      return (T)wrap(put(uri, base, getDefaultRequestOptions().get()));
     }
 
     /**
@@ -270,7 +273,7 @@ public class AbderaSession extends Sessi
         EntityProvider provider, 
         RequestOptions options) {
         if (options == null)
-            options = getDefaultRequestOptions();
+            options = getDefaultRequestOptions().get();
         return (T)wrap(execute(
             method, 
             uri, 

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java
(original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java
Sat Nov 12 04:25:22 2011
@@ -26,7 +26,7 @@ public class GooglePlusExample   {
       new ActivitiesClient();
     try {
       ASDocument<Collection<Activity>> doc = 
-        cl.getCollection(
+        cl.<Activity,Collection<Activity>>getCollection(
           expandAnnotated(
             new GooglePlusExample()));
       Collection<Activity> c = doc.getRoot();

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
(original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
Sat Nov 12 04:25:22 2011
@@ -449,7 +449,7 @@ public final class FeedPagingHelper {
     private static <E extends Element>Document<E> fetch(IRI iri, AbderaSession
session) {
       if (iri == null) return null;
       PageFetch<E> fetch = new PageFetch<E>(iri.toString(), session);
-      return fetch.apply(session.getDefaultRequestOptions());
+      return fetch.apply(session.getDefaultRequestOptions().get());
     }
     
     public static class PageFetch<E extends Element>

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/json/JSONServlet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/json/JSONServlet.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/json/JSONServlet.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/json/JSONServlet.java Sat Nov
12 04:25:22 2011
@@ -67,30 +67,31 @@ public class JSONServlet extends HttpSer
 
         Abdera abdera = getAbdera();
         AbderaClient client = new AbderaClient(abdera);
-        RequestOptions options = RequestHelper.createDefaultRequestOptions();
+        RequestOptions.Builder options = 
+          RequestHelper.createAtomDefaultRequestOptions();
         if (request.getHeader("If-Match") != null)
-            options.setIfMatch(request.getHeader("If-Match"));
+            options.ifMatch(request.getHeader("If-Match"));
         if (request.getHeader("If-None-Match") != null)
-            options.setIfNoneMatch(request.getHeader("If-None-Match"));
+            options.ifNoneMatch(request.getHeader("If-None-Match"));
         if (request.getHeader("If-Modified-Since") != null)
-            options.setIfNoneMatch(request.getHeader("If-Modified-Since"));
+            options.ifNoneMatch(request.getHeader("If-Modified-Since"));
         if (request.getHeader("If-Unmodified-Since") != null)
-            options.setIfNoneMatch(request.getHeader("If-Unmodified-Since"));
+            options.ifNoneMatch(request.getHeader("If-Unmodified-Since"));
         try {
-            Document<?> doc = client.get(url);
-            response.setContentType("application/json");
-            response.setCharacterEncoding("UTF-8");
-            if (doc.getEntityTag() != null)
-                response.setHeader("ETag", doc.getEntityTag().toString());
-            if (doc.getLanguage() != null)
-                response.setHeader("Content-Language", doc.getLanguage());
-            if (doc.getLastModified() != null)
-                response.setDateHeader("Last-Modified", doc.getLastModified().getMillis());
-            OutputStream out = response.getOutputStream();
-            doc.writeTo("json", out);
+          Document<?> doc = client.get(url,options.get());
+          response.setContentType("application/json");
+          response.setCharacterEncoding("UTF-8");
+          if (doc.getEntityTag() != null)
+            response.setHeader("ETag", doc.getEntityTag().toString());
+          if (doc.getLanguage() != null)
+            response.setHeader("Content-Language", doc.getLanguage());
+          if (doc.getLastModified() != null)
+            response.setDateHeader("Last-Modified", doc.getLastModified().getMillis());
+          OutputStream out = response.getOutputStream();
+          doc.writeTo("json", out);
         } catch (Exception e) {
-            response.sendError(500);
-            return;
+          response.sendError(500);
+          return;
         }
         client.shutdown();
     }

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java Sat Nov
12 04:25:22 2011
@@ -383,56 +383,41 @@ public class AppTest {
     public void testRequestOptions() throws Exception {
         Client abderaClient = new BasicClient();
         Session session = abderaClient.newSession();
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setIfModifiedSince(DateTimes.now());
-        assertNotNull(options.getIfModifiedSince());
-
-        options.set4xxRequestException(true);
-        assertTrue(options.is4xxRequestException());
-
-        options.set5xxRequestException(true);
-        assertTrue(options.is5xxRequestException());
-
-        options.setAccept("text/plain");
-        assertEquals("text/plain", options.getAccept());
-
-        options.setAcceptCharset("UTF-8");
-        assertEquals("UTF-8", options.getAcceptCharset());
-
-        options.setAcceptEncoding("gzip");
-        assertEquals("gzip", options.getAcceptEncoding());
+        RequestOptions options = 
+          session.getDefaultRequestOptions()
+            .ifModifiedSinceNow()
+            .requestException4xx()
+            .requestException5xx()
+            .usePostOverride()
+            .accept("text/plain")
+            .acceptCharset("UTF-8")
+            .acceptEncoding("gzip")
+            .acceptLanguage("en-US")
+            .cacheControl("no-cache")
+            .contentType("text/plain")
+            .encodedHeader("foo", "UTF-8", "bar")
+            .header("foo", "bar")
+            .ifMatch("testing")
+            .ifNoneMatch("testing")
+            .slug("This is the slug")
+            .get();
 
-        options.setAcceptLanguage("en-US");
-        assertEquals("en-US", options.getAcceptLanguage());
-
-//        options.setAuthorization("auth");
-//        assertEquals("auth", options.getAuthorization());
-
-        options.setCacheControl("no-cache");
+        assertTrue(options.isUsePostOverride());
+        assertEquals("This is the slug", options.getSlug());
+        assertTrue(EntityTag.matchesAny(new EntityTag("testing"), options.getIfNoneMatch()));
+        assertTrue(EntityTag.matchesAny(new EntityTag("testing"), options.getIfMatch()));
+        assertEquals("bar", options.getHeader("foo"));
+        assertEquals("bar", options.getDecodedHeader("foo"));
+        assertTrue(MimeTypeHelper.isMatch(options.getContentType(), new MimeType("text/plain")));
         CacheControl cc = options.getCacheControl();
         assertTrue(cc.isNoCache());
-
-        options.setContentType("text/plain");
-        assertTrue(MimeTypeHelper.isMatch(options.getContentType(), new MimeType("text/plain")));
-
-        options.setEncodedHeader("foo", "UTF-8", "bar");
-        assertEquals("bar", options.getDecodedHeader("foo"));
-
-        options.setHeader("foo", "bar");
-        assertEquals("bar", options.getHeader("foo"));
-
-        options.setIfMatch("testing");
-        assertTrue(EntityTag.matchesAny(new EntityTag("testing"), options.getIfMatch()));
-
-        options.setIfNoneMatch("testing");
-        assertTrue(EntityTag.matchesAny(new EntityTag("testing"), options.getIfNoneMatch()));
-
-        options.setSlug("This is the slug");
-        assertEquals("This is the slug", options.getSlug());
-
-        options.setUsePostOverride(true);
-        assertTrue(options.isUsePostOverride());
-        
+        assertEquals("en-US", options.getAcceptLanguage());
+        assertEquals("gzip", options.getAcceptEncoding());
+        assertEquals("UTF-8", options.getAcceptCharset());
+        assertEquals("text/plain", options.getAccept());
+        assertNotNull(options.getIfModifiedSince());
+        assertTrue(options.is4xxRequestException());
+        assertTrue(options.is5xxRequestException());
         abderaClient.shutdown();
     }
 
@@ -441,10 +426,11 @@ public class AppTest {
         AbderaClient abderaClient = new AbderaClient();
         AbderaSession session = (AbderaSession) abderaClient.newSession();
         Entry entry = getFactory().newEntry();
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setHeader("Connection", "close");
-        options.setUseExpectContinue(false);
-
+        RequestOptions options = 
+          session.getDefaultRequestOptions()
+            .header("Connection", "close")
+            .doNotUseExpectContinue()
+            .get();
         // do the introspection step
         AbderaClientResponse response = 
           (AbderaClientResponse) session.get(
@@ -564,10 +550,11 @@ public class AppTest {
         // Now let's try to do a media post
 
         // Post the media resource
-        options = session.getDefaultRequestOptions();
-        options.setContentType("text/plain");
-        options.setHeader("Connection", "close");
-        options.setUseExpectContinue(false);
+        options = session.getDefaultRequestOptions()
+          .contentType("text/plain")
+          .header("Connection", "close")
+          .doNotUseExpectContinue()
+          .get();
 
         response = (AbderaClientResponse) session.post(col_uri, new ByteArrayInputStream("test".getBytes()),
options);
 
@@ -582,8 +569,8 @@ public class AppTest {
         }
 
         // was an entry created?
-        options = session.getDefaultRequestOptions();
-        options.setHeader("Connection", "close");
+        options = session.getDefaultRequestOptions()
+          .header("Connection", "close").get();
         response = (AbderaClientResponse) session.get(self_uri, options);
 
         String edit_media, media;
@@ -609,10 +596,10 @@ public class AppTest {
         }
 
         // submit the changes
-        options = session.getDefaultRequestOptions();
-        options.setContentType("application/atom+xml;type=entry");
-        options.setHeader("Connection", "close");
-        options.setUseExpectContinue(false);
+        options = session.getDefaultRequestOptions()
+          .contentType("application/atom+xml;type=entry")
+          .header("Connection", "close")
+          .doNotUseExpectContinue().get();
 
         response = (AbderaClientResponse) session.put(edit_uri, entry, options);
 
@@ -635,10 +622,11 @@ public class AppTest {
         }
 
         // edit the media resource
-        options = session.getDefaultRequestOptions();
-        options.setHeader("Connection", "close");
-        options.setContentType("text/plain");
-        options.setUseExpectContinue(false);
+        options = session.getDefaultRequestOptions()
+          .header("Connection", "close")
+          .contentType("text/plain")
+          .doNotUseExpectContinue()
+          .get();
 
         response = (AbderaClientResponse) session.put(edit_media, new ByteArrayInputStream("TEST".getBytes()),
options);
 
@@ -679,7 +667,7 @@ public class AppTest {
         }
 
         // is the media resource gone?
-        options.setCacheControl(CacheControl.NOCACHE());
+        options = options.template().cacheControl(CacheControl.NOCACHE()).get();
 
         response = (AbderaClientResponse) session.get(media, options);
 

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/CacheTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/CacheTest.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/CacheTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/CacheTest.java Sat Nov
12 04:25:22 2011
@@ -310,66 +310,82 @@ public class CacheTest {
     public void testResponseMustRevalidate() throws Exception {
         Client abderaClient = new BasicCachingClient();
         Session session = abderaClient.newSession();
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setHeader("Connection", "close");
-        options.setHeader("x-reqnum", "1");
-        ClientResponse response = session.get(CHECK_MUST_REVALIDATE, options);
+        ClientResponse response = 
+          session.get(
+            CHECK_MUST_REVALIDATE, 
+            session.getDefaultRequestOptions()
+              .header("Connection", "close")
+              .header("x-reqnum", "1")
+              .get());
 
         String resp1 = getResponse(response);
         assertEquals("1", resp1);
 
-        // Should be revalidated and use the cache
-        options.setHeader("x-reqnum", "2");
-        response = session.get(CHECK_MUST_REVALIDATE, options);
+        response = session.get(
+          CHECK_MUST_REVALIDATE, 
+          session.getDefaultRequestOptions()
+            .header("Connection", "close")
+            .header("x-reqnum", "2")
+            .get());
 
         assertEquals(304, response.getStatus());
 
-        // Should be revalidated and return a 404
-        options.setHeader("x-reqnum", "3");
-        response = session.get(CHECK_MUST_REVALIDATE, options);
+        response = session.get(
+          CHECK_MUST_REVALIDATE, 
+          session.getDefaultRequestOptions()
+            .header("Connection", "close")
+            .header("x-reqnum", "3")
+            .get());
         assertEquals(404, response.getStatus());
         response.release();
 
         abderaClient.shutdown();
     }
 
-    private RequestOptions getRequestOptions(Session session, int num) {
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setHeader("Connection", "close");
-        options.setHeader("x-reqnum", String.valueOf(num));
-        options.setUseExpectContinue(false);
-        return options;
+    private RequestOptions.Builder getRequestOptions(Session session, int num) {
+        return session.getDefaultRequestOptions()
+          .header("Connection", "close")
+          .header("x-reqnum", String.valueOf(num))
+          .doNotUseExpectContinue();
     }
 
     private void _methodInvalidates(int type) throws Exception {
 
         Client abderaClient = new BasicCachingClient();
         Session session = abderaClient.newSession();
-        RequestOptions options = getRequestOptions(session, 1);
-        ClientResponse response = session.get(CHECK_CACHE_INVALIDATE, options);
+        ClientResponse response = session.get(
+          CHECK_CACHE_INVALIDATE, 
+          getRequestOptions(session, 1).get());
 
         String resp1 = getResponse(response);
 
         response.release();
         assertEquals("1", resp1);
 
-        // calling a method that could change state on the server should invalidate the cache
-        options = getRequestOptions(session, 2);
         switch (type) {
             case POST:
-                response = session.post(CHECK_CACHE_INVALIDATE, new ByteArrayInputStream("".getBytes()),
options);
+                response = session.post(
+                  CHECK_CACHE_INVALIDATE, 
+                  new ByteArrayInputStream("".getBytes()), 
+                  getRequestOptions(session, 2).get());
                 break;
             case PUT:
-                response = session.put(CHECK_CACHE_INVALIDATE, new ByteArrayInputStream("".getBytes()),
options);
+                response = session.put(
+                  CHECK_CACHE_INVALIDATE, 
+                  new ByteArrayInputStream("".getBytes()), 
+                  getRequestOptions(session, 2).get());
                 break;
             case DELETE:
-                response = session.delete(CHECK_CACHE_INVALIDATE, options);
+                response = session.delete(
+                  CHECK_CACHE_INVALIDATE, 
+                  getRequestOptions(session, 2).get());
                 break;
         }
         response.release();
-
-        options = getRequestOptions(session, 3);
-        response = session.get(CHECK_CACHE_INVALIDATE, options);
+        
+        response = session.get(
+          CHECK_CACHE_INVALIDATE, 
+          getRequestOptions(session, 3).get());
 
         resp1 = getResponse(response);
         response.release();
@@ -382,50 +398,51 @@ public class CacheTest {
 
         BasicCachingClient abderaClient = new BasicCachingClient();
         Session session = abderaClient.newSession();
-        RequestOptions options = getRequestOptions(session, 1);
-        ClientResponse response = session.get(CHECK_CACHE_INVALIDATE, options);
+        ClientResponse response = session.get(
+          CHECK_CACHE_INVALIDATE, 
+          getRequestOptions(session, 1).get());
         String resp1 = getResponse(response);
         assertEquals("1", resp1);
 
         // Should use the cache
-        options = getRequestOptions(session, 3);
+        RequestOptions.Builder builder = getRequestOptions(session, 3);
         switch (type) {
-            case NOCACHE:
-                options.setCacheControl(CacheControl.NONNOCACHE());
-                break;
-            case NOSTORE:
-              options.setCacheControl(CacheControl.NONNOSTORE());
-                break;
-            case MAXAGE0:
-              options.setCacheControl(CacheControl.MAXAGE(60));
-              try {
-                // sleep for a few seconds to let the cache age;
-                Thread.sleep(5*1000);
-              } catch (Throwable t) {}
-                break;
+          case NOCACHE:
+            builder.cacheControl(CacheControl.NONNOCACHE());
+            break;
+          case NOSTORE:
+            builder.cacheControl(CacheControl.NONNOSTORE());
+            break;
+          case MAXAGE0:
+            builder.cacheControl(CacheControl.MAXAGE(60));
+            try {
+              // sleep for a few seconds to let the cache age;
+              Thread.sleep(5*1000);
+            } catch (Throwable t) {}
+              break;
         }
-        response = session.get(CHECK_CACHE_INVALIDATE, options);
+        response = session.get(CHECK_CACHE_INVALIDATE, builder.get());
         String resp3 = getResponse(response);
         assertEquals("1", resp3);
         
         // Should not use the cache
-        options = getRequestOptions(session, 2);
+        builder = getRequestOptions(session, 2);
         switch (type) {
-            case NOCACHE:
-                options.setCacheControl(CacheControl.NOCACHE());
-                break;
-            case NOSTORE:
-                options.setCacheControl(CacheControl.NOSTORE());
-                break;
-            case MAXAGE0:
-                options.setCacheControl(CacheControl.MAXAGE(0));
-                try {
-                  // sleep for a few seconds to let the cache age;
-                  Thread.sleep(5*1000);
-                } catch (Throwable t) {}
-                break;
+          case NOCACHE:
+            builder.cacheControl(CacheControl.NOCACHE());
+            break;
+          case NOSTORE:
+            builder.cacheControl(CacheControl.NOSTORE());
+            break;
+          case MAXAGE0:
+            builder.cacheControl(CacheControl.MAXAGE(0));
+            try {
+              // sleep for a few seconds to let the cache age;
+              Thread.sleep(5*1000);
+            } catch (Throwable t) {}
+            break;
         }
-        response = session.get(CHECK_CACHE_INVALIDATE, options);
+        response = session.get(CHECK_CACHE_INVALIDATE, builder.get());
 
         String resp2 = getResponse(response);
         assertEquals("2", resp2);
@@ -437,26 +454,32 @@ public class CacheTest {
 
         Client abderaClient = new BasicCachingClient();
         Session session = abderaClient.newSession();
-        RequestOptions options = getRequestOptions(session, 1);
-        options.setHeader("x-reqtest", String.valueOf(type));
-        ClientResponse response = session.get(CHECK_NO_CACHE, options);
+        ClientResponse response = 
+          session.get(
+            CHECK_NO_CACHE, 
+            getRequestOptions(session, 1)
+              .header("x-reqtest", String.valueOf(type))
+              .get());
 
         String resp1 = getResponse(response);
         assertEquals("1", resp1);
 
         // Should not use the cache
-
-        options = getRequestOptions(session, 2);
-        options.setHeader("x-reqtest", String.valueOf(type));
-        response = session.get(CHECK_NO_CACHE, options);
+        response = session.get(
+          CHECK_NO_CACHE, 
+          getRequestOptions(session, 2)
+            .header("x-reqtest", String.valueOf(type))
+            .get());
 
         String resp2 = getResponse(response);
         assertEquals("2", resp2);
 
         // Should use the cache
-        options = getRequestOptions(session, 3);
-        options.setHeader("x-reqtest", String.valueOf(type));
-        response = session.get(CHECK_NO_CACHE, options);
+        response = session.get(
+          CHECK_NO_CACHE, 
+          getRequestOptions(session, 3)
+            .header("x-reqtest", String.valueOf(type))
+            .get());
 
         String resp3 = getResponse(response);
         assertEquals("3", resp3);

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicTest.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicTest.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicTest.java
Sat Nov 12 04:25:22 2011
@@ -36,7 +36,6 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.AbderaClientResponse;
 import org.apache.abdera2.protocol.client.AbderaSession;
 import org.apache.abdera2.protocol.client.ClientResponse;
-import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.client.Session;
 import org.apache.abdera2.test.server.JettyServer;
 import org.apache.abdera2.common.Constants;
@@ -126,9 +125,10 @@ public class BasicTest {
     public void testPostMedia() {
         Session session = client.newSession();
         ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03,
0x04});
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setContentType("application/octet-stream");
-        ClientResponse resp = session.post("http://localhost:9002/sample", in, options);
+        ClientResponse resp = session.post(
+          "http://localhost:9002/sample", 
+          in, session.getDefaultRequestOptions()
+            .contentType("application/octet-stream").get());
         assertEquals(ResponseType.CLIENT_ERROR, resp.getType());
         assertEquals(405, resp.getStatus());
         resp.release();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProviderTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProviderTest.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProviderTest.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProviderTest.java
Sat Nov 12 04:25:22 2011
@@ -38,7 +38,6 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.AbderaClientResponse;
 import org.apache.abdera2.protocol.client.AbderaSession;
 import org.apache.abdera2.protocol.client.ClientResponse;
-import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.client.Session;
 import org.apache.abdera2.test.server.JettyServer;
 import org.apache.abdera2.common.Constants;
@@ -161,9 +160,11 @@ public class CustomProviderTest {
     public void testPostMedia() {
       Session session = client.newSession();
         ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03,
0x04});
-        RequestOptions options = session.getDefaultRequestOptions();
-        options.setContentType("application/octet-stream");
-        ClientResponse resp = session.post(BASE + "/feed", in, options);
+        ClientResponse resp = session.post(
+          BASE + "/feed", in, 
+          session.getDefaultRequestOptions()
+            .contentType("application/octet-stream")
+            .get());
         assertEquals(ResponseType.CLIENT_ERROR, resp.getType());
         assertEquals(405, resp.getStatus());
         resp.release();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java?rev=1201185&r1=1201184&r2=1201185&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
Sat Nov 12 04:25:22 2011
@@ -40,7 +40,6 @@ import org.apache.abdera2.model.Workspac
 import org.apache.abdera2.protocol.client.AbderaClient;
 import org.apache.abdera2.protocol.client.AbderaClientResponse;
 import org.apache.abdera2.protocol.client.AbderaSession;
-import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.server.AtompubProvider;
 import org.apache.abdera2.protocol.server.impl.DefaultAtompubProvider;
 import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
@@ -56,7 +55,7 @@ import org.junit.Test;
 
 public class CustomerAdapterTest {
 
-    private DefaultAtompubProvider customerProvider;
+    DefaultAtompubProvider customerProvider;
 
     private void setupAbdera(String base) throws Exception {
         customerProvider = new DefaultAtompubProvider(base);
@@ -137,9 +136,12 @@ public class CustomerAdapterTest {
         customerEl.setAttributeValue(new QName("name"), "Dan Diephouse");
         entry.setContent(customerEl);
 
-        RequestOptions opts = new RequestOptions();
-        opts.setContentType("application/atom+xml;type=entry");
-        res = (AbderaClientResponse) session.post(colUri.toString() + "?test=foo", entry,
opts);
+        res = (AbderaClientResponse) session.post(
+          colUri.toString() + "?test=foo", 
+          entry,
+          session.getDefaultRequestOptions()
+            .contentType("application/atom+xml;type=entry")
+            .get());
         assertEquals(201, res.getStatus());
 
         // prettyPrint(abdera, res.getDocument());



Mime
View raw message