cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r962689 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/ja...
Date Fri, 09 Jul 2010 20:42:25 GMT
Author: sergeyb
Date: Fri Jul  9 20:42:23 2010
New Revision: 962689

URL: http://svn.apache.org/viewvc?rev=962689&view=rev
Log:
Merged revisions 959789 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r959789 | sergeyb | 2010-07-01 22:34:33 +0100 (Thu, 01 Jul 2010) | 1 line
  
  Addressing various jaxrs frontend issues reported during the last couple of months
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlElement.java
      - copied unchanged from r959789, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlElement.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul  9 20:42:23 2010
@@ -1 +1 @@
-/cxf/trunk:960506,961051,961818
+/cxf/trunk:959789,960506,961051,961818

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java Fri Jul  9 20:42:23 2010
@@ -68,6 +68,9 @@ public class MessageContextImpl implemen
             || (MultipartBody.INBOUND_MESSAGE_ATTACHMENTS + ".embedded").equals(keyValue)) {
             return createAttachments(key.toString());
         }
+        if (keyValue.equals("WRITE-" + Message.ATTACHMENTS)) {
+            return m.getExchange().getOutMessage().get(Message.ATTACHMENTS);
+        }
         Object value = m.get(key);
         if (value == null && isRequestor()) {
             Message inMessage = m.getExchange().getInMessage();
@@ -150,6 +153,10 @@ public class MessageContextImpl implemen
             convertToAttachments(value);
         }
         m.put(key.toString(), value);
