cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756019 - in /cxf/branches/2.1.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/o...
Date Thu, 19 Mar 2009 14:26:11 GMT
Author: sergeyb
Date: Thu Mar 19 14:26:10 2009
New Revision: 756019

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

........
  r747806 | sergeyb | 2009-02-25 15:01:06 +0000 (Wed, 25 Feb 2009) | 1 line
  
  JAXRS: improving exception handling on client side and media type comparison
........
  r747846 | sergeyb | 2009-02-25 16:22:52 +0000 (Wed, 25 Feb 2009) | 1 line
  
  JAXRS : fixing the hudson build failures
........

Added:
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Messages.properties
      - copied unchanged from r747846, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Messages.properties
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 19 14:26:10 2009
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747986,748159,748192,748223,748305,748313,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749767,749771,749799,749890,750059-750060,750302,750591,750689,750935,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752122,752132,752136,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747806-747846,747986,748159,748192,748223,748305,748313,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749767,749771,749799,749890,750059-750060,750302,750591,750689,750935,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752122,752132,752136,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806

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

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 19 14:26:10 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,755514,755806

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 19 14:26:10 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,755514,755806

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java Thu Mar 19 14:26:10 2009
@@ -20,11 +20,18 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
 
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.binding.BindingFactory;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -49,6 +56,9 @@
  */
 public class AbstractJAXRSFactoryBean extends AbstractEndpointFactory {
     
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXRSFactoryBean.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXRSFactoryBean.class);
+    
     protected List<String> schemaLocations;
     protected JAXRSServiceFactoryBean serviceFactory;
     protected List<?> entityProviders;
@@ -190,4 +200,13 @@
         setProviders(Collections.singletonList(provider));
     }
 
+    protected void checkResources() {
+        if (!serviceFactory.resourcesAvailable()) {
+            org.apache.cxf.common.i18n.Message msg = 
+                new org.apache.cxf.common.i18n.Message("NO_RESOURCES_AVAILABLE", 
+                                                       BUNDLE);
+            LOG.severe(msg.toString());
+            throw new WebApplicationException(Response.Status.NOT_FOUND);
+        }
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Thu Mar 19 14:26:10 2009
@@ -23,12 +23,8 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.logging.Logger;
 
 import org.apache.cxf.BusException;
-import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.Server;
@@ -57,9 +53,6 @@
  */
 public class JAXRSServerFactoryBean extends AbstractJAXRSFactoryBean {
     
-    private static final Logger LOG = LogUtils.getL7dLogger(JAXRSServerFactoryBean.class);
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSServerFactoryBean.class);
-    
     protected Map<Class, ResourceProvider> resourceProviders = new HashMap<Class, ResourceProvider>();
     
     private Server server;
@@ -83,13 +76,7 @@
     
     public Server create() {
         try {
-            if (!serviceFactory.resourcesAvailable()) {
-                org.apache.cxf.common.i18n.Message msg = 
-                    new org.apache.cxf.common.i18n.Message("NO_RESOURCES_AVAILABLE", 
-                                                           BUNDLE);
-                LOG.severe(msg.toString());
-                throw new EndpointException(msg);
-            }
+            checkResources();
             if (serviceFactory.getService() == null) {
                 serviceFactory.create();
                 updateClassResourceProviders();
@@ -127,6 +114,8 @@
             throw new ServiceConstructionException(e);
         } catch (IOException e) {
             throw new ServiceConstructionException(e);
+        } catch (Exception e) {
+            throw new ServiceConstructionException(e);
         }
 
         applyFeatures();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties Thu Mar 19 14:26:10 2009
@@ -18,7 +18,7 @@
 #    under the License.
 #
 #
-NO_RESOURCES_AVAILABLE=No resource classes found, endpoint can not be created
+NO_RESOURCES_AVAILABLE=No resource classes found
 NO_SUBRESOURCE_FOUND=No subresource locator found for path {0}
 NULL_SUBRESOURCE=Null subresource locator is returned for path {0}
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Thu Mar 19 14:26:10 2009
@@ -31,6 +31,8 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Cookie;
@@ -46,6 +48,8 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
@@ -67,6 +71,9 @@
 public class AbstractClient implements Client {
 
     protected static final MediaType WILDCARD = MediaType.valueOf("*/*");
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractClient.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractClient.class);
+
     protected List<Interceptor> inInterceptors = new ModCountCopyOnWriteArrayList<Interceptor>();
     protected List<Interceptor> outInterceptors = new ModCountCopyOnWriteArrayList<Interceptor>();
     protected ConduitSelector conduitSelector;
@@ -290,7 +297,7 @@
             }
              
         } else {
-            throw new WebApplicationException();
+            reportNoMessageHandler("NO_MSG_WRITER", cls);
         }
                                                                                  
     }
