cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1370731 - in /cxf/trunk: parent/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ rt/fr...
Date Wed, 08 Aug 2012 10:28:30 GMT
Author: sergeyb
Date: Wed Aug  8 10:28:29 2012
New Revision: 1370731

URL: http://svn.apache.org/viewvc?rev=1370731&view=rev
Log:
[CXF-4455] Starting the initial upgrade to javax.ws.rs.api 2.0

Modified:
    cxf/trunk/parent/pom.xml
    cxf/trunk/rt/frontend/jaxrs/pom.xml
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java

Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Wed Aug  8 10:28:29 2012
@@ -148,7 +148,7 @@
         <cxf.geronimo.servlet.version>1.0</cxf.geronimo.servlet.version>
         <cxf.geronimo.servlet25.version>1.1.2</cxf.geronimo.servlet25.version>
         <cxf.geronimo.jpa.version>1.0</cxf.geronimo.jpa.version>
- 
+        <cxf.javax.ws.rs.version>2.0-m09</cxf.javax.ws.rs.version>
         <cxf.commons-codec.version>1.4</cxf.commons-codec.version>
         <cxf.commons-lang.version>2.6</cxf.commons-lang.version>
         <cxf.commons-collections.version>3.2.1</cxf.commons-collections.version>
@@ -527,8 +527,8 @@
         <dependencies>
             <dependency>
                 <groupId>javax.ws.rs</groupId>
-                <artifactId>jsr311-api</artifactId>
-                <version>1.1.1</version>
+                <artifactId>javax.ws.rs-api</artifactId>
+                <version>${cxf.javax.ws.rs.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.aries.blueprint</groupId>

Modified: cxf/trunk/rt/frontend/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/pom.xml Wed Aug  8 10:28:29 2012
@@ -78,7 +78,7 @@
         </dependency>
         <dependency>
             <groupId>javax.ws.rs</groupId>
-            <artifactId>jsr311-api</artifactId>
+            <artifactId>javax.ws.rs-api</artifactId>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Wed Aug  8 10:28:29 2012
@@ -259,7 +259,11 @@ public abstract class AbstractClient imp
         if (state.getResponseBuilder() == null) {
             return null;
         }
-        return state.getResponseBuilder().clone().build();
+        try {
+            return state.getResponseBuilder().clone().build();
+        } catch (CloneNotSupportedException ex) {
+            throw new ClientWebApplicationException(ex);
+        }
     }
     
     /**

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
Wed Aug  8 10:28:29 2012
@@ -57,7 +57,11 @@ public class LocalClientState implements
     public LocalClientState(LocalClientState cs) {
         this.requestHeaders = new MetadataMap<String, String>(cs.requestHeaders);
         this.templates = cs.templates == null ? null : new MetadataMap<String, String>(cs.templates);
-        this.responseBuilder = cs.responseBuilder != null ? cs.responseBuilder.clone() :
null;
+        try {
+            this.responseBuilder = cs.responseBuilder != null ? cs.responseBuilder.clone()
: null;
+        } catch (CloneNotSupportedException ex) {
+            throw new ClientWebApplicationException(ex);
+        }
         this.baseURI = cs.baseURI;
         this.currentBuilder = cs.currentBuilder != null ? cs.currentBuilder.clone() : null;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
Wed Aug  8 10:28:29 2012
@@ -64,8 +64,7 @@ public class ServerWebApplicationExcepti
         super(cause, response);
     }
     
-    @Override
-    public Response getResponse() {
+    public Response getServerResponse() {
         Response response = super.getResponse();
         
         ResponseBuilder rb = Response.status(response.getStatus());
@@ -144,7 +143,7 @@ public class ServerWebApplicationExcepti
      * @return the typed entity
      */
     public <T> T toErrorObject(Client client, Class<T> entityCls) {
-        Response response = getResponse();
+        Response response = getServerResponse();
         try {
             MultivaluedMap<String, String> headers = getHeaders();
             Object contentType = headers.getFirst("Content-Type");

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Wed Aug  8 10:28:29 2012
@@ -20,9 +20,11 @@
 package org.apache.cxf.jaxrs.impl;
 
 
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -39,6 +41,7 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
@@ -272,5 +275,50 @@ public class HttpHeadersImpl implements 
             });
         }
     }