+        if (!isRequestor()) {
+            m.getExchange().put(key.toString(), value);
+        }
+            
     }
 
     private void convertToAttachments(Object value) {
@@ -161,7 +168,7 @@ public class MessageContextImpl implemen
             Attachment handler = (Attachment)handlers.get(i);
             AttachmentImpl att = new AttachmentImpl(handler.getContentId(), handler.getDataHandler());
             for (String key : handler.getHeaders().keySet()) {
-                att.setHeader(key, att.getHeader(key));
+                att.setHeader(key, handler.getHeader(key));
             }
             att.setXOP(false);
             atts.add(att);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java Fri Jul  9 20:42:23 2010
@@ -24,12 +24,17 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
 public class MediaTypeHeaderProvider implements HeaderDelegate<MediaType> {
 
+    private static final Pattern COMPLEX_PARAMETERS = 
+        Pattern.compile("(([\\w-]+=\"[^\"]*\")|([\\w-]+=[\\w-]+))");
+    
     public MediaType fromString(String mType) {
         
         if (mType == null) {
@@ -53,21 +58,22 @@ public class MediaTypeHeaderProvider imp
         
         Map<String, String> parameters = Collections.emptyMap();
         if (paramsStart != -1) {
-            // Using Pattern.compile might be marginally faster ?
-            // though it's rare when more than one parameter is provided
+
             parameters = new LinkedHashMap<String, String>();
-            StringTokenizer st = 
-                new StringTokenizer(mType.substring(paramsStart + 1), ";");
-            while (st.hasMoreTokens()) {
-                String token = st.nextToken();
-                int equalSign = token.indexOf('=');
-                if (equalSign == -1) {
-                    throw new IllegalArgumentException("Wrong media type  parameter, seperator is missing");
+            
+            String paramString = mType.substring(paramsStart + 1);
+            if (paramString.contains("\"")) {
+                Matcher m = COMPLEX_PARAMETERS.matcher(paramString);
+                while (m.find()) {
+                    String val = m.group().trim();
+                    addParameter(parameters, val);
+                }
+            } else {
+                StringTokenizer st = new StringTokenizer(paramString, ";");
+                while (st.hasMoreTokens()) {
+                    addParameter(parameters, st.nextToken());
                 }
-                parameters.put(token.substring(0, equalSign).trim().toLowerCase(), 
-                               token.substring(equalSign + 1).trim());
             }
-            
         }
         
         return new MediaType(type.trim().toLowerCase(), 
@@ -75,6 +81,15 @@ public class MediaTypeHeaderProvider imp
                              parameters);
     }
 
+    private static void addParameter(Map<String, String> parameters, String token) {
+        int equalSign = token.indexOf('=');
+        if (equalSign == -1) {
+            throw new IllegalArgumentException("Wrong media type  parameter, seperator is missing");
+        }
+        parameters.put(token.substring(0, equalSign).trim().toLowerCase(), 
+                       token.substring(equalSign + 1).trim());
+    }
+    
     public String toString(MediaType type) {
         StringBuilder sb = new StringBuilder();
         sb.append(type.getType()).append('/').append(type.getSubtype());

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Fri Jul  9 20:42:23 2010
@@ -374,12 +374,13 @@ public class JAXRSOutInterceptor extends
         
         Object contentType = 
             response.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE);
+        if (contentType != null) {
+            return Collections.singletonList(MediaType.valueOf(contentType.toString()));
+        }
         Exchange exchange = message.getExchange();
         List<MediaType> produceTypes = null;
         OperationResourceInfo operation = exchange.get(OperationResourceInfo.class);
-        if (contentType != null) {
-            return Collections.singletonList(MediaType.valueOf(contentType.toString()));
-        } else if (operation != null) {
+        if (operation != null) {
             produceTypes = operation.getProduceTypes();
         } else {
             produceTypes = Collections.singletonList(MediaType.APPLICATION_OCTET_STREAM_TYPE);
@@ -389,7 +390,7 @@ public class JAXRSOutInterceptor extends
         if (acceptContentTypes == null) {
             acceptContentTypes = Collections.singletonList(MediaType.WILDCARD_TYPE);
         }        
-        return JAXRSUtils.intersectMimeTypes(acceptContentTypes, produceTypes);
+        return JAXRSUtils.intersectMimeTypes(acceptContentTypes, produceTypes, true);
         
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java Fri Jul  9 20:42:23 2010
@@ -439,97 +439,100 @@ public final class URITemplate {
             }
         }
     }
-}
+    
+    /**
+     * Splits string into parts inside and outside curly braces. Nested curly braces are ignored and treated
+     * as part inside top-level curly braces. Example: string "foo{bar{baz}}blah" is split into three tokens,
+     * "foo","{bar{baz}}" and "blah". When closed bracket is missing, whole unclosed part is returned as one
+     * token, e.g.: "foo{bar" is split into "foo" and "{bar". When opening bracket is missing, closing
+     * bracket is ignored and taken as part of current token e.g.: "foo{bar}baz}blah" is split into "foo",
+     * "{bar}" and "baz}blah".
+     * <p>
+     * This is helper class for {@link URITemplate} that enables recurring literals appearing next to regular
+     * expressions e.g. "/foo/{zipcode:[0-9]{5}}/". Nested expressions with closed sections, like open-closed
+     * brackets causes expression to be out of regular grammar (is context-free grammar) which are not
+     * supported by Java regexp version.
+     * 
+     * @author amichalec
+     * @version $Rev$
+     */
+    static class CurlyBraceTokenizer {
+
+        private List<String> tokens = new ArrayList<String>();
+        private int tokenIdx;
 
-/**
- * Splits string into parts inside and outside curly braces. Nested curly braces are ignored and treated as
- * part inside top-level curly braces. Example: string "foo{bar{baz}}blah" is split into three tokens, "foo",
- * "{bar{baz}}" and "blah". When closed bracket is missing, whole unclosed part is returned as one token,
- * e.g.: "foo{bar" is split into "foo" and "{bar". When opening bracket is missing, closing bracked is ignored
- * and taken as part of current token e.g.: "foo{bar}baz}blah" is split into "foo", "{bar}" and "baz}blah".
- * <p>
- * This is helper class for {@link URITemplate} that enables recurring literals appearing next to regular
- * expressions e.g. "/foo/{zipcode:[0-9]{5}}/". Nested expressions with closed sections, like open-closed
- * brackets causes expression to be out of regular grammar (is context-free grammar) which are not supported
- * by Java regexp version.
- * 
- * @author amichalec
- * @version $Rev$
- */
-final class CurlyBraceTokenizer {
-
-    private List<String> tokens = new ArrayList<String>();
-    private int tokenIdx;
-
-    public CurlyBraceTokenizer(String string) {
-        boolean outside = true;
-        int level = 0;
-        int lastIdx = 0;
-        int idx;
-        for (idx = 0; idx < string.length(); idx++) {
-            if (string.charAt(idx) == '{') {
-                if (outside) {
-                    if (lastIdx < idx) {
-                        tokens.add(string.substring(lastIdx, idx));
+        public CurlyBraceTokenizer(String string) {
+            boolean outside = true;
+            int level = 0;
+            int lastIdx = 0;
+            int idx;
+            for (idx = 0; idx < string.length(); idx++) {
+                if (string.charAt(idx) == '{') {
+                    if (outside) {
+                        if (lastIdx < idx) {
+                            tokens.add(string.substring(lastIdx, idx));
+                        }
+                        lastIdx = idx;
+                        outside = false;
+                    } else {
+                        level++;
                     }
-                    lastIdx = idx;
-                    outside = false;
-                } else {
-                    level++;
-                }
-            } else if (string.charAt(idx) == '}' && !outside) {
-                if (level > 0) {
-                    level--;
-                } else {
-                    if (lastIdx < idx) {
-                        tokens.add(string.substring(lastIdx, idx + 1));
+                } else if (string.charAt(idx) == '}' && !outside) {
+                    if (level > 0) {
+                        level--;
+                    } else {
+                        if (lastIdx < idx) {
+                            tokens.add(string.substring(lastIdx, idx + 1));
+                        }
+                        lastIdx = idx + 1;
+                        outside = true;
                     }
-                    lastIdx = idx + 1;
-                    outside = true;
                 }
             }
+            if (lastIdx < idx) {
+                tokens.add(string.substring(lastIdx, idx));
+            }
         }
-        if (lastIdx < idx) {
-            tokens.add(string.substring(lastIdx, idx));
-        }
-    }
 
-    /**
-     * Token is enclosed by curly braces.
-     * 
-     * @param token
-     *            text to verify
-     * @return true if enclosed, false otherwise.
-     */
-    public static boolean insideBraces(String token) {
-        return token.charAt(0) == '{' && token.charAt(token.length() - 1) == '}';
-    }
+        /**
+         * Token is enclosed by curly braces.
+         * 
+         * @param token
+         *            text to verify
+         * @return true if enclosed, false otherwise.
+         */
+        public static boolean insideBraces(String token) {
+            return token.charAt(0) == '{' && token.charAt(token.length() - 1) == '}';
+        }
 
-    /**
-     * Strips token from enclosed curly braces. If token is not enclosed method
-     * has no side effect.
-     * 
-     * @param token
-     *            text to verify
-     * @return text stripped from curly brace begin-end pair.
-     */
-    public static String stripBraces(String token) {
-        if (insideBraces(token)) {
-            return token.substring(1, token.length() - 1);
-        } else {
-            return token;
+        /**
+         * Strips token from enclosed curly braces. If token is not enclosed method
+         * has no side effect.
+         * 
+         * @param token
+         *            text to verify
+         * @return text stripped from curly brace begin-end pair.
+         */
+        public static String stripBraces(String token) {
+            if (insideBraces(token)) {
+                return token.substring(1, token.length() - 1);
+            } else {
+                return token;
+            }
         }
-    }
 
-    public boolean hasNext() {
-        return tokens.size() > tokenIdx;
-    }
+        public boolean hasNext() {
+            return tokens.size() > tokenIdx;
+        }
 
-    public String next() {
-        if (hasNext()) {
-            return tokens.get(tokenIdx++);
-        } else {
-            throw new IllegalStateException("no more elements");
+        public String next() {
+            if (hasNext()) {
+                return tokens.get(tokenIdx++);
+            } else {
+                throw new IllegalStateException("no more elements");
+            }
         }
     }
 }
+
+

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Fri Jul  9 20:42:23 2010
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -495,6 +496,8 @@ public class WadlGenerator implements Re
                 }
                 sb.append("<representation");
                 sb.append(" mediaType=\"").append(mt.toString()).append("\"");
+                
+                type = getActualJaxbType(type, ori.getAnnotatedMethod(), inbound);
                 if (qnameResolver != null && mt.getSubtype().contains("xml") && jaxbTypes.contains(type)) {
                     generateQName(sb, qnameResolver, clsMap, type,
                                   getBodyAnnotations(ori, inbound));
@@ -511,6 +514,11 @@ public class WadlGenerator implements Re
         }
     }
     
+    protected Class<?> getActualJaxbType(Class<?> type, Method resourceMethod, boolean inbound) {
+        WadlElement element = resourceMethod.getAnnotation(WadlElement.class);
+        return element == null ? type : inbound ? element.request() : element.response();
+    }
+    
     protected List<OperationResourceInfo> sortOperationsByPath(Set<OperationResourceInfo> ops) {
         List<OperationResourceInfo> opsWithSamePath = new LinkedList<OperationResourceInfo>(ops);
         Collections.sort(opsWithSamePath, new Comparator<OperationResourceInfo>() {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Fri Jul  9 20:42:23 2010
@@ -382,16 +382,11 @@ public abstract class AbstractJAXBProvid
             || JAXBElement.class.isAssignableFrom(type)
             || objectFactoryForClass(type)
             || (type != genericType && objectFactoryForType(genericType))
-            || adapterAvailable(type, anns)
+            || getAdapter(type, anns) != null
             || type.getResource("jaxb.index") != null;
     
     }
     
-    protected boolean adapterAvailable(Class<?> type, Annotation[] anns) {
-        return AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class) != null
-               || type.getAnnotation(XmlJavaTypeAdapter.class) != null;
-    }
-    
     protected boolean objectFactoryForClass(Class<?> type) {
         try {
             return type.getClassLoader().loadClass(PackageUtils.getPackageName(type) 
@@ -464,7 +459,7 @@ public abstract class AbstractJAXBProvid
     }
     
     @SuppressWarnings("unchecked")
-    protected Object checkAdapter(Object obj, Annotation[] anns, boolean marshal) {
+    protected Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns, boolean marshal) {
         XmlJavaTypeAdapter typeAdapter = getAdapter(obj.getClass(), anns); 
         if (typeAdapter != null) {
             try {
@@ -482,10 +477,16 @@ public abstract class AbstractJAXBProvid
         return obj;
     }
     
-    protected XmlJavaTypeAdapter getAdapter(Class<?> type, Annotation[] anns) {
+    protected XmlJavaTypeAdapter getAdapter(Class<?> objectClass, Annotation[] anns) {
         XmlJavaTypeAdapter typeAdapter = AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class);
         if (typeAdapter == null) {
-            typeAdapter = type.getAnnotation(XmlJavaTypeAdapter.class);
+            typeAdapter = objectClass.getAnnotation(XmlJavaTypeAdapter.class);
+            if (typeAdapter == null) {
+                // lets just try the 1st interface for now
+                Class<?>[] interfaces = objectClass.getInterfaces();
+                typeAdapter = interfaces.length > 0 
+                    ? interfaces[0].getAnnotation(XmlJavaTypeAdapter.class) : null;
+            }
         }
         return typeAdapter;
     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java Fri Jul  9 20:42:23 2010
@@ -128,7 +128,7 @@ public class FormEncodingProvider implem
             FormUtils.populateMapFromMultipart(params, body, decode);
         } else {
             FormUtils.populateMapFromString(params, 
-                                            FormUtils.readBody(is), 
+                                            FormUtils.readBody(is, mt), 
                                             decode,
                                             mc != null ? mc.getHttpServletRequest() : null);
         }
@@ -179,14 +179,17 @@ public class FormEncodingProvider implem
         } else {
             MultivaluedMap<String, String> map = (MultivaluedMap<String, String>)obj;
             boolean encoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
+            
+            String encoding = HttpUtils.getSetEncoding(mt, headers, "UTF-8");
+            
             for (Iterator<Map.Entry<String, List<String>>> it = map.entrySet().iterator(); it.hasNext();) {
                 Map.Entry<String, List<String>> entry = it.next();
                 for (Iterator<String> entryIterator = entry.getValue().iterator(); entryIterator.hasNext();) {
                     String value = entryIterator.next();
-                    os.write(entry.getKey().getBytes("UTF-8"));
+                    os.write(entry.getKey().getBytes(encoding));
                     os.write('=');
                     String data = encoded ? value : HttpUtils.urlEncode(value);
-                    os.write(data.getBytes("UTF-8"));
+                    os.write(data.getBytes(encoding));
                     if (entryIterator.hasNext() || it.hasNext()) {
                         os.write('&');
                     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Fri Jul  9 20:42:23 2010
@@ -168,7 +168,7 @@ public class JAXBElementProvider extends
                 response = ((CollectionWrapper)response).getCollectionOrArray(theType, type); 
             }
             
-            response = checkAdapter(response, anns, false);
+            response = checkAdapter(response, type, anns, false);
             return response;
             
         } catch (JAXBException e) {
@@ -229,7 +229,7 @@ public class JAXBElementProvider extends
         MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) 
         throws IOException {
         try {
-            Object actualObject = checkAdapter(obj, anns, true);
+            Object actualObject = checkAdapter(obj, cls, anns, true);
             Class<?> actualClass = obj != actualObject ? actualObject.getClass() : cls;
             String encoding = HttpUtils.getSetEncoding(m, headers, null);
             if (InjectionUtils.isSupportedCollectionOrArray(actualClass)) {
@@ -319,7 +319,7 @@ public class JAXBElementProvider extends
     }
     
     protected void addAttachmentMarshaller(Marshaller ms) {
-        Collection<Attachment> attachments = getAttachments();
+        Collection<Attachment> attachments = getAttachments(true);
         if (attachments != null) {
             Object value = getContext().getContextualProperty(Message.MTOM_THRESHOLD);
             Integer threshold = value != null ? Integer.valueOf(value.toString()) : 0;
@@ -329,17 +329,19 @@ public class JAXBElementProvider extends
     }
     
     protected void addAttachmentUnmarshaller(Unmarshaller um) {
-        Collection<Attachment> attachments = getAttachments();
+        Collection<Attachment> attachments = getAttachments(false);
         if (attachments != null) {
             um.setAttachmentUnmarshaller(new JAXBAttachmentUnmarshaller(
                 attachments));
         }
     }
     
-    private Collection<Attachment> getAttachments() {
+    private Collection<Attachment> getAttachments(boolean write) {
         MessageContext mc = getContext();
         if (mc != null) {
-            return CastUtils.cast((Collection<?>)mc.get(Message.ATTACHMENTS));
+            // TODO: there has to be a better fix
+            String propertyName = write ? "WRITE-" + Message.ATTACHMENTS : Message.ATTACHMENTS;
+            return CastUtils.cast((Collection<?>)mc.get(propertyName));
         } else {
             return null;
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java Fri Jul  9 20:42:23 2010
@@ -172,7 +172,7 @@ public class JSONProvider extends Abstra
             if (response instanceof JAXBElement && !JAXBElement.class.isAssignableFrom(type)) {
                 response = ((JAXBElement)response).getValue();    
             }
-            response = checkAdapter(response, anns, false);
+            response = checkAdapter(response, type, anns, false);
             return response;
             
         } catch (JAXBException e) {
@@ -254,7 +254,7 @@ public class JSONProvider extends Abstra
         throws IOException {
         try {
             
-            Object actualObject = checkAdapter(obj, anns, true);
+            Object actualObject = checkAdapter(obj, cls, anns, true);
             Class<?> actualClass = obj != actualObject ? actualObject.getClass() : cls;
             if (cls == genericType) {
                 genericType = actualClass;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Fri Jul  9 20:42:23 2010
@@ -448,7 +448,7 @@ public final class ProviderFactory {
         List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderConsumeTypes(ep);
         
         List<MediaType> availableMimeTypes = 
-            JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType), supportedMediaTypes);
+            JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType), supportedMediaTypes, false);
 
         if (availableMimeTypes.size() == 0) {
             return false;
@@ -501,7 +501,7 @@ public final class ProviderFactory {
         
         List<MediaType> availableMimeTypes = 
             JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
-                                          supportedMediaTypes);
+                                          supportedMediaTypes, false);
 
         if (availableMimeTypes.size() == 0) {
             return false;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java Fri Jul  9 20:42:23 2010
@@ -90,7 +90,7 @@ public class XMLBeansJSONProvider extend
             Map<String, String> nstojns = new HashMap<String, String>();
             XMLOutputFactory factory = new MappedXMLOutputFactory(nstojns);
             XMLStreamWriter xsw = factory.createXMLStreamWriter(os);
-
+            xsw.writeStartDocument();
             if (obj instanceof XmlObject) {
 
                 XmlObject xObj = (XmlObject)obj;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java Fri Jul  9 20:42:23 2010
@@ -69,7 +69,7 @@ public class CXFNonSpringJaxrsServlet ex
         
         String applicationClass = servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
         if (applicationClass != null) {
-            createServerFromApplication(applicationClass);
+            createServerFromApplication(applicationClass, servletConfig);
             return;
         }
         
@@ -253,7 +253,8 @@ public class CXFNonSpringJaxrsServlet ex
         
     }
     
-    protected void createServerFromApplication(String cName) throws ServletException {
+    protected void createServerFromApplication(String cName, ServletConfig servletConfig) 
+        throws ServletException {
         Class<?> appClass = loadClass(cName, "Application");
         Application app = null;
         try {
@@ -301,6 +302,10 @@ public class CXFNonSpringJaxrsServlet ex
         for (Map.Entry<Class, ResourceProvider> entry : map.entrySet()) {
             bean.setResourceProvider(entry.getKey(), entry.getValue());
         }
+        setSchemasLocations(bean, servletConfig);
+        setInterceptors(bean, servletConfig, OUT_INTERCEPTORS_PARAM);
+        setInterceptors(bean, servletConfig, IN_INTERCEPTORS_PARAM);
+        
         bean.create();
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java Fri Jul  9 20:42:23 2010
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.common.util.StringUtils;
@@ -59,16 +60,21 @@ public final class FormUtils {
         }
     }
     
-    public static String readBody(InputStream is) {
+    public static String readBody(InputStream is, MediaType mt) {
         try {
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             IOUtils.copy(is, bos, 1024);
-            return new String(bos.toByteArray(), "UTF-8");
+            return new String(bos.toByteArray(), getCharset(mt));
         } catch (Exception ex) {
             throw new WebApplicationException(ex);
         }
     }
     
+    private static String getCharset(MediaType mt) {
+        String charset = mt.getParameters().get("charset");
+        return charset == null ? "UTF-8" : charset;
+    }
+    
     public static void populateMapFromString(MultivaluedMap<String, String> params, 
                                              String postBody, boolean decode,
                                              HttpServletRequest request) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Fri Jul  9 20:42:23 2010
@@ -816,7 +816,13 @@ public final class InjectionUtils {
         for (Method m : bean.getClass().getMethods()) {
             if (m.getName().startsWith("get") && m.getParameterTypes().length == 0 
                 && m.getName().length() > 3) {
-                String propertyName = m.getName().substring(3).toLowerCase();
+                String propertyName = m.getName().substring(3);
+                if (propertyName.length() == 1) {
+                    propertyName = propertyName.toLowerCase();
+                } else {
+                    propertyName = propertyName.substring(0, 1).toLowerCase()
+                                   + propertyName.substring(1);
+                }
                 if (baseName.contains(propertyName) || "class".equals(propertyName)) {
                     continue;
                 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri Jul  9 20:42:23 2010
@@ -679,7 +679,7 @@ public final class JAXRSUtils {
             if (mt == null || mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
                 String body = (String)m.get("org.apache.cxf.jaxrs.provider.form.body");
                 if (body == null) {
-                    body = FormUtils.readBody(m.getContent(InputStream.class));
+                    body = FormUtils.readBody(m.getContent(InputStream.class), mt);
                     m.put("org.apache.cxf.jaxrs.provider.form.body", body);
                 }
                 HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
@@ -1035,7 +1035,8 @@ public final class JAXRSUtils {
      * @return return a list of intersected mime types
      */   
     public static List<MediaType> intersectMimeTypes(List<MediaType> requiredMediaTypes, 
-                                                     List<MediaType> userMediaTypes) {
+                                                     List<MediaType> userMediaTypes,
+                                                     boolean addRequiredParamsIfPossible) {
         Set<MediaType> supportedMimeTypeList = new LinkedHashSet<MediaType>();
 
         for (MediaType requiredType : requiredMediaTypes) {
@@ -1068,8 +1069,17 @@ public final class JAXRSUtils {
                     String type = requiredType.getType().equals(MediaType.MEDIA_TYPE_WILDCARD) 
                                       ? userType.getType() : requiredType.getType();
                     String subtype = requiredType.getSubtype().equals(MediaType.MEDIA_TYPE_WILDCARD) 
-                                      ? userType.getSubtype() : requiredType.getSubtype();                  
-                    supportedMimeTypeList.add(new MediaType(type, subtype, userType.getParameters()));
+                                      ? userType.getSubtype() : requiredType.getSubtype();
+                    Map<String, String> parameters = userType.getParameters();
+                    if (addRequiredParamsIfPossible) {
+                        parameters = new LinkedHashMap<String, String>(parameters);
+                        for (Map.Entry<String, String> entry : requiredType.getParameters().entrySet()) {
+                            if (!parameters.containsKey(entry.getKey())) {
+                                parameters.put(entry.getKey(), entry.getValue());
+                            }
+                        }
+                    }
+                    supportedMimeTypeList.add(new MediaType(type, subtype, parameters));
                 }
             }
         }
@@ -1081,13 +1091,14 @@ public final class JAXRSUtils {
     public static List<MediaType> intersectMimeTypes(List<MediaType> mimeTypesA, 
                                                      MediaType mimeTypeB) {
         return intersectMimeTypes(mimeTypesA, 
-                                  Collections.singletonList(mimeTypeB));
+                                  Collections.singletonList(mimeTypeB), false);
     }
     
     public static List<MediaType> intersectMimeTypes(String mimeTypesA, 
                                                      String mimeTypesB) {
         return intersectMimeTypes(parseMediaTypes(mimeTypesA),
-                                  parseMediaTypes(mimeTypesB));
+                                  parseMediaTypes(mimeTypesB),
+                                  false);
     }
     
     public static List<MediaType> sortMediaTypes(String mediaTypes) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java Fri Jul  9 20:42:23 2010
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.jaxrs.impl;
 
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -81,15 +80,14 @@ public class MediaTypeHeaderProviderTest
     
     @Test
     public void testTypeWithParameters() {
-        MediaType m = MediaType.valueOf("text/html;q=1234;b=4321");
+        MediaType mt = MediaType.valueOf("text/html;q=1234;b=4321");
         
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("q", "1234");
-        params.put("b", "4321");
-        
-        MediaType expected = new MediaType("text", "html", params);
-        
-        assertEquals("Media type was not parsed correctly", expected, m);
+        assertEquals("text", mt.getType());
+        assertEquals("html", mt.getSubtype());
+        Map<String, String> params2 = mt.getParameters();
+        assertEquals(2, params2.size());
+        assertEquals("1234", params2.get("q"));
+        assertEquals("4321", params2.get("b"));
     }
     
     @Test
@@ -102,6 +100,23 @@ public class MediaTypeHeaderProviderTest
     }
     
     @Test
+    public void testHeaderFileName() {
+
+        String fileName = "version_2006&#65288;3&#65289;.pdf";
+        String header = "application/octet-stream; name=\"%s\"";
+        String value = String.format(header, fileName);
+        
+        MediaTypeHeaderProvider provider = new MediaTypeHeaderProvider();
+        MediaType mt = provider.fromString(value);
+        assertEquals("application", mt.getType());
+        assertEquals("octet-stream", mt.getSubtype());
+        Map<String, String> params = mt.getParameters();
+        assertEquals(1, params.size());
+        assertEquals("\"version_2006&#65288;3&#65289;.pdf\"", params.get("name"));
+        
+    }
+    
+    @Test
     public void testComplexToString() {
         MediaTypeHeaderProvider provider = 
             new MediaTypeHeaderProvider();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java Fri Jul  9 20:42:23 2010
@@ -26,6 +26,8 @@ import java.util.Map;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.model.URITemplate.CurlyBraceTokenizer;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java Fri Jul  9 20:42:23 2010
@@ -31,6 +31,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.cxf.aegis.type.java5.IgnoreProperty;
@@ -102,6 +103,13 @@ public class BookStore {
         return new Chapter(1);
     }
     
+    @GET
+    @Path("chapter2")
+    @WadlElement(response = Chapter.class)
+    public Response getChaper2() {
+        return Response.ok().entity(new Chapter(1)).build();
+    }
+    
     @Path("form")
     public FormInterface getForm() {
         return new Book(1);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java Fri Jul  9 20:42:23 2010
@@ -329,14 +329,15 @@ public class WadlGeneratorTest extends A
         
         List<Element> resourceEls = DOMUtils.getChildrenWithName(resource, 
                                          WadlGenerator.WADL_NS, "resource");
-        assertEquals(7, resourceEls.size());        
+        assertEquals(8, resourceEls.size());        
         assertEquals("/book2", resourceEls.get(0).getAttribute("path"));
         assertEquals("/books/{bookid}", resourceEls.get(1).getAttribute("path"));
         assertEquals("/chapter", resourceEls.get(2).getAttribute("path"));
-        assertEquals("/books/{bookid}", resourceEls.get(3).getAttribute("path"));
-        assertEquals("/booksubresource", resourceEls.get(4).getAttribute("path"));
-        assertEquals("/form", resourceEls.get(5).getAttribute("path"));
-        assertEquals("/itself", resourceEls.get(6).getAttribute("path"));
+        assertEquals("/chapter2", resourceEls.get(3).getAttribute("path"));
+        assertEquals("/books/{bookid}", resourceEls.get(4).getAttribute("path"));
+        assertEquals("/booksubresource", resourceEls.get(5).getAttribute("path"));
+        assertEquals("/form", resourceEls.get(6).getAttribute("path"));
+        assertEquals("/itself", resourceEls.get(7).getAttribute("path"));
         
         // verify root resource starting with "/"
         // must have a single template parameter
@@ -419,17 +420,19 @@ public class WadlGeneratorTest extends A
         
         // verify resource starting with /chapter
         verifyGetResourceMethod(resourceEls.get(2), chapterEl);
+     // verify resource starting with /chapter2
+        verifyGetResourceMethod(resourceEls.get(3), chapterEl);
         
         // verify resource starting from /booksubresource
         // should have 2 parameters
-        paramsEls = DOMUtils.getChildrenWithName(resourceEls.get(4), 
+        paramsEls = DOMUtils.getChildrenWithName(resourceEls.get(5), 
                          WadlGenerator.WADL_NS, "param");
         assertEquals(2, paramsEls.size());
         checkParameter(paramsEls.get(0), "id", "template", "xs:int");
         checkParameter(paramsEls.get(1), "mid", "matrix", "xs:int");
         
         // should have 4 child resources
-        List<Element> subResourceEls = DOMUtils.getChildrenWithName(resourceEls.get(4), 
+        List<Element> subResourceEls = DOMUtils.getChildrenWithName(resourceEls.get(5), 
                                          WadlGenerator.WADL_NS, "resource");
         assertEquals(4, subResourceEls.size());        
         assertEquals("/book", subResourceEls.get(0).getAttribute("path"));

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java Fri Jul  9 20:42:23 2010
@@ -204,6 +204,29 @@ public class FormEncodingProviderTest ex
         assertEquals("Wrong entry for boo", "far", mvMap.getFirst("boo"));
 
     }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testReadFromISO() throws Exception {
+        
+        String eWithAcute = "\u00E9";
+        String helloStringUTF16 = "name=F" + eWithAcute + "lix";
+        
+        byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
+        String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+        
+        System.out.println(helloStringISO88591);
+        
+        MultivaluedMap<String, String> mvMap = 
+            (MultivaluedMap<String, String>)ferp.readFrom((Class)MultivaluedMap.class, null,
+                new Annotation[]{}, 
+                MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED + ";charset=ISO-8859-1"), null, 
+                new ByteArrayInputStream(iso88591bytes));
+        String value = mvMap.getFirst("name");
+
+        System.out.println(value);
+
+    }
 
     @Test
     public void testReadable() {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Fri Jul  9 20:42:23 2010
@@ -383,7 +383,7 @@ public class JAXRSUtilsTest extends Asse
         List<MediaType> providerMimeTypes = 
             JAXRSUtils.parseMediaTypes("application/mytype, application/xml, application/json");
 
-        candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes);
+        candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes, false);
 
         assertEquals(3, candidateList.size());
         for (MediaType type : candidateList) {
@@ -779,11 +779,15 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testFormBean", argType);
         MessageImpl messageImpl = new MessageImpl();
         messageImpl.put(Message.REQUEST_URI, "/bar");
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        headers.putSingle("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
+        messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         String body = "a=aValue&b=123";
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
 
         MessageImpl complexMessageImpl = new MessageImpl();
         complexMessageImpl.put(Message.REQUEST_URI, "/bar");
+        complexMessageImpl.put(Message.PROTOCOL_HEADERS, headers);
         body = "c=1&a=A&b=123&c=2&c=3&"
                                 + "d.c=4&d.a=B&d.b=456&d.c=5&d.c=6&"
                                 + "e.c=41&e.a=B1&e.b=457&e.c=51&e.c=61&"
@@ -961,6 +965,9 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         String body = "p1=1&p2=2&p2=3";
         messageImpl.put(Message.REQUEST_URI, "/foo");
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        headers.putSingle("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
+        messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), 
                                                            null, messageImpl);

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java Fri Jul  9 20:42:23 2010
@@ -65,7 +65,14 @@ public class Book {
     @Produces("application/xml;charset=ISO-8859-1")
     public Chapter getChapter(@PathParam("chapterid")int chapterid) {
         return chapters.get(new Long(chapterid));
-    } 
+    }
+    
+    @GET
+    @Path("chapters/acceptencoding/{chapterid}/")    
+    @Produces("application/xml")
+    public Chapter getChapterAcceptEncoding(@PathParam("chapterid")int chapterid) {
+        return chapters.get(new Long(chapterid));
+    }
 
     @GET
     @Path("chapters/badencoding/{chapterid}/")    

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri Jul  9 20:42:23 2010
@@ -403,6 +403,12 @@ public class BookStore {
         return new BookInfo(doGetBook("123"));
     }
     
+    @GET
+    @Path("/books/interface/adapter")
+    public BookInfoInterface getBookAdapter2() throws Exception {
+        return new BookInfo2(doGetBook("123"));
+    }
+    
     @PathParam("bookId")
     public void setBookId(String id) {
         currentBookId = id;
@@ -700,6 +706,13 @@ public class BookStore {
         cds.put(cd1.getId(), cd1);
     }
     
+    @XmlJavaTypeAdapter(BookInfoAdapter.class)
+    private static interface BookInfoInterface {
+        String getName();
+        
+        long getId();
+    }
+    
     static class BookInfo {
         private String name;
         private long id;
@@ -732,6 +745,16 @@ public class BookStore {
         }
     }
     
+    static class BookInfo2 extends BookInfo implements BookInfoInterface {
+        public BookInfo2() {
+            
+        }
+        
+        public BookInfo2(Book b) {
+            super(b);
+        }
+    }
+    
     public static class BookInfoAdapter extends XmlAdapter<Book, BookInfo> {
 
         @Override

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Fri Jul  9 20:42:23 2010
@@ -57,7 +57,7 @@ public class JAXRSClientServerBookTest e
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly",
-                   launchServer(BookServer.class));
+                   launchServer(BookServer.class, true));
     }
     
     
@@ -598,6 +598,13 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetBookAdapterInterface() throws Exception {
+        getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/books/interface/adapter",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+    }
+    
+    @Test
     public void testGetBook123FromSub() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/interface/subresource",
                                "resources/expected_get_book123.txt",
@@ -634,6 +641,16 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetChapterAcceptEncoding() throws Exception {
+        
+        getAndCompareAsStrings("http://localhost:" 
+                               + PORT + "/bookstore/booksubresource/123/chapters/acceptencoding/1",
+                               "resources/expected_get_chapter1.txt",
+                               "application/xml;charset=ISO-8859-1", "application/xml;charset=ISO-8859-1", 
+                               200);
+    }
+    
+    @Test
     public void testGetChapterChapter() throws Exception {
         
         getAndCompareAsStrings("http://localhost:" 

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java Fri Jul  9 20:42:23 2010
@@ -258,7 +258,7 @@ public class JAXRSMultipartTest extends 
         conduit.getClient().setReceiveTimeout(1000000);
         conduit.getClient().setConnectionTimeout(1000000);
         
-        client.type("multipart/related").accept("text/plain");
+        client.type("multipart/related").accept("multipart/related");
         XopType xop = new XopType();
         xop.setName("xopName");
         InputStream is = 
@@ -276,10 +276,12 @@ public class JAXRSMultipartTest extends 
             xop.setImage(getImage("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
         }
         
-        String response = client.post(xop, String.class);
+        XopType xop2 = client.post(xop, XopType.class);
         
-        
-        assertEquals("xopName" + bookXsd + bookXsd, response);
+        String bookXsdOriginal = IOUtils.readStringFromStream(getClass().getResourceAsStream(
+                "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
+        String bookXsd2 = IOUtils.readStringFromStream(xop2.getAttachinfo().getInputStream());        
+        assertEquals(bookXsdOriginal, bookXsd2);
     }
     
     private Image getImage(String name) throws Exception {

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java Fri Jul  9 20:42:23 2010
@@ -30,6 +30,8 @@ import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.mail.util.ByteArrayDataSource;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.POST;
@@ -70,8 +72,8 @@ public class MultipartStore {
     @POST
     @Path("/xop")
     @Consumes("multipart/related")
-    @Produces("text/plain")
-    public String addBookXop(XopType type) throws Exception {
+    @Produces("multipart/related;type=text/xml")
+    public XopType addBookXop(XopType type) throws Exception {
         if (!"xopName".equals(type.getName())) {
             throw new RuntimeException("Wrong name property");
         }
@@ -84,7 +86,25 @@ public class MultipartStore {
         if (!Boolean.getBoolean("java.awt.headless") && type.getImage() == null) {
             throw new RuntimeException("Wrong image property");
         }
-        return type.getName() + bookXsd + new String(type.getAttachinfo2());
+        context.put(org.apache.cxf.message.Message.MTOM_ENABLED, 
+                    (Object)"true");
+        
+        XopType xop = new XopType();
+        xop.setName("xopName");
+        InputStream is = 
+            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
+        byte[] data = IOUtils.readBytesFromStream(is);
+        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
+        
+        xop.setAttachinfo2(bookXsd.getBytes());
+     
+        if (Boolean.getBoolean("java.awt.headless")) {
+            System.out.println("Running headless. Ignoring an Image property.");
+        } else {
+            xop.setImage(ImageIO.read(getClass().getResource(
+                "/org/apache/cxf/systest/jaxrs/resources/java.jpg")));
+        }
+        return xop;
     }
     
     

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml?rev=962689&r1=962688&r2=962689&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml Fri Jul  9 20:42:23 2010
@@ -49,6 +49,14 @@
 		      <param-name>javax.ws.rs.Application</param-name>
 		      <param-value>org.apache.cxf.systest.jaxrs.BookApplication</param-value>    
 		</init-param>
+		<init-param>
+		      <param-name>jaxrs.outInterceptors</param-name>
+		      <param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>    
+		</init-param>
+		<init-param>
+		      <param-name>jaxrs.inInterceptors</param-name>
+		      <param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>    
+		</init-param>
 		<load-on-startup>1</load-on-startup>
 	</servlet>
 



Mime
View raw message