@@ -324,9 +331,18 @@
             }
              
         } else {
-            throw new WebApplicationException();
+            reportNoMessageHandler("NO_MSG_READER", cls);
         }
-                                                                                 
+        return null;                                                
+    }
+    
+    protected static void reportNoMessageHandler(String name, Class<?> cls) {
+        org.apache.cxf.common.i18n.Message errorMsg = 
+            new org.apache.cxf.common.i18n.Message(name, 
+                                                   BUNDLE,
+                                                   cls);
+        LOG.severe(errorMsg.toString());
+        throw new WebApplicationException(415);
     }
     
     private static MediaType getResponseContentType(Response r) {
@@ -400,14 +416,16 @@
     
     protected Message createMessage(String httpMethod, 
                                     MultivaluedMap<String, String> headers,
-                                    String address) {
+                                    URI currentURI) {
         Message m = conduitSelector.getEndpoint().getBinding().createMessage();
         m.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
         m.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
         
         m.put(Message.HTTP_REQUEST_METHOD, httpMethod);
         m.put(Message.PROTOCOL_HEADERS, headers);
-        m.put(Message.ENDPOINT_ADDRESS, address);
+        m.put(Message.ENDPOINT_ADDRESS, currentURI.toString());
+        m.put(Message.REQUEST_URI, currentURI.toString());
+        
         m.put(Message.CONTENT_TYPE, headers.getFirst(HttpHeaders.CONTENT_TYPE));
         
         

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Thu Mar 19 14:26:10 2009
@@ -27,6 +27,8 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
 
 import javax.ws.rs.CookieParam;
 import javax.ws.rs.HeaderParam;
@@ -41,6 +43,8 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -58,6 +62,9 @@
 
 public class ClientProxyImpl extends AbstractClient implements InvocationHandler {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(ClientProxyImpl.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ClientProxyImpl.class);
+    
     private ClassResourceInfo cri;
     private boolean inheritHeaders;
     
@@ -78,15 +85,14 @@
         
         OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
         if (ori == null) {
-            throw new WebApplicationException(400);
+            reportInvalidResourceMethod(m, "INVALID_RESOURCE_METHOD");
         }
         
-        
         MultivaluedMap<ParameterType, Parameter> types = 
             getParametersInfo(ori, m, params);
         List<Object> pathParams = getParamValues(types, params, ParameterType.PATH);
         
-        int bodyIndex = getBodyIndex(types, ori.isSubResourceLocator());
+        int bodyIndex = getBodyIndex(types, ori);
         
         UriBuilder builder = getCurrentBuilder().clone(); 
         if (cri.isRoot()) {
@@ -106,7 +112,7 @@
         if (ori.isSubResourceLocator()) {
             ClassResourceInfo subCri = cri.getSubResource(m.getReturnType(), m.getReturnType());
             if (subCri == null) {
-                throw new WebApplicationException();
+                reportInvalidResourceMethod(m, "INVALID_SUBRESOURCE");
             }
             ClientProxyImpl proxyImpl = new ClientProxyImpl(getBaseURI(), uri, subCri, inheritHeaders);
             proxyImpl.setBus(bus);
@@ -146,20 +152,21 @@
         }
         if (map.containsKey(ParameterType.REQUEST_BODY)) {
             if (map.get(ParameterType.REQUEST_BODY).size() > 1) {
-                throw new WebApplicationException();
+                reportInvalidResourceMethod(m, "SINGLE_BODY_ONLY");
             }
             if (map.containsKey(ParameterType.FORM)) {
-                throw new WebApplicationException();
+                reportInvalidResourceMethod(m, "ONLY_FORM_ALLOWED");
             }
         }
         return map;
     }
     
-    private static int getBodyIndex(MultivaluedMap<ParameterType, Parameter> map, boolean subresource) {
+    private static int getBodyIndex(MultivaluedMap<ParameterType, Parameter> map, 
+                                    OperationResourceInfo ori) {
         List<Parameter> list = map.get(ParameterType.REQUEST_BODY);
         int index  = list == null ? -1 : list.get(0).getIndex(); 
-        if (subresource && index != -1) {
-            throw new WebApplicationException();
+        if (ori.isSubResourceLocator() && index != -1) {
+            reportInvalidResourceMethod(ori.getMethodToInvoke(), "NO_BODY_IN_SUBRESOURCE");
         }
         return index;
     }
@@ -308,7 +315,7 @@
         
         Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
         if (ctx != null) {
-            throw new WebApplicationException();
+            reportInvalidResourceMethod(ori.getMethodToInvoke(), "NO_CONTEXT_PARAMETERS");
         }
         
         boolean isEncoded = AnnotationUtils.isEncoded(anns, ori);
@@ -374,7 +381,7 @@
     private Object doChainedInvocation(URI uri, MultivaluedMap<String, String> headers, 
                           OperationResourceInfo ori, Object[] params, int bodyIndex, 
                           MultivaluedMap<ParameterType, Parameter> types) throws Throwable {
-        Message m = createMessage(ori.getHttpMethod(), headers, uri.toString());
+        Message m = createMessage(ori.getHttpMethod(), headers, uri);
 
         if (bodyIndex != -1 || types.containsKey(ParameterType.FORM)) {
             m.setContent(OperationResourceInfo.class, ori);
@@ -410,6 +417,16 @@
         return readBody(r, connect, inMessage, method.getReturnType(), 
                         method.getGenericReturnType(), method.getDeclaredAnnotations());
     }
+
+    protected static void reportInvalidResourceMethod(Method m, String name) {
+        org.apache.cxf.common.i18n.Message errorMsg = 
+            new org.apache.cxf.common.i18n.Message(name, 
+                                                   BUNDLE,
+                                                   m.getDeclaringClass().getName(), 
+                                                   m.getName());
+        LOG.severe(errorMsg.toString());
+        throw new WebApplicationException(405);
+    }
     
     private static class Parameter {
         private ParameterType type;
@@ -485,4 +502,5 @@
         }
         
     }
+    
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java Thu Mar 19 14:26:10 2009
@@ -19,7 +19,6 @@
 package org.apache.cxf.jaxrs.client;
 
 import java.net.URI;
-import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.WebApplicationException;
@@ -97,15 +96,12 @@
     }
     
     public Client create() {
-        List<ClassResourceInfo> list = serviceFactory.getClassResourceInfo();
-        if (list.isEmpty()) {
-            throw new WebApplicationException();
-        }
+        checkResources();
         
         try {
             Endpoint ep = createEndpoint();
             URI baseURI = URI.create(getAddress());
-            ClassResourceInfo cri = list.get(0);
+            ClassResourceInfo cri = serviceFactory.getClassResourceInfo().get(0);
             
             ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, inheritHeaders);
             initClient(proxyImpl, ep);    

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Thu Mar 19 14:26:10 2009
@@ -287,7 +287,7 @@
     protected Response doChainedInvocation(String httpMethod, 
         MultivaluedMap<String, String> headers, Object body, Class<?> responseClass) {
 
-        Message m = createMessage(httpMethod, headers, getCurrentURI().toString());
+        Message m = createMessage(httpMethod, headers, getCurrentURI());
         
         if (body != null) {
             MessageContentsList contents = new MessageContentsList(body);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java Thu Mar 19 14:26:10 2009
@@ -49,11 +49,19 @@
     }
     
     public List<MediaType> getAcceptableMediaTypes() {
-        return JAXRSUtils.sortMediaTypes((String)m.get(Message.ACCEPT_CONTENT_TYPE)); 
+        String lValues = headers.getFirst(HttpHeaders.ACCEPT);
+        if (lValues == null) {
+            return Collections.emptyList();
+        }
+        return JAXRSUtils.sortMediaTypes(lValues); 
     }
 
     public Map<String, Cookie> getCookies() {
-        List<String> cs = headers.get(HttpHeaders.COOKIE);
+        List<String> values = headers.get(HttpHeaders.COOKIE);
+        if (values == null || values.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        String[] cs =  values.get(0).split(",");
         Map<String, Cookie> cl = new HashMap<String, Cookie>(); 
         for (String c : cs) {
             Cookie cookie = Cookie.valueOf(c);
@@ -90,17 +98,18 @@
         String[] ls =  values.get(0).split(",");
         Map<String, Float> prefs = new HashMap<String, Float>();
         for (String l : ls) {
-            String[] pair = l.split(";"); 
-            newLs.add(pair[0]);
+            String[] pair = l.split(";");
+            String locale = pair[0].trim();
+            newLs.add(locale);
             if (pair.length > 1) {
                 String[] pair2 = pair[1].split("=");
                 if (pair2.length > 1) {
-                    prefs.put(pair[0], JAXRSUtils.getMediaTypeQualityFactor(pair2[1]));
+                    prefs.put(locale, JAXRSUtils.getMediaTypeQualityFactor(pair2[1].trim()));
                 } else {
-                    prefs.put(pair[0], 1F);
+                    prefs.put(locale, 1F);
                 }
             } else {
-                prefs.put(pair[0], 1F);
+                prefs.put(locale, 1F);
             }
         }
         if (newLs.size() == 1) {
@@ -135,7 +144,7 @@
             float p1 = prefs.get(lang1);
             float p2 = prefs.get(lang2);
             int result = Float.compare(p1, p2);
-            return result == 0 ? result : ~result;
+            return result == 0 ? result : result * -1;
         }
     }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Thu Mar 19 14:26:10 2009
@@ -90,10 +90,14 @@
     public static String getEndpointAddress(Message m) {
         String address = null;
         Destination d = m.getExchange().getDestination();
-        if (d instanceof ServletDestination) {
-            address = ((ServletDestination)d).getEndpointInfo().getAddress();
+        if (d != null) {
+            if (d instanceof ServletDestination) {
+                address = ((ServletDestination)d).getEndpointInfo().getAddress();
+            } else {
+                address = d.getAddress().getAddress().getValue();
+            }
         } else {
-            address = d.getAddress().getAddress().getValue();
+            address = (String)m.get(Message.ENDPOINT_ADDRESS);
         }
         
         return address;

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Thu Mar 19 14:26:10 2009
@@ -327,13 +327,6 @@
     
     public static int compareMediaTypes(MediaType mt1, MediaType mt2) {
         
-        if (mt1.equals(mt2)) {
-            float q1 = getMediaTypeQualityFactor(mt1.getParameters().get("q"));
-            float q2 = getMediaTypeQualityFactor(mt2.getParameters().get("q"));
-            int result = Float.compare(q1, q2);
-            return result == 0 ? result : ~result;
-        }
-        
         if (mt1.isWildcardType() && !mt2.isWildcardType()) {
             return 1;
         }
@@ -349,7 +342,15 @@
                 return -1;
             }       
         }
-        return mt1.toString().compareTo(mt2.toString());
+        
+        float q1 = getMediaTypeQualityFactor(mt1.getParameters().get("q"));
+        float q2 = getMediaTypeQualityFactor(mt2.getParameters().get("q"));
+        int result = Float.compare(q1, q2);
+        if (result != 0) {
+            return result * -1;
+        }
+        
+        return 0;
         
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java Thu Mar 19 14:26:10 2009
@@ -29,6 +29,7 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -57,14 +58,14 @@
                      ori.getMethodToInvoke().getName());
         
         
-        acceptContentTypes = "*/*";
+        acceptContentTypes = "application/xml,application/json";
         resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1", values);
         ori = JAXRSUtils.findTargetMethod(resource, 
                                         values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
                                         "GET", values, contentTypes, 
-                                        Collections.singletonList(MediaType.valueOf(acceptContentTypes)));
+                                        JAXRSUtils.parseMediaTypes(acceptContentTypes));
         assertNotNull(ori);
-        assertEquals("listMethod needs to be selected", "unlimitedPath", 
+        assertEquals("readMethod needs to be selected", "readMethod", 
                      ori.getMethodToInvoke().getName());
         
         
@@ -76,7 +77,7 @@
                                         "GET", values, contentTypes, 
                                         Collections.singletonList(MediaType.valueOf(acceptContentTypes)));
         assertNotNull(ori);
-        assertEquals("listMethod needs to be selected", "readMethod", 
+        assertEquals("readMethod needs to be selected", "readMethod", 
                      ori.getMethodToInvoke().getName());
         
         contentTypes = "application/json";
@@ -87,7 +88,7 @@
                                         "GET", values, contentTypes, 
                                         Collections.singletonList(MediaType.valueOf(acceptContentTypes)));
         assertNotNull(ori);
-        assertEquals("listMethod needs to be selected", "readMethod2", 
+        assertEquals("readMethod2 needs to be selected", "readMethod2", 
                      ori.getMethodToInvoke().getName());
         
         contentTypes = "application/json";
@@ -98,7 +99,7 @@
                                         "GET", values, contentTypes, 
                                         Collections.singletonList(MediaType.valueOf(acceptContentTypes)));
         assertNotNull(ori);
-        assertEquals("listMethod needs to be selected", "unlimitedPath", 
+        assertEquals("unlimitedPath needs to be selected", "unlimitedPath", 
                      ori.getMethodToInvoke().getName());
         
         resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/1/2", values);
@@ -107,7 +108,7 @@
                                         "GET", values, contentTypes, 
                                         Collections.singletonList(MediaType.valueOf(acceptContentTypes)));
         assertNotNull(ori);
-        assertEquals("listMethod needs to be selected", "limitedPath", 
+        assertEquals("limitedPath needs to be selected", "limitedPath", 
                      ori.getMethodToInvoke().getName());
         
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java Thu Mar 19 14:26:10 2009
@@ -19,15 +19,20 @@
 
 package org.apache.cxf.jaxrs.impl;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -85,10 +90,67 @@
     }
     
         
-    private Map<String, List<String>> createHeaders() {
+    
+    @Test
+    public void testSingleAcceptableLanguages() throws Exception {
+        
+        Message m = control.createMock(Message.class);
+        m.get(Message.PROTOCOL_HEADERS);
+        MetadataMap<String, String> headers = createHeaders();
+        headers.putSingle(HttpHeaders.ACCEPT_LANGUAGE, "en");
+        EasyMock.expectLastCall().andReturn(headers);
+        control.replay();
+        HttpHeaders h = new HttpHeadersImpl(m);
+        List<String> languages = h.getAcceptableLanguages();
+        assertEquals(1, languages.size());
+        assertEquals("en", languages.get(0));
+    }
+    
+    @Test
+    public void testGetCookies() throws Exception {
+        
+        Message m = new MessageImpl();
+        MetadataMap<String, String> headers = createHeaders();
+        headers.putSingle(HttpHeaders.COOKIE, "a=b,c=d");
+        m.put(Message.PROTOCOL_HEADERS, headers);
+        HttpHeaders h = new HttpHeadersImpl(m);
+        Map<String, Cookie> cookies = h.getCookies();
+        assertEquals(2, cookies.size());
+        assertEquals("b", cookies.get("a").getValue());
+        assertEquals("d", cookies.get("c").getValue());
+    }
+    
+    @Test
+    public void testMultipleAcceptableLanguages() throws Exception {
+        
+        Message m = control.createMock(Message.class);
+        m.get(Message.PROTOCOL_HEADERS);
+        MetadataMap<String, String> headers = 
+            createHeader(HttpHeaders.ACCEPT_LANGUAGE, 
+                         "en;q=0.7, en-gb;q=0.8, da");
+        EasyMock.expectLastCall().andReturn(headers);
+        control.replay();
+        HttpHeaders h = new HttpHeadersImpl(m);
+        List<String> languages = h.getAcceptableLanguages();
+        assertEquals(3, languages.size());
+        assertEquals("da", languages.get(0));
+        assertEquals("en-gb", languages.get(1));
+        assertEquals("en", languages.get(2));
+    }
+    
+        
+    private MetadataMap<String, String> createHeaders() {
         MetadataMap<String, String> hs = new MetadataMap<String, String>();
         hs.putSingle("Accept", "text/*;q=1,application/xml");
         hs.putSingle("Content-Type", "*/*");
         return hs;
     }
+    
+    private MetadataMap<String, String> createHeader(String name, String... values) {
+        MetadataMap<String, String> hs = new MetadataMap<String, String>();
+        List<String> list = new ArrayList<String>();
+        list.addAll(Arrays.asList(values));
+        hs.put(name, list);
+        return hs;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Thu Mar 19 14:26:10 2009
@@ -71,6 +71,9 @@
     @Test
     public void testMultipleFactories() {
         assertSame(ProviderFactory.getInstance(), ProviderFactory.getInstance());
+        assertSame(ProviderFactory.getInstance("/"), ProviderFactory.getInstance("/"));
+        assertSame(ProviderFactory.getInstance(), ProviderFactory.getInstance("/"));
+        assertNotSame(ProviderFactory.getInstance(), ProviderFactory.getSharedInstance());
         assertSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/bar"));
         assertNotSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/"));
     }
@@ -150,10 +153,11 @@
     public void testSortEntityProvidersWithConfig() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         JSONProvider json1 = new JSONProvider();
+        json1.setConsumeMediaTypes(Collections.singletonList("application/json;q=0.9"));
         pf.registerUserProvider(json1);
         JSONProvider json2 = new JSONProvider();
-        json2.setConsumeMediaTypes(Collections.singletonList("application/abc"));
-        json2.setProduceMediaTypes(Collections.singletonList("application/sbc"));
+        json2.setConsumeMediaTypes(Collections.singletonList("application/json"));
+        json2.setProduceMediaTypes(Collections.singletonList("application/sbc;q=0.9"));
         pf.registerUserProvider(json2);
         
         List<ProviderInfo<MessageBodyReader>> readers = pf.getMessageReaders();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Thu Mar 19 14:26:10 2009
@@ -154,7 +154,7 @@
         //method is declared with a most specific ProduceMime type is selected.
         OperationResourceInfo ori = findTargetResourceClass(resources, null, 
              "/bookstore/1/books/123/", "GET", new MetadataMap<String, String>(), contentTypes, 
-             getTypes("*/*"));       
+             getTypes("application/json,application/xml"));       
         assertNotNull(ori);
         assertEquals("getBookJSON", ori.getMethodToInvoke().getName());
         
@@ -403,9 +403,9 @@
         List<MediaType> types = 
             JAXRSUtils.sortMediaTypes("text/*,text/plain;q=.2,text/xml,TEXT/BAR");
         assertTrue(types.size() == 4
-                   && "text/bar".equals(types.get(0).toString())
-                   && "text/plain;q=.2".equals(types.get(1).toString())
-                   && "text/xml".equals(types.get(2).toString())
+                   && "text/xml".equals(types.get(0).toString())
+                   && "text/bar".equals(types.get(1).toString())
+                   && "text/plain;q=.2".equals(types.get(2).toString())
                    && "text/*".equals(types.get(3).toString()));
     }
     
@@ -422,10 +422,10 @@
         assertTrue("text/* should be equal to itself", 
                    JAXRSUtils.compareMediaTypes(m2, new MediaType("text", "*")) == 0);
         
-        assertTrue("text/plain is alphabetically earlier than text/xml", 
-                   JAXRSUtils.compareMediaTypes(MediaType.valueOf("text/plain"), m1) < 0);
-        assertTrue("text/xml is alphabetically later than text/plain", 
-                   JAXRSUtils.compareMediaTypes(m1, MediaType.valueOf("text/plain")) > 0);
+        assertTrue("text/plain and text/xml are just two specific media types", 
+                   JAXRSUtils.compareMediaTypes(MediaType.valueOf("text/plain"), m1) == 0);
+        assertTrue("text/xml and text/plain are just two specific media types", 
+                   JAXRSUtils.compareMediaTypes(m1, MediaType.valueOf("text/plain")) == 0);
         assertTrue("*/* is less specific than text/xml", 
                    JAXRSUtils.compareMediaTypes(JAXRSUtils.ALL_TYPES, m1) > 0);
         assertTrue("*/* is less specific than text/xml", 
@@ -745,11 +745,13 @@
         assertSame(ori, ori1);
         
         ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", new MetadataMap<String, String>(), 
-                                          "*/*", getTypes("*,text/plain,text/xml"));
+                                          "*/*", 
+                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain,text/xml")));
                      
         assertSame(ori, ori2);
         ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", new MetadataMap<String, String>(), 
-                                          "*/*", getTypes("*,x/y,text/xml,text/plain"));
+                                          "*/*", 
+                                          JAXRSUtils.sortMediaTypes(getTypes("*,text/plain, text/xml,x/y")));
                      
         assertSame(ori, ori2);
     }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java Thu Mar 19 14:26:10 2009
@@ -77,7 +77,7 @@
     
     @GET
     @Path("/books/feed")
-    @ProduceMime({"application/json", "application/atom+xml" })
+    @ProduceMime({"application/atom+xml", "application/json" })
     public Feed getBooksAsFeed(@Context UriInfo uParam) {
         
         MediaType mt = headers.getMediaType();

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java Thu Mar 19 14:26:10 2009
@@ -34,7 +34,7 @@
     
     @GET
     @Path("/")
-    @ProduceMime({"application/json", "application/atom+xml" })
+    @ProduceMime({"application/atom+xml", "application/json" })
     public Feed getBooksAsFeed(@Context UriInfo uParam) {
         
         return super.getBooksAsFeed(uParam);

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Thu Mar 19 14:26:10 2009
@@ -40,6 +40,9 @@
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
@@ -62,7 +65,9 @@
     private String currentBookId;
     @PathParam("CDId")
     private String currentCdId;
-
+    @Context
+    private HttpHeaders httpHeaders;
+    
     public BookStore() {
         init();
     }
@@ -148,6 +153,18 @@
     @GET
     @Path("/bookheaders/")
     public Book getBookByHeader(@HeaderParam("BOOK") List<String> ids) throws Exception {
+        List<MediaType> types = httpHeaders.getAcceptableMediaTypes();
+        if (types.size() != 2 
+            || !"text/xml".equals(types.get(0).toString())
+            || !MediaType.APPLICATION_XML_TYPE.isCompatible(types.get(1))) {
+            throw new WebApplicationException();
+        }
+        List<String> locales = httpHeaders.getAcceptableLanguages();
+        if (locales.size() != 2 
+            || !"en".equals(locales.get(0))
+            || !"da".equals(locales.get(1))) {
+            throw new WebApplicationException();
+        }
         
         return doGetBook(ids.get(0) + ids.get(1) + ids.get(2));
     }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Thu Mar 19 14:26:10 2009
@@ -238,7 +238,7 @@
         
         getAndCompareAsStrings("http://localhost:9080/bookstore/books/123",
                                "resources/expected_get_book123json.txt",
-                               "application/xml,application/json", 200);
+                               "application/json, application/xml", 200);
     }
     
     @Test
@@ -274,7 +274,7 @@
     public void testGetBookByHeader() throws Exception {
         getAndCompareAsStrings("http://localhost:9080/bookstore/bookheaders",
                                "resources/expected_get_book123.txt",
-                               "application/xml", 200);
+                               "application/xml;q=0.5,text/xml", 200);
     }
     
     @Test
@@ -299,7 +299,7 @@
         
         getAndCompareAsStrings("http://localhost:9080/bookstore/books/123",
                                "resources/expected_get_book123json.txt",
-                               "application/xml,application/json", 200);
+                               "application/xml;q=0.1,application/json", 200);
     }
     
     @Test
@@ -755,7 +755,7 @@
                                int expectedStatus) throws Exception {
         GetMethod get = new GetMethod(address);
         get.setRequestHeader("Accept", acceptType);
-        get.setRequestHeader("Accept-Language", "en,da;q=0.8");
+        get.setRequestHeader("Accept-Language", "da;q=0.8,en");
         get.setRequestHeader("BOOK", "1,2,3");
         HttpClient httpClient = new HttpClient();
         try {

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=756019&r1=756018&r2=756019&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Thu Mar 19 14:26:10 2009
@@ -57,7 +57,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerRestSoap.class, true));
+                   launchServer(BookServerRestSoap.class));
     }
     
     @Test



Mime
View raw message