+
+    public Date getDate() {
+        List<String> values = headers.get(HttpHeaders.DATE);
+        if (values == null || StringUtils.isEmpty(values.get(0))) {
+            return null;
+        }
+        try {
+            return HttpUtils.getHttpDateFormat().parse(values.get(0));
+        } catch (ParseException ex) {
+            return null;
+        }
+    }
+
+    public String getHeaderString(String headerName) {
+        List<String> values = headers.get(headerName);
+        if (values == null) {
+            return null;
+        } else {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < values.size(); i++) {
+                String value = values.get(i);
+                if (StringUtils.isEmpty(value)) {
+                    continue;
+                }
+                sb.append(value);
+                if (i + 1 < values.size()) {
+                    sb.append(",");
+                }
+            }
+            return sb.toString();
+        }
+    }
+
+    public int getLength() {
+        List<String> values = headers.get(HttpHeaders.CONTENT_LENGTH);
+        if (values == null || values.size() != 1) {
+            return -1;
+        }
+        try {
+            int len = Integer.valueOf(values.get(0));
+            return len >= 0 ? len : -1;
+        } catch (Exception ex) {
+            return -1;
+        }
+    }
     
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java Wed
Aug  8 10:28:29 2012
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -71,14 +72,27 @@ public class MetadataMap<K, V> implement
     }
     
     public void add(K key, V value) {
+        addValue(key, value, true);
+    }
+    
+    private void addValue(K key, V value, boolean last) {
+        List<V> data = getList(key);
+        if (last) {
+            data.add(value);
+        } else {
+            data.add(0, value);
+        }
+    }
+
+    private List<V> getList(K key) {
         List<V> data = this.get(key);
         if (data == null) {
             data = new ArrayList<V>();    
             m.put(key, data);
         }
-        data.add(value);
+        return data;
     }
-
+    
     public V getFirst(K key) {
         List<V> data = this.get(key);
         return data == null ? null : data.get(0);
@@ -195,4 +209,26 @@ public class MetadataMap<K, V> implement
         }
         
     }
+
+    public void addAll(K key, V... newValues) {
+        this.addAllValues(key, Arrays.asList(newValues));
+    }
+
+    public void addAll(K key, List<V> newValues) {
+        this.addAllValues(key, newValues);
+    }
+
+    private void addAllValues(K key, List<V> newValues) {
+        if (newValues == null) {
+            throw new NullPointerException("List is empty");
+        }
+        if (newValues.isEmpty()) {
+            return;
+        }
+        getList(key).addAll(newValues);
+    }
+    
+    public void addFirst(K key, V value) {
+        addValue(key, value, false);
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
Wed Aug  8 10:28:29 2012
@@ -19,15 +19,19 @@
 
 package org.apache.cxf.jaxrs.impl;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 import java.net.URI;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Set;
 
 import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Link;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.NewCookie;
@@ -251,4 +255,64 @@ public final class ResponseBuilderImpl e
         List<Object> values = metadata.get(key);
         return values == null ? false : values.contains(value.toString());
     }
