incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r789101 - in /incubator/wink/sandbox: wink-common/src/main/java/org/apache/wink/common/internal/ wink-common/src/main/java/org/apache/wink/common/internal/providers/header/ wink-common/src/test/java/org/apache/wink/common/internal/ wink-com...
Date Sun, 28 Jun 2009 13:56:03 GMT
Author: elman
Date: Sun Jun 28 13:56:02 2009
New Revision: 789101

URL: http://svn.apache.org/viewvc?rev=789101&view=rev
Log:
See https://issues.apache.org/jira/browse/WINK-15

Modified:
    incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/ResponseImpl.java
    incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
    incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java
    incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/ResponseImplTest.java
    incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegateTest.java
    incubator/wink/sandbox/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
    incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/jaxrs/HttpHeadersImplTest.java
    incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java

Modified: incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/ResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/ResponseImpl.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/ResponseImpl.java
(original)
+++ incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/ResponseImpl.java
Sun Jun 28 13:56:02 2009
@@ -33,204 +33,204 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Variant;
 
-
 public class ResponseImpl extends Response {
-	
-	private static final int DEFAULT_STATUS = -1;
-	
-	private Object entity ;
-	private int status = DEFAULT_STATUS;
-	private MultivaluedMap<String,Object> metadata;
-	
-	private ResponseImpl(int status, Object entity,MultivaluedMap<String,Object> metadata){
-		this.status = status;
-		this.entity = entity;
-		this.metadata = metadata;
-	}
-
-
-	@Override
-	public Object getEntity() {
-		return entity;
-	}
-
-	@Override
-	public MultivaluedMap<String, Object> getMetadata() {
-		return metadata;
-	}
-
-	@Override
-	public int getStatus() {
-		return status;
-	}
-	
-	public static class ResponseBuilderImpl extends ResponseBuilder{
-		private Object entity;
-		private int status;
-		private MultivaluedMap<String, Object> metadata;
-		
-		public ResponseBuilderImpl(){
-			super();
-			metadata = new MultivaluedMapImpl<String,Object>();
-			status = DEFAULT_STATUS;
-			
-		}
-		
-		private ResponseBuilderImpl(int status, Object entity,MultivaluedMap<String,Object>
metadata){
-			super();
-			this.status = status;
-			this.entity = entity;
-			this.metadata = metadata;			
-		}
-		
-
-		@Override
-		public Response build() {
-			return new ResponseImpl(status,entity,metadata);
-		}
-
-		@Override
-		public ResponseBuilder cacheControl(CacheControl cacheControl) {
-			return putSingleRemoveNull(HttpHeaders.CACHE_CONTROL,cacheControl);
-		}
-
-		@Override
-		public ResponseBuilder clone() {
-			return new ResponseBuilderImpl(status,entity,metadata);
-		}
-
-		@Override
-		public ResponseBuilder contentLocation(URI location) {
-			return putSingleRemoveNull(HttpHeaders.CONTENT_LOCATION, location);
-		}
-
-		@Override
-		public ResponseBuilder cookie(NewCookie... cookies) {
-			if(cookies == null)
-				metadata.remove(HttpHeaders.COOKIE);
-			else{
-				for(NewCookie cooky :cookies)
-					metadata.add(HttpHeaders.COOKIE,cooky);
-			}
-			return this;
-		}
-
-		@Override
-		public ResponseBuilder entity(Object entity) {
-			this.entity = entity;
-			return this;
-		}		
-		
-		@Override
-		public ResponseBuilder expires(Date expires) {
-			return putSingleRemoveNull(HttpHeaders.EXPIRES, expires);
-		}
-
-		@Override
-		public ResponseBuilder header(String name, Object value) {
-			return putSingleRemoveNull(name, value);			
-		}
-
-		@Override
-		public ResponseBuilder language(String language) {
-			return putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, language);
-		}
-
-		@Override
-		public ResponseBuilder language(Locale language) {
-			return putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, language);
-		}
-
-		@Override
-		public ResponseBuilder lastModified(Date lastModified) {
-			return putSingleRemoveNull(HttpHeaders.LAST_MODIFIED, lastModified);
-		}
-
-		@Override
-		public ResponseBuilder location(URI location) {
-			return putSingleRemoveNull(HttpHeaders.LOCATION, location);
-		}
-
-		@Override
-		public ResponseBuilder status(int status) {
-			this.status = status;
-			return this;
-		}
-
-		@Override
-		public ResponseBuilder tag(EntityTag tag) {
-			return putSingleRemoveNull(HttpHeaders.ETAG, tag);
-		}
-
-		@Override
-		public ResponseBuilder tag(String tag) {
-			return putSingleRemoveNull(HttpHeaders.ETAG, tag);
-		}
-
-		@Override
-		public ResponseBuilder type(MediaType type) {
-			return putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, type);
-		}
-
-		@Override
-		public ResponseBuilder type(String type) {
-			return putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, type);
-		}
-
-		@Override
-		public ResponseBuilder variant(Variant variant) {
-			if(variant != null){
-				language(variant.getLanguage());
-				putSingleRemoveNull(HttpHeaders.CONTENT_ENCODING, variant.getEncoding());
-				type(variant.getMediaType());
-			}else{
-				
-				putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, null);
-				putSingleRemoveNull(HttpHeaders.CONTENT_ENCODING, null);
-				putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, null);
-			}
-			return this;
-		}
-
-		@Override
-		public ResponseBuilder variants(List<Variant> variants) {
-			if(variants == null){
-				putSingleRemoveNull(HttpHeaders.VARY, null);
-				return this;
-			}
-			boolean encoding = false;
-			boolean lang = false;
-			boolean medyatype = false;
-						
-			for(Variant v : variants){
-				encoding = encoding || (v.getEncoding()!= null);
-				lang = lang || (v.getLanguage()!= null);
-				medyatype = medyatype || ( v.getMediaType()!= null);				
-			}
-			StringBuilder sb = new StringBuilder();
-			conditionalAppend(sb, encoding, HttpHeaders.CONTENT_ENCODING);
-			conditionalAppend(sb, lang, HttpHeaders.ACCEPT_LANGUAGE);
-			conditionalAppend(sb, medyatype, HttpHeaders.CONTENT_TYPE);
-			putSingleRemoveNull(HttpHeaders.VARY, sb.toString());
-			return this;
-		}
-		
-		///////////////////// helper methods ////////////////////////
-		public ResponseBuilder putSingleRemoveNull(String key,Object value) {
-			if(value == null)
-				metadata.remove(key);
-			else metadata.putSingle(key, value);
-			return this;
-		}
-		
-		private void conditionalAppend(StringBuilder sb,boolean b,String s){
-			if(b){
-				if(sb.length()>0)
-					sb.append(",");
-				sb.append(s);
-			}	
-		}
-		
-	}
+
+    private static final int               DEFAULT_STATUS = -1;
+
+    private Object                         entity;
+    private int                            status         = DEFAULT_STATUS;
+    private MultivaluedMap<String, Object> metadata;
+
+    private ResponseImpl(int status, Object entity, MultivaluedMap<String, Object>
metadata) {
+        this.status = status;
+        this.entity = entity;
+        this.metadata = metadata;
+    }
+
+    @Override
+    public Object getEntity() {
+        return entity;
+    }
+
+    @Override
+    public MultivaluedMap<String, Object> getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public int getStatus() {
+        return status;
+    }
+
+    public static class ResponseBuilderImpl extends ResponseBuilder {
+
+        private Object                         entity;
+        private int                            status;
+        private MultivaluedMap<String, Object> metadata;
+
+        public ResponseBuilderImpl() {
+            super();
+            metadata = new MultivaluedMapImpl<String, Object>();
+            status = DEFAULT_STATUS;
+
+        }
+
+        private ResponseBuilderImpl(int status, Object entity,
+            MultivaluedMap<String, Object> metadata) {
+            super();
+            this.status = status;
+            this.entity = entity;
+            this.metadata = metadata;
+        }
+
+        @Override
+        public Response build() {
+            return new ResponseImpl(status, entity, metadata);
+        }
+
+        @Override
+        public ResponseBuilder cacheControl(CacheControl cacheControl) {
+            return putSingleRemoveNull(HttpHeaders.CACHE_CONTROL, cacheControl);
+        }
+
+        @Override
+        public ResponseBuilder clone() {
+            return new ResponseBuilderImpl(status, entity, metadata);
+        }
+
+        @Override
+        public ResponseBuilder contentLocation(URI location) {
+            return putSingleRemoveNull(HttpHeaders.CONTENT_LOCATION, location);
+        }
+
+        @Override
+        public ResponseBuilder cookie(NewCookie... cookies) {
+            if (cookies == null)
+                metadata.remove(HttpHeaders.SET_COOKIE);
+            else {
+                for (NewCookie cooky : cookies)
+                    metadata.add(HttpHeaders.SET_COOKIE, cooky);
+            }
+            return this;
+        }
+
+        @Override
+        public ResponseBuilder entity(Object entity) {
+            this.entity = entity;
+            return this;
+        }
+
+        @Override
+        public ResponseBuilder expires(Date expires) {
+            return putSingleRemoveNull(HttpHeaders.EXPIRES, expires);
+        }
+
+        @Override
+        public ResponseBuilder header(String name, Object value) {
+            return putSingleRemoveNull(name, value);
+        }
+
+        @Override
+        public ResponseBuilder language(String language) {
+            return putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, language);
+        }
+
+        @Override
+        public ResponseBuilder language(Locale language) {
+            return putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, language);
+        }
+
+        @Override
+        public ResponseBuilder lastModified(Date lastModified) {
+            return putSingleRemoveNull(HttpHeaders.LAST_MODIFIED, lastModified);
+        }
+
+        @Override
+        public ResponseBuilder location(URI location) {
+            return putSingleRemoveNull(HttpHeaders.LOCATION, location);
+        }
+
+        @Override
+        public ResponseBuilder status(int status) {
+            this.status = status;
+            return this;
+        }
+
+        @Override
+        public ResponseBuilder tag(EntityTag tag) {
+            return putSingleRemoveNull(HttpHeaders.ETAG, tag);
+        }
+
+        @Override
+        public ResponseBuilder tag(String tag) {
+            return putSingleRemoveNull(HttpHeaders.ETAG, tag);
+        }
+
+        @Override
+        public ResponseBuilder type(MediaType type) {
+            return putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, type);
+        }
+
+        @Override
+        public ResponseBuilder type(String type) {
+            return putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, type);
+        }
+
+        @Override
+        public ResponseBuilder variant(Variant variant) {
+            if (variant != null) {
+                language(variant.getLanguage());
+                putSingleRemoveNull(HttpHeaders.CONTENT_ENCODING, variant.getEncoding());
+                type(variant.getMediaType());
+            } else {
+
+                putSingleRemoveNull(HttpHeaders.CONTENT_LANGUAGE, null);
+                putSingleRemoveNull(HttpHeaders.CONTENT_ENCODING, null);
+                putSingleRemoveNull(HttpHeaders.CONTENT_TYPE, null);
+            }
+            return this;
+        }
+
+        @Override
+        public ResponseBuilder variants(List<Variant> variants) {
+            if (variants == null) {
+                putSingleRemoveNull(HttpHeaders.VARY, null);
+                return this;
+            }
+            boolean encoding = false;
+            boolean lang = false;
+            boolean medyatype = false;
+
+            for (Variant v : variants) {
+                encoding = encoding || (v.getEncoding() != null);
+                lang = lang || (v.getLanguage() != null);
+                medyatype = medyatype || (v.getMediaType() != null);
+            }
+            StringBuilder sb = new StringBuilder();
+            conditionalAppend(sb, encoding, HttpHeaders.CONTENT_ENCODING);
+            conditionalAppend(sb, lang, HttpHeaders.ACCEPT_LANGUAGE);
+            conditionalAppend(sb, medyatype, HttpHeaders.CONTENT_TYPE);
+            putSingleRemoveNull(HttpHeaders.VARY, sb.toString());
+            return this;
+        }
+
+        ///////////////////// helper methods ////////////////////////
+        public ResponseBuilder putSingleRemoveNull(String key, Object value) {
+            if (value == null)
+                metadata.remove(key);
+            else
+                metadata.putSingle(key, value);
+            return this;
+        }
+
+        private void conditionalAppend(StringBuilder sb, boolean b, String s) {
+            if (b) {
+                if (sb.length() > 0)
+                    sb.append(",");
+                sb.append(s);
+            }
+        }
+
+    }
 
 }

