abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1222387 - in /abdera/abdera2: common/src/main/java/org/apache/abdera2/common/http/EntityTag.java test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
Date Thu, 22 Dec 2011 18:20:53 GMT
Author: jmsnell
Date: Thu Dec 22 18:20:52 2011
New Revision: 1222387

URL: http://svn.apache.org/viewvc?rev=1222387&view=rev
Log:
Test cases and fixes

Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java?rev=1222387&r1=1222386&r2=1222387&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java Thu
Dec 22 18:20:52 2011
@@ -28,6 +28,7 @@ import java.util.List;
 
 import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.misc.MoreFunctions;
+import org.apache.abdera2.common.text.CharUtils;
 import org.apache.abdera2.common.text.UrlEncoding;
 
 import com.google.common.base.Function;
@@ -62,6 +63,7 @@ public class EntityTag 
         entity_tag.charAt(pos) == '"' && 
         entity_tag.charAt(l) == '"',"Invalid");
       String tag = entity_tag.substring(pos+1,l);
+      tag = CharUtils.unescape(CharUtils.unquote(tag));
       return new EntityTag(tag, weak, false);
     }
 

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java?rev=1222387&r1=1222386&r2=1222387&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
(original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
Thu Dec 22 18:20:52 2011
@@ -3,12 +3,16 @@ package org.apache.abdera2.test.common.h
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.*;
 
 import java.util.Arrays;
 
 import org.apache.abdera2.common.http.EntityTag;
 import org.junit.Test;
 
+import com.google.common.collect.Iterables;
+
 public class EntityTagTest {
   @Test
   public void testEntityTag() throws Exception {
@@ -56,4 +60,22 @@ public class EntityTagTest {
       assertEquals("\"e2fc714c4727ee9395f324cd2e7f331f\"", etag.toString().toLowerCase());
   }
 
+  @Test
+  public void simpleetagquoted() {
+    EntityTag etag = new EntityTag("W/\"\\\"foo\\\\\"");
+    assertTrue(etag.isWeak());
+    assertEquals("\"foo\\",etag.getTag());
+  }
+  
+  @SuppressWarnings("unchecked")
+  @Test
+  public void multiple() {
+    Iterable<EntityTag> tags = EntityTag.parseTags("\"foo\", W/\"bar\", \"\\\\whee\\\"\"");
+    assertEquals(3,Iterables.size(tags));
+    for (EntityTag etag : tags) {
+      assertThat(etag.getTag(), anyOf(is("foo"),is("bar"),is("\\whee\"")));
+      if (etag.getTag().equals("bar"))
+        assertTrue(etag.isWeak());
+    }
+  }
 }



Mime
View raw message