+
+    @Override
+    public ResponseBuilder allow(String... arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder allow(Set<String> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder encoding(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder entity(Object arg0, Annotation[] arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder entity(Object arg0, Type arg1, Annotation[] arg2) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder link(URI arg0, String arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder link(String arg0, String arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder links(Link... arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder replaceAll(MultivaluedMap<String, Object> arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ResponseBuilder variants(Variant... arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
Wed Aug  8 10:28:29 2012
@@ -19,7 +19,21 @@
 
 package org.apache.cxf.jaxrs.impl;
 
+import java.lang.annotation.Annotation;
+import java.net.URI;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.MessageProcessingException;
+import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Link;
+import javax.ws.rs.core.Link.Builder;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
 
 public final class ResponseImpl extends Response {
@@ -49,5 +63,138 @@ public final class ResponseImpl extends 
         // don't worry about cloning for now
         return metadata;
     }
+
+    @Override
+    public boolean bufferEntity() throws MessageProcessingException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void close() throws MessageProcessingException {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public Set<String> getAllowedMethods() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Map<String, NewCookie> getCookies() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Date getDate() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public EntityTag getEntityTag() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public String getHeader(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Locale getLanguage() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Date getLastModified() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public int getLength() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public Link getLink(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Builder getLinkBuilder(String arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Set<Link> getLinks() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public URI getLocation() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public MediaType getMediaType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public StatusType getStatusInfo() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean hasEntity() {
+        return getEntity() != null;
+    }
+
+    @Override
+    public boolean hasLink(String arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public <T> T readEntity(Class<T> arg0) throws MessageProcessingException,
IllegalStateException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public <T> T readEntity(GenericType<T> arg0) throws MessageProcessingException,
IllegalStateException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public <T> T readEntity(Class<T> arg0, Annotation[] arg1) throws MessageProcessingException,
+        IllegalStateException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public <T> T readEntity(GenericType<T> arg0, Annotation[] arg1) throws MessageProcessingException,
+        IllegalStateException {
+        // TODO Auto-generated method stub
+        return null;
+    }
     
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
Wed Aug  8 10:28:29 2012
@@ -323,7 +323,7 @@ public class UriBuilderImpl extends UriB
     }
 
     @Override
-    public UriBuilder path(@SuppressWarnings("rawtypes") Class resource) throws IllegalArgumentException
{
+    public UriBuilder path(Class<?> resource) throws IllegalArgumentException {
         if (resource == null) {
             throw new IllegalArgumentException("resource is null");
         }
@@ -338,7 +338,7 @@ public class UriBuilderImpl extends UriB
     }
 
     @Override
-    public UriBuilder path(@SuppressWarnings("rawtypes") Class resource, String method) 
+    public UriBuilder path(Class<?> resource, String method) 
         throws IllegalArgumentException {
         if (resource == null) {
             throw new IllegalArgumentException("resource is null");
@@ -716,4 +716,13 @@ public class UriBuilderImpl extends UriB
         buildMatrix(sb, matrix, false);
         return new PathSegmentImpl(sb.toString());
     }
+
+
+    public UriBuilder uri(String uriTemplate) throws IllegalArgumentException {
+        try {
+            return uri(URI.create(uriTemplate));
+        } catch (Exception ex) {
+            throw new IllegalArgumentException(ex);
+        }
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
Wed Aug  8 10:28:29 2012
@@ -84,7 +84,7 @@ public class VariantListBuilderImpl exte
             handleLanguages(null);
         } else if (encodings.size() > 0) {
             for (String enc : encodings) {
-                variants.add(new Variant(null, null, enc));
+                variants.add(new Variant(null, (Locale)null, enc));
             }
         } 
     }
@@ -95,10 +95,10 @@ public class VariantListBuilderImpl exte
                 handleLanguages(type);
             } else if (encodings.size() > 0) {
                 for (String enc : encodings) {
-                    variants.add(new Variant(type, null, enc));
+                    variants.add(new Variant(type, (Locale)null, enc));
                 }
             } else {
-                variants.add(new Variant(type, null, null));
+                variants.add(new Variant(type, (Locale)null, null));
             }
         }
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalHttpHeaders.java
Wed Aug  8 10:28:29 2012
@@ -20,6 +20,7 @@
 
 package org.apache.cxf.jaxrs.impl.tl;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -60,4 +61,16 @@ public class ThreadLocalHttpHeaders exte
         return get().getRequestHeader(name);
     }
 
+    public Date getDate() {
+        return get().getDate();
+    }
+
+    public String getHeaderString(String name) {
+        return get().getHeaderString(name);
+    }
+
+    public int getLength() {
+        return get().getLength();
+    }
+
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
Wed Aug  8 10:28:29 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -30,6 +31,7 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -159,6 +161,63 @@ public class HttpHeadersImplTest extends
     }
     
     @Test
+    public void testGetMissingContentLegth() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, new MetadataMap<String, String>());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        assertEquals(-1, h.getLength());
+    }
+    
+    @Test
+    public void testGetContentLegth() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, createHeaders());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        assertEquals(10, h.getLength());
+    }
+    
+    @Test
+    public void testGetDate() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, createHeaders());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        
+        List<String> dateValues = h.getRequestHeader("Date");
+        assertEquals(1, dateValues.size());
+        assertEquals("Tue, 21 Oct 2008 17:00:00 GMT", dateValues.get(0));
+        
+        Date d = h.getDate();
+        
+        String theDateValue = HttpUtils.getHttpDateFormat().format(d);
+        assertEquals(theDateValue, "Tue, 21 Oct 2008 17:00:00 GMT");
+    }
+    
+    @Test
+    public void testGetHeaderString() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, createHeaders());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        
+        String date = h.getHeaderString("Date");
+        assertEquals("Tue, 21 Oct 2008 17:00:00 GMT", date);
+    }
+    
+    @Test
+    public void testGetHeaderString2() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, createHeaders());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        
+        String date = h.getHeaderString("a");
+        assertEquals("1,2", date);
+    }
+    
+    @Test
     public void testGetMediaTypes() throws Exception {
         
         Message m = control.createMock(Message.class);
@@ -307,6 +366,11 @@ public class HttpHeadersImplTest extends
         hs.putSingle("Accept", "text/bar;q=0.6,text/*;q=1,application/xml");
         hs.putSingle("Content-Type", "*/*");
         hs.putSingle("Date", "Tue, 21 Oct 2008 17:00:00 GMT");
+        hs.putSingle("Content-Length", "10");
+        List<String> values = new ArrayList<String>();
+        values.add("1");
+        values.add("2");
+        hs.addAll("a", values);
         return hs;
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
Wed Aug  8 10:28:29 2012
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.junit.Assert;
@@ -45,6 +46,38 @@ public class MetadataMapTest extends Ass
     }
     
     @Test