Modified: incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
(original)
+++ incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
Sun Jun 28 13:56:02 2009
@@ -25,78 +25,92 @@
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
-
 public class CookieHeaderDelegate implements HeaderDelegate<Cookie> {
 
-    private static Pattern whitespace = Pattern.compile("\\s");
-    private static final String VERSION = "$Version";
-    private static final String DOMAIN = "$Domain";
-    private static final String PATH = "$Path";
+    private static Pattern      whitespace = Pattern.compile("\\s");
+    private static final String VERSION    = "$Version";
+    private static final String DOMAIN     = "$Domain";
+    private static final String PATH       = "$Path";
 
     public Cookie fromString(String cookie) throws IllegalArgumentException {
-        
-        if(cookie == null){
+
+        if (cookie == null) {
             throw new IllegalArgumentException("Cookie header is null");
         }
-        
+
         String tokens[] = cookie.split("[;,]");
 
         if (tokens.length <= 0) {
-            throw new IllegalArgumentException(" Invalid Cookie " + cookie);
+            throw new IllegalArgumentException("Invalid Cookie " + cookie);
         }
 
         ModifiableCookie firstCookie = null;
         int cookieNum = 0;
-        int version = 0;
 
         for (String token : tokens) {
-            String[] subTokens = token.split("=", 2);
+            String[] subTokens = token.trim().split("=", 2);
             String name = subTokens.length > 0 ? subTokens[0] : null;
             String value = subTokens.length > 1 ? subTokens[1] : null;
-            if (value != null && value.startsWith("\"") && value.endsWith("\"")
&& value.length() > 1) {
+            if (value != null && value.startsWith("\"") && value.endsWith("\"")
+                && value.length() > 1) {
                 value = value.substring(1, value.length() - 1);
             }
 
-            if (!name.trim().startsWith("$")) {
+            if (!name.startsWith("$")) {
                 cookieNum++;
                 if (cookieNum > 1) {
                     // Return only first Cookie
                     break;
                 }
-                firstCookie = new ModifiableCookie();
+                if (firstCookie == null) {
+                    throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
+                }
                 firstCookie.name = name;
                 firstCookie.value = value;
-                firstCookie.version = version;
             } else if (name.trim().startsWith("$Version")) {
+                if (firstCookie == null) {
+                    firstCookie = new ModifiableCookie();
+                } else {
+                    throw new IllegalArgumentException("Cookie cannot contain additional
$Version: " + cookie);
+                }
                 firstCookie.version = Integer.parseInt(value);
-            } else if (name.trim().startsWith("$Path") && cookie != null) {
+            } else if (name.startsWith("$Path") && cookie != null) {
+                if (firstCookie == null) {
+                    throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
+                }
                 firstCookie.path = value;
             } else if (name.trim().startsWith("$Domain") && cookie != null) {
+                if (firstCookie == null) {
+                    throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
+                }
                 firstCookie.domain = value;
             }
         }
+        if (cookieNum == 0) {
+            throw new IllegalArgumentException("Cookie doesn't contain NAME+VALUE: " + cookie);
+        }
 
-        if(firstCookie != null){
+        if (firstCookie != null) {
             return validateAndBuildCookie(firstCookie, cookie);
-        }
-        else{
+        } else {
             throw new IllegalArgumentException("Failed to parse Cookie " + cookie);
         }
     }
 
     private Cookie validateAndBuildCookie(ModifiableCookie firstCookie, String cookie) {
-        if(firstCookie.name==null || firstCookie.value==null){
+        if (firstCookie.name == null || firstCookie.value == null) {
             throw new IllegalArgumentException("Failed to parse Cookie " + cookie);
         }
-        return new Cookie(firstCookie.name, firstCookie.value, firstCookie.path, firstCookie.domain,
firstCookie.version);
-        
+        return new Cookie(firstCookie.name, firstCookie.value, firstCookie.path,
+            firstCookie.domain, firstCookie.version);
+
     }
 
     public String toString(Cookie cookie) {
-        if(cookie == null){
+        if (cookie == null) {
             throw new IllegalArgumentException("Cookie header is null");
         }
-        
+
         StringBuilder cookieHeader = new StringBuilder();
 
         cookieHeader.append(VERSION + "=").append(cookie.getVersion()).append(';');
@@ -137,9 +151,10 @@
     }
 
     private static class ModifiableCookie {
+
         public String name;
         public String value;
-        public int version = Cookie.DEFAULT_VERSION;
+        public int    version = Cookie.DEFAULT_VERSION;
         public String path;
         public String domain;
     }

Modified: incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java
(original)
+++ incubator/wink/sandbox/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java
Sun Jun 28 13:56:02 2009
@@ -101,7 +101,7 @@
             sb.append(";Domain=").append(domain);
         if (comment != null)
             sb.append(";Comment=").append(comment);
-        if (maxAge != 0) {
+        if (maxAge >= 0) {
             sb.append(";Max-Age=").append(maxAge);
         }
         if (secure)

Modified: incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/ResponseImplTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/ResponseImplTest.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/ResponseImplTest.java
(original)
+++ incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/ResponseImplTest.java
Sun Jun 28 13:56:02 2009
@@ -47,7 +47,7 @@
 		URI loc = new URI("/defects/5");
 		r = Response.created(loc).cookie(new NewCookie("cName","cValue")).expires(new Date()).build();
 		assertEquals(loc,r.getMetadata().getFirst(HttpHeaders.LOCATION));
-		assertTrue(r.getMetadata().getFirst(HttpHeaders.COOKIE).toString().indexOf("cName") >-1);
+		assertTrue(r.getMetadata().getFirst(HttpHeaders.SET_COOKIE).toString().indexOf("cName")
>-1);
 		
 		r = Response.serverError().build();
 		assertTrue(r.getStatus()>= 500);

Modified: incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegateTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegateTest.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegateTest.java
(original)
+++ incubator/wink/sandbox/wink-common/src/test/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegateTest.java
Sun Jun 28 13:56:02 2009
@@ -39,14 +39,14 @@
         }
 
         Cookie expectedNewCookie = new Cookie("MyCookie", "MyCookieValue", ".", "mydomain",
1);
-        String cookieToParse = "MyCookie=MyCookieValue;$Version=1; $Path=.; $Domain=mydomain,
SecondCookie=Value";
+        String cookieToParse = "$Version=1; MyCookie=MyCookieValue; $Path=.; $Domain=mydomain,
SecondCookie=Value";
 
         // Test Parse Cookie
         Cookie parsedNewCookie = cookieHeaderDelegate.fromString(cookieToParse);
         assertEquals(expectedNewCookie, parsedNewCookie);
 
         expectedNewCookie = new Cookie("MyCookie", "", ".", "mydomain", 1);
-        cookieToParse = "MyCookie=\"\";$Version=1; $Path=.; $Domain=mydomain;";
+        cookieToParse = "$Version=1; MyCookie=\"\"; $Path=.; $Domain=mydomain;";
         parsedNewCookie = cookieHeaderDelegate.fromString(cookieToParse);
         assertEquals(expectedNewCookie, parsedNewCookie);
 

Modified: incubator/wink/sandbox/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
(original)
+++ incubator/wink/sandbox/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServerInjectableFactory.java
Sun Jun 28 13:56:02 2009
@@ -440,8 +440,7 @@
             }
             
             if (cookie == null && hasDefaultValue()) {
-                value = getName() + "=" + getDefaultValue();
-                cookie = Cookie.valueOf(value);
+                cookie = new Cookie(getName(), getDefaultValue());
             }
 
             if (cookie != null) {

Modified: incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/jaxrs/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/jaxrs/HttpHeadersImplTest.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/jaxrs/HttpHeadersImplTest.java
(original)
+++ incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/jaxrs/HttpHeadersImplTest.java
Sun Jun 28 13:56:02 2009
@@ -71,8 +71,8 @@
         	// Cookies
         	Map<String, Cookie> cookies = headers.getCookies();
         	assertEquals(2, cookies.size());
-        	assertEquals(Cookie.valueOf("cookie1_name=cookie1_val"), cookies.get("cookie1_name"));
-            assertEquals(Cookie.valueOf("cookie2_name=cookie2_val"), cookies.get("cookie2_name"));
+        	assertEquals(new Cookie("cookie1_name", "cookie1_val"), cookies.get("cookie1_name"));
+            assertEquals(new Cookie("cookie2_name", "cookie2_val"), cookies.get("cookie2_name"));
         	
         	// Language
         	Locale language = headers.getLanguage();
@@ -105,8 +105,8 @@
             assertEquals(1, requestHeaders.get("Content-Language").size());
             assertEquals("en-us, he", requestHeaders.get("Content-Language").get(0));
             assertEquals(2, requestHeaders.get("Cookie").size());
-            assertEquals("cookie1_name=cookie1_val", requestHeaders.get("Cookie").get(0));
-            assertEquals("cookie2_name=cookie2_val", requestHeaders.get("Cookie").get(1));
+            assertEquals("$Version=1; cookie1_name=cookie1_val", requestHeaders.get("Cookie").get(0));
+            assertEquals("$Version=1; cookie2_name=cookie2_val", requestHeaders.get("Cookie").get(1));
             assertEquals(1, requestHeaders.get("Accept-Language").size());
             assertEquals("en;q=0.3, en-us, he;q=0.5", requestHeaders.get("Accept-Language").get(0));
             assertEquals(2, requestHeaders.get("Header1").size());
@@ -162,8 +162,8 @@
         MockHttpServletRequest servletRequest = MockRequestConstructor.constructMockRequest("GET",
"/test", "application/xml;q=0.3, text/plain, text/html;q=0.5");
         servletRequest.addHeader("Content-Type", "application/xml");
         servletRequest.addHeader("Content-Language", "en-us, he");
-        servletRequest.addHeader("Cookie", "cookie1_name=cookie1_val");
-        servletRequest.addHeader("Cookie", "cookie2_name=cookie2_val");
+        servletRequest.addHeader("Cookie", "$Version=1; cookie1_name=cookie1_val");
+        servletRequest.addHeader("Cookie", "$Version=1; cookie2_name=cookie2_val");
         servletRequest.addHeader("Accept-Language", "en;q=0.3, en-us, he;q=0.5");
         servletRequest.addHeader("header1", "value1");
         servletRequest.addHeader("header1", "value2");

Modified: incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java?rev=789101&r1=789100&r2=789101&view=diff
==============================================================================
--- incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
(original)
+++ incubator/wink/sandbox/wink-server/src/test/java/org/apache/wink/server/internal/registry/InjectableDataTest.java
Sun Jun 28 13:56:02 2009
@@ -758,14 +758,14 @@
         @Path("cookie")
         @Produces
         public void getCookie(@CookieParam("c") Cookie p) {
-            assertEquals(Cookie.valueOf("c=cookieVal"), p);
+            assertEquals(Cookie.valueOf("$Version=1; c=cookieVal"), p);
         }
 
         @GET
         @Path("cookieDefault")
         @Produces
         public void getCookieDefault(@DefaultValue("b") @CookieParam("k") Cookie p) {
-            assertEquals(Cookie.valueOf("k=b"), p);
+            assertEquals(Cookie.valueOf("$Version=1; k=b"), p);
         }
 
         @GET
@@ -780,7 +780,7 @@
         @Produces
         public void getCookieSimpleList(@CookieParam("c") List<Cookie> p) {
             assertEquals(1, p.size());
-            assertEquals(Cookie.valueOf("c=cookieVal"), p.get(0));
+            assertEquals(Cookie.valueOf("$Version=1; c=cookieVal"), p.get(0));
         }
 
         @GET
@@ -788,7 +788,7 @@
         @Produces
         public void getCookieDefaultList(@DefaultValue("b") @CookieParam("k") List<Cookie>
p) {
             assertEquals(1, p.size());
-            assertEquals(Cookie.valueOf("k=b"), p.get(0));
+            assertEquals(Cookie.valueOf("$Version=1; k=b"), p.get(0));
         }
         
         @GET
@@ -803,7 +803,7 @@
         @Produces
         public void getCookieSimpleSet(@CookieParam("c") Set<Cookie> p) {
             assertEquals(1, p.size());
-            assertTrue(p.contains(Cookie.valueOf("c=cookieVal")));
+            assertTrue(p.contains(Cookie.valueOf("$Version=1; c=cookieVal")));
         }
 
         @GET
@@ -811,7 +811,7 @@
         @Produces
         public void getCookieDefaultSet(@DefaultValue("b") @CookieParam("k") Set<Cookie>
p) {
             assertEquals(1, p.size());
-            assertTrue(p.contains(Cookie.valueOf("k=b")));
+            assertTrue(p.contains(Cookie.valueOf("$Version=1; k=b")));
         }
 
         @GET
@@ -819,7 +819,7 @@
         @Produces
         public void getCookieSimpleSortedSet(@CookieParam("c") SortedSet<Cookie> p)
{
             assertEquals(1, p.size());
-            assertTrue(p.contains(Cookie.valueOf("c=cookieVal")));
+            assertTrue(p.contains(Cookie.valueOf("$Version=1; c=cookieVal")));
         }
 
         @GET
@@ -827,7 +827,7 @@
         @Produces
         public void getCookieDefaultSortedSet(@DefaultValue("b") @CookieParam("k") SortedSet<Cookie>
p) {
             assertEquals(1, p.size());
-            assertTrue(p.contains(Cookie.valueOf("k=b")));
+            assertTrue(p.contains(Cookie.valueOf("$Version=1; k=b")));
         }
 
     }
@@ -1040,7 +1040,7 @@
 
     public void testCookieParam() {
         MultivaluedMap<String,String> headers = new MultivaluedMapImpl<String,String>();
-        headers.add("Cookie", "c=cookieVal");
+        headers.add("Cookie", "$Version=1; c=cookieVal");
         assertInvocation("cookieParam/simple", headers);
         assertInvocation("cookieParam/default", headers);
         assertInvocation("cookieParam/simpleList", headers);



Mime
View raw message