abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r555848 - /incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
Date Fri, 13 Jul 2007 02:57:37 GMT
Author: jmsnell
Date: Thu Jul 12 19:57:36 2007
New Revision: 555848

URL: http://svn.apache.org/viewvc?view=rev&rev=555848
Log:
Fix the caching tests

Modified:
    incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java

Modified: incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java?view=diff&rev=555848&r1=555847&r2=555848
==============================================================================
--- incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
(original)
+++ incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
Thu Jul 12 19:57:36 2007
@@ -283,12 +283,17 @@
 
   }
   
+  private RequestOptions getRequestOptions(AbderaClient client, int num) {
+    RequestOptions options = client.getDefaultRequestOptions();
+    options.setHeader("Connection", "close");
+    options.setHeader("x-reqnum", String.valueOf(num));
+    return options;
+  }
+  
   private void _methodInvalidates(int type) throws Exception {
     
     AbderaClient abderaClient = new AbderaClient();
-    RequestOptions options = abderaClient.getDefaultRequestOptions();
-    options.setHeader("Connection", "close");
-    options.setHeader("x-reqnum", "1");
+    RequestOptions options = getRequestOptions(abderaClient,1);
     ClientResponse response = abderaClient.get(CHECK_CACHE_INVALIDATE, options);
   
     String resp1 = getResponse(response);
@@ -296,7 +301,7 @@
     assertEquals(resp1, "1");
     
     // calling a method that could change state on the server should invalidate the cache
-    options.setHeader("x-reqnum", "2");
+    options = getRequestOptions(abderaClient,2);
     switch(type) {
       case POST:  
         response = abderaClient.post(
@@ -318,7 +323,7 @@
     }
     response.release();
     
-    options.setHeader("x-reqnum", "3");
+    options = getRequestOptions(abderaClient,3);
     response = abderaClient.get(CHECK_CACHE_INVALIDATE, options);
   
     resp1 = getResponse(response);
@@ -329,15 +334,13 @@
   private void _requestCacheInvalidation(int type) throws Exception {
     
     AbderaClient abderaClient = new AbderaClient();
-    RequestOptions options = abderaClient.getDefaultRequestOptions();
-    options.setHeader("Connection", "close");
-    options.setHeader("x-reqnum", "1");
+    RequestOptions options = getRequestOptions(abderaClient,1);
     ClientResponse response = abderaClient.get(CHECK_CACHE_INVALIDATE, options);  
     String resp1 = getResponse(response);
     assertEquals(resp1, "1");
     
     // Should not use the cache
-    options.setHeader("x-reqnum", "2");
+    options = getRequestOptions(abderaClient,2);
     switch(type) {
       case NOCACHE: options.setNoCache(true); break;
       case NOSTORE: options.setNoStore(true); break;
@@ -349,7 +352,7 @@
     assertEquals(resp2, "2");
     
     // Should use the cache
-    options.setHeader("x-reqnum", "3");
+    options =getRequestOptions(abderaClient,3);
     switch(type) {
       case NOCACHE: options.setNoCache(false); break;
       case NOSTORE: options.setNoStore(false); break;
@@ -364,9 +367,7 @@
   private void _responseNoCache(int type) throws Exception {
     
     AbderaClient abderaClient = new AbderaClient();
-    RequestOptions options = abderaClient.getDefaultRequestOptions();
-    options.setHeader("Connection", "close");
-    options.setHeader("x-reqnum", "1");
+    RequestOptions options = getRequestOptions(abderaClient,1);
     options.setHeader("x-reqtest", String.valueOf(type));
     ClientResponse response = abderaClient.get(CHECK_NO_CACHE, options);
   
@@ -374,14 +375,17 @@
     assertEquals(resp1, "1");
     
     // Should not use the cache
-    options.setHeader("x-reqnum", "2");
+    
+    options = getRequestOptions(abderaClient,2);
+    options.setHeader("x-reqtest", String.valueOf(type));
     response = abderaClient.get(CHECK_NO_CACHE, options);
   
     String resp2 = getResponse(response);
     assertEquals(resp2, "2");
     
     // Should use the cache
-    options.setHeader("x-reqnum", "3");
+    options = getRequestOptions(abderaClient,3);
+    options.setHeader("x-reqtest", String.valueOf(type));
     response = abderaClient.get(CHECK_NO_CACHE, options);
   
     String resp3 = getResponse(response);



Mime
View raw message