+    public void testAddFirst() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.addFirst("baz", "foo");
+        List<Object> values = m.get("baz");
+        assertEquals(1, values.size());
+        assertEquals("foo", values.get(0));
+        
+        m.addFirst("baz", "clazz");
+        values = m.get("baz");
+        assertEquals(2, values.size());
+        assertEquals("clazz", values.get(0));
+        assertEquals("foo", values.get(1));
+    }
+    
+    @Test
+    public void testAddAll() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        List<Object> values = new ArrayList<Object>();
+        values.add("foo");
+        m.addAll("baz", values);
+        values = m.get("baz");
+        assertEquals(1, values.size());
+        assertEquals("foo", values.get(0));
+        
+        m.addAll("baz", Collections.<Object>singletonList("foo2"));
+        values = m.get("baz");
+        assertEquals(2, values.size());
+        assertEquals("foo", values.get(0));
+        assertEquals("foo2", values.get(1));
+    }
+    
+    @Test
     public void testPutSingleCaseInsensitive() {
         MetadataMap<String, Object> m = new MetadataMap<String, Object>(false,
true);
         List<Object> value1 = new ArrayList<Object>();

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
Wed Aug  8 10:28:29 2012
@@ -287,7 +287,7 @@ public class UriBuilderImplTest extends 
     
     @Test(expected = IllegalArgumentException.class)
     public void testUriNull() throws Exception {
-        new UriBuilderImpl().uri(null);
+        new UriBuilderImpl().uri((URI)null);
     }
 
     @Test

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java?rev=1370731&r1=1370730&r2=1370731&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
Wed Aug  8 10:28:29 2012
@@ -56,10 +56,10 @@ public class VariantListBuilderImplTest 
         List<Variant> variants = 
             vb.mediaTypes(mt1, mt2).encodings("zip", "identity").add().build();
         assertEquals("4 variants need to be created", 4, variants.size());
-        assertTrue(verifyVariant(variants, new Variant(mt1, null, "zip")));
-        assertTrue(verifyVariant(variants, new Variant(mt1, null, "identity")));
-        assertTrue(verifyVariant(variants, new Variant(mt2, null, "zip")));
-        assertTrue(verifyVariant(variants, new Variant(mt2, null, "identity")));
+        assertTrue(verifyVariant(variants, new Variant(mt1, (Locale)null, "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt1, (Locale)null, "identity")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, (Locale)null, "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, (Locale)null, "identity")));
     }
     
     @Test
@@ -104,8 +104,8 @@ public class VariantListBuilderImplTest 
         List<Variant> variants = 
             vb.encodings("zip", "identity").add().build();
         assertEquals("2 variants need to be created", 2, variants.size());
-        assertTrue(verifyVariant(variants, new Variant(null, null, "zip")));
-        assertTrue(verifyVariant(variants, new Variant(null, null, "identity")));
+        assertTrue(verifyVariant(variants, new Variant(null, (Locale)null, "zip")));
+        assertTrue(verifyVariant(variants, new Variant(null, (Locale)null, "identity")));
     }
     
     @Test
@@ -114,8 +114,8 @@ public class VariantListBuilderImplTest 
         List<Variant> variants = 
             vb.mediaTypes(new MediaType("*", "*"), new MediaType("text", "xml")).add().build();
         assertEquals("2 variants need to be created", 2, variants.size());
-        assertTrue(verifyVariant(variants, new Variant(new MediaType("*", "*"), null, null)));
-        assertTrue(verifyVariant(variants, new Variant(new MediaType("text", "xml"), null,
null)));
+        assertTrue(verifyVariant(variants, new Variant(new MediaType("*", "*"), (Locale)null,
null)));
+        assertTrue(verifyVariant(variants, new Variant(new MediaType("text", "xml"), (Locale)null,
null)));
     }
 
     private boolean verifyVariant(List<Variant> vs, Variant var) {



Mime
View raw message