cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1380674 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/jav...
Date Tue, 04 Sep 2012 14:55:58 GMT
Author: sergeyb
Date: Tue Sep  4 14:55:57 2012
New Revision: 1380674

URL: http://svn.apache.org/viewvc?rev=1380674&view=rev
Log:
[CXF-4455] Completing the support for new exception classes, dropping a couple of CXF-specific
providers

Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ResponseReader.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/ResponseReaderTest.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlTest.java
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Tue Sep  4 14:55:57 2012
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Type;
 import java.net.HttpURLConnection;
 import java.net.URI;
@@ -37,6 +38,7 @@ import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.HttpHeaders;
@@ -65,6 +67,7 @@ import org.apache.cxf.jaxrs.model.URITem
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -405,6 +408,18 @@ public abstract class AbstractClient imp
                                                                                  
     }
     
+    protected WebApplicationException convertToWebApplicationException(Response r) {
+        Class<?> exceptionClass = JAXRSUtils.getWebApplicationExceptionClass(r, 
+                                       WebApplicationException.class);
+        try {
+            Constructor<?> ctr = exceptionClass.getConstructor(Response.class);
+            return (WebApplicationException)ctr.newInstance(r);
+        } catch (Exception ex2) {
+            ex2.printStackTrace();
+            return new WebApplicationException(r);
+        }
+    }
+    
     @SuppressWarnings("unchecked")
     protected <T> T readBody(Response r, Message outMessage, Class<T> cls, 
                              Type type, Annotation[] anns) {
@@ -423,10 +438,9 @@ public abstract class AbstractClient imp
         }
         
         int status = r.getStatus();
-        if (status < 200 || status == 204 || status > 300) {
+        if (status < 200 || status == 204 || status >= 300) {
             Object length = r.getMetadata().getFirst(HttpHeaders.CONTENT_LENGTH);
-            if (length == null || Integer.parseInt(length.toString()) == 0
-                || status >= 400) {
+            if (length == null || Integer.parseInt(length.toString()) == 0 || status >=
300) {
                 if (cls == Response.class) {
                     return cls.cast(r);
                 } else {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Tue Sep  4 14:55:57 2012
@@ -263,7 +263,7 @@ public class ClientProxyImpl extends Abs
         Throwable t = null;
         int status = r.getStatus();
         
-        if (status >= 400) {
+        if (status >= 300) {
             if (m.getReturnType() == Response.class && m.getExceptionTypes().length
== 0) {
                 return;
             }            
@@ -276,7 +276,7 @@ public class ClientProxyImpl extends Abs
             } 
                         
             if (t == null) {
-                t = new ServerWebApplicationException(r);
+                t = convertToWebApplicationException(r);
             }
 
             

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Tue
Sep  4 14:55:57 2012
@@ -29,6 +29,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.HttpHeaders;
@@ -743,8 +744,8 @@ public class WebClient extends AbstractC
         resetResponse();
         Response r = doChainedInvocation(httpMethod, headers, body, requestClass, inGenericType,

                                          responseClass, outGenericType, null, null);
-        if (r.getStatus() >= 400 && responseClass != Response.class) {
-            throw new ServerWebApplicationException(r);
+        if (r.getStatus() >= 300 && responseClass != Response.class) {
+            throw convertToWebApplicationException(r);
         }
         return r;
     }
@@ -805,8 +806,8 @@ public class WebClient extends AbstractC
                 return (Response)results[0];
             }
         } catch (Exception ex) {
-            throw ex instanceof ServerWebApplicationException 
-                ? (ServerWebApplicationException)ex 
+            throw ex instanceof WebApplicationException 
+                ? (WebApplicationException)ex 
                 : ex instanceof ClientWebApplicationException 
                 ? new ClientWebApplicationException(ex) : new RuntimeException(ex); 
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Tue Sep  4 14:55:57 2012
@@ -297,7 +297,8 @@ public final class ProviderFactory {
         if (WebApplicationException.class == exceptionType 
             && exception instanceof WebApplicationException) {
             exceptionType = 
-                JAXRSUtils.getWebApplicationExceptionClass((WebApplicationException)exception,
exceptionType);
+                JAXRSUtils.getWebApplicationExceptionClass(((WebApplicationException)exception).getResponse(),

+                                                           exceptionType);
         }
         for (ProviderInfo<ExceptionMapper<?>> em : exceptionMappers) {
             handleMapper(candidates, em, exceptionType, m, ExceptionMapper.class, true);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Tue
Sep  4 14:55:57 2012
@@ -48,8 +48,18 @@ import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.NotSupportedException;
 import javax.ws.rs.Produces;
+import javax.ws.rs.RedirectionException;
+import javax.ws.rs.ServerErrorException;
+import javax.ws.rs.ServiceUnavailableException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Cookie;
@@ -120,8 +130,15 @@ public final class JAXRSUtils {
     
     private static final Map<Integer, Class<?>> EXCEPTIONS_MAP;
     static {
-        //TODO: Populate it with the upgrade to the more up to date API
         EXCEPTIONS_MAP = new HashMap<Integer, Class<?>>();
+        EXCEPTIONS_MAP.put(400, BadRequestException.class);
+        EXCEPTIONS_MAP.put(404, NotFoundException.class);
+        EXCEPTIONS_MAP.put(500, InternalServerErrorException.class);
+        EXCEPTIONS_MAP.put(405, NotAllowedException.class);
+        EXCEPTIONS_MAP.put(406, NotAcceptableException.class);
+        EXCEPTIONS_MAP.put(401, NotAuthorizedException.class);
+        EXCEPTIONS_MAP.put(415, NotSupportedException.class);
+        EXCEPTIONS_MAP.put(503, ServiceUnavailableException.class);
     }
     
     private JAXRSUtils() {        
@@ -1223,15 +1240,19 @@ public final class JAXRSUtils {
         return types;
     }
     
-    public static Class<?> getWebApplicationExceptionClass(WebApplicationException
ex,
-                                                           Class<?> exceptionType)
{
-        int status = ex.getResponse().getStatus();
+    public static Class<?> getWebApplicationExceptionClass(Response exResponse,
+                                                           Class<?> defaultExceptionType)
{
+        int status = exResponse.getStatus();
         Class<?> cls = EXCEPTIONS_MAP.get(status);
-        //TODO: enable this code after the upgrade to the more up-to-date API
-        //if (cls == null && status / 100 == 5) {
-        //    cls = ServerErrorException.class;
-        //}
-        return cls == null ? exceptionType : cls;
+        if (cls == null) {
+            int family = status / 100;
+            if (family == 5) {
+                cls = ServerErrorException.class;
+            } else if (family == 3) {
+                cls = RedirectionException.class;
+            }
+        }
+        return cls == null ? defaultExceptionType : cls;
     }
     
     @SuppressWarnings("unchecked")
@@ -1243,7 +1264,7 @@ public final class JAXRSUtils {
             if (ex.getClass() == WebApplicationException.class 
                 && mapper.getClass() != WebApplicationExceptionMapper.class) {
                 WebApplicationException webEx = (WebApplicationException)ex;
-                Class<?> exceptionClass = getWebApplicationExceptionClass(webEx, 
+                Class<?> exceptionClass = getWebApplicationExceptionClass(webEx.getResponse(),

                                                                           WebApplicationException.class);
                 if (exceptionClass != WebApplicationException.class) {
                     //TODO: consider using switch statements

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Tue Sep  4 14:55:57 2012
@@ -37,8 +37,12 @@ import java.util.concurrent.TimeUnit;
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotFoundException;
 import javax.ws.rs.Produces;
+import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
@@ -68,6 +72,7 @@ import org.apache.cxf.jaxrs.model.Provid
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.SuperBook;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -317,6 +322,67 @@ public class ProviderFactoryTest extends
     }
     
     @Test
+    public void testNotFoundExceptionMapper() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        Message message = prepareMessage(pf);
+        
+        
+        ExceptionMapper<?> mapper = 
+            pf.createExceptionMapper(WebApplicationException.class, message);
+        assertTrue(mapper instanceof WebApplicationExceptionMapper);
+        
+        mapper = pf.createExceptionMapper(NotFoundException.class, message);
+        assertTrue(mapper instanceof WebApplicationExceptionMapper);
+        
+        NotFoundExceptionMapper nf = new NotFoundExceptionMapper(); 
+        pf.registerUserProvider(nf);
+        
+        mapper = pf.createExceptionMapper(NotFoundException.class, message);
+        assertSame(mapper, nf);
+        
+        mapper = pf.createExceptionMapper(new NotFoundException(), message);
+        assertSame(mapper, nf);
+        
+        mapper = pf.createExceptionMapper(new WebApplicationException(404), message);
+        assertSame(mapper, nf);
+        
+        Response r = JAXRSUtils.convertFaultToResponse(new NotFoundException(), message);
+        assertNotNull(r);
+        assertEquals(404, r.getStatus());
+        
+        r = JAXRSUtils.convertFaultToResponse(new WebApplicationException(404), message);
+        assertNotNull(r);
+        assertEquals(404, r.getStatus());
+    }
+    
+    @Test
+    public void testServerErrorExceptionMapper() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        Message message = prepareMessage(pf);
+        
+        ServerErrorExceptionMapper nf = new ServerErrorExceptionMapper(); 
+        pf.registerUserProvider(nf);
+        
+        ExceptionMapper<?> mapper = pf.createExceptionMapper(ServerErrorException.class,
message);
+        assertSame(mapper, nf);
+        
+        mapper = pf.createExceptionMapper(new ServerErrorException(500), message);
+        assertSame(mapper, nf);
+        
+        mapper = pf.createExceptionMapper(new WebApplicationException(500), message);
+        assertSame(mapper, nf);
+        
+        mapper = pf.createExceptionMapper(new InternalServerErrorException(), message);
+        assertSame(mapper, nf);
+        
+        InternalServerErrorExceptionMapper is = new InternalServerErrorExceptionMapper();

+        pf.registerUserProvider(is);
+        
+        mapper = pf.createExceptionMapper(new InternalServerErrorException(), message);
+        assertSame(mapper, is);
+    }
+    
+    @Test
     public void testExceptionMappersHierarchy1() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
@@ -541,6 +607,29 @@ public class ProviderFactoryTest extends
                    instanceof JAXBContextProvider2);
     }
     
+    private Message prepareMessage(ProviderFactory pf) {
+        
+        Message m = new MessageImpl();
+        m.put("org.apache.cxf.http.case_insensitive_queries", false);
+        Exchange e = new ExchangeImpl();
+        m.setExchange(e);
+        e.setInMessage(m);
+        Endpoint endpoint = EasyMock.createMock(Endpoint.class);
+        endpoint.getEndpointInfo();
+        EasyMock.expectLastCall().andReturn(null).anyTimes();
+        endpoint.get(Application.class.getName());
+        EasyMock.expectLastCall().andReturn(null);
+        endpoint.size();
+        EasyMock.expectLastCall().andReturn(0).anyTimes();
+        endpoint.isEmpty();
+        EasyMock.expectLastCall().andReturn(true).anyTimes();
+        endpoint.get(ProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(pf).anyTimes();
+        EasyMock.replay(endpoint);
+        e.put(Endpoint.class, endpoint);
+        return m;
+    }
+    
     private Message prepareMessage(String contentType, String acceptType) {
         Message message = new MessageImpl();
         Map<String, List<String>> headers = new MetadataMap<String, String>();
@@ -878,4 +967,27 @@ public class ProviderFactoryTest extends
         }
         
     }
+    
+    private static class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException>
{
+
+        public Response toResponse(NotFoundException arg0) {
+            return Response.status(404).build();
+        }
+    }
+    
+    private static class ServerErrorExceptionMapper implements ExceptionMapper<ServerErrorException>
{
+
+        public Response toResponse(ServerErrorException arg0) {
+            return Response.status(404).build();
+        }
+    }
+    
+    private static class InternalServerErrorExceptionMapper 
+        implements ExceptionMapper<InternalServerErrorException> {
+
+        public Response toResponse(InternalServerErrorException arg0) {
+            return Response.status(404).build();
+        }
+    }
+
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Sep  4 14:55:57 2012
@@ -31,6 +31,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.ServerErrorException;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
@@ -52,8 +55,6 @@ import org.apache.cxf.io.CachedOutputStr
 import org.apache.cxf.jaxrs.client.ClientWebApplicationException;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ResponseReader;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
@@ -428,10 +429,9 @@ public class JAXRSClientServerBookTest e
         try {
             wc.get(Book.class);
             fail("Exception expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(500, ex.getStatus());
-            assertEquals("This is a WebApplicationException", ex.getMessage());
-            assertTrue(ex.toString().contains("This is a WebApplicationException"));
+        } catch (ServerErrorException ex) {
+            assertEquals(500, ex.getResponse().getStatus());
+            assertEquals("This is a WebApplicationException", ex.getResponse().readEntity(String.class));
         }
     }
     
@@ -442,24 +442,21 @@ public class JAXRSClientServerBookTest e
         try {
             Response r = wc.get(Response.class);
             assertEquals(500, r.getStatus());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail("Unexpected exception");
         }
     }
     
     @Test
     public void testServerWebApplicationExceptionXML() throws Exception {
-        ResponseReader reader = new ResponseReader();
-        reader.setEntityClass(Book.class);
-        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/webappexceptionXML",
-                                        Collections.singletonList(reader));
+        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/webappexceptionXML");
         wc.accept("application/xml");
         try {
             wc.get(Book.class);
             fail("Exception expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(406, ex.getStatus());
-            Book exBook = ex.toErrorObject(wc, Book.class);
+        } catch (NotAcceptableException ex) {
+            assertEquals(406, ex.getResponse().getStatus());
+            Book exBook = ex.getResponse().readEntity(Book.class);
             assertEquals("Exception", exBook.getName());
             assertEquals(999L, exBook.getId());
         }
@@ -467,16 +464,14 @@ public class JAXRSClientServerBookTest e
     
     @Test
     public void testServerWebApplicationExceptionXMLWithProxy() throws Exception {
-        ResponseReader reader = new ResponseReader();
-        reader.setEntityClass(Book.class);
         BookStore proxy = JAXRSClientFactory.create("http://localhost:" + PORT,
-                                                    BookStore.class, Collections.singletonList(reader));
+                                                    BookStore.class);
         try {
             proxy.throwExceptionXML();
             fail("Exception expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(406, ex.getStatus());
-            Book exBook = ex.toErrorObject(WebClient.client(proxy), Book.class);
+        } catch (NotAcceptableException ex) {
+            assertEquals(406, ex.getResponse().getStatus());
+            Book exBook = ex.getResponse().readEntity(Book.class);
             assertEquals("Exception", exBook.getName());
             assertEquals(999L, exBook.getId());
         }
@@ -488,10 +483,21 @@ public class JAXRSClientServerBookTest e
         try {
             store.throwException();
             fail("Exception expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(500, ex.getStatus());
-            assertEquals("This is a WebApplicationException", ex.getMessage());
-            assertTrue(ex.toString().contains("This is a WebApplicationException"));
+        } catch (ServerErrorException ex) {
+            assertEquals(500, ex.getResponse().getStatus());
+            assertEquals("This is a WebApplicationException", ex.getResponse().readEntity(String.class));
+        }
+    }
+    
+    @Test
+    public void testServerWebApplicationExceptionWithProxy2() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        try {
+            store.throwException();
+            fail("Exception expected");
+        } catch (WebApplicationException ex) {
+            assertEquals(500, ex.getResponse().getStatus());
+            assertEquals("This is a WebApplicationException", ex.getResponse().readEntity(String.class));
         }
     }
     
@@ -969,15 +975,11 @@ public class JAXRSClientServerBookTest e
     
     @Test
     public void testGetBookFromResponseWithProxyAndReader() throws Exception {
-        ResponseReader reader = new ResponseReader();
-        reader.setEntityClass(Book.class);
-        
         BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, 
-                                                 BookStore.class,
-                                                 Collections.singletonList(reader));
+                                                 BookStore.class);
         Response r = bs.getGenericResponseBook("123");
         assertEquals(200, r.getStatus());
-        Book book = (Book)r.getEntity();
+        Book book = r.readEntity(Book.class);
         assertEquals(123L, book.getId());
     }
     
@@ -994,12 +996,10 @@ public class JAXRSClientServerBookTest e
     @Test
     public void testGetBookFromResponseWithWebClientAndReader() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/genericresponse/123";
-        WebClient wc = WebClient.create(address, 
-                                        Collections.singletonList(
-                                        new ResponseReader(Book.class)));
+        WebClient wc = WebClient.create(address);
         Response r = wc.accept("application/xml").get();
         assertEquals(200, r.getStatus());
-        Book book = (Book)r.getEntity();
+        Book book = r.readEntity(Book.class);
         assertEquals(123L, book.getId());
     }
     

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
Tue Sep  4 14:55:57 2012
@@ -23,6 +23,9 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.WebApplicationException;
+
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.GetMethod;
@@ -30,7 +33,6 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
@@ -158,8 +160,8 @@ public class JAXRSClientServerNonSpringB
         try {
             wc.accept("*/*").get(Book.class);
             fail();
-        } catch (ServerWebApplicationException ex) {
-            assertEquals("No book found at all : 321", ex.getMessage());
+        } catch (InternalServerErrorException ex) {
+            assertEquals("No book found at all : 321", ex.getResponse().readEntity(String.class));
         }
         
     }
@@ -171,8 +173,8 @@ public class JAXRSClientServerNonSpringB
         try {
             wc.accept("*/*").get(Book.class);
             fail();
-        } catch (ServerWebApplicationException ex) {
-            assertEquals("Nonexistent method", ex.getMessage());
+        } catch (WebApplicationException ex) {
+            assertEquals("Nonexistent method", ex.getResponse().readEntity(String.class));
         }
         
     }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverTest.java
Tue Sep  4 14:55:57 2012
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Response;
 
 import org.apache.cxf.clustering.FailoverFeature;
@@ -35,7 +36,6 @@ import org.apache.cxf.endpoint.ConduitSe
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.jaxrs.client.ClientWebApplicationException;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -144,7 +144,7 @@ public class FailoverTest extends Abstra
         strategyTest(Server.ADDRESS1, feature, Server.ADDRESS3, Server.ADDRESS2, false, false,
true);
     }
     
-    @Test(expected = ServerWebApplicationException.class)
+    @Test(expected = InternalServerErrorException.class)
     public void testSequentialStrategyWithServerException() throws Exception {
         FailoverFeature feature = 
             getFeature(false, false, Server.ADDRESS2, Server.ADDRESS3); 

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java
(original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java
Tue Sep  4 14:55:57 2012
@@ -24,12 +24,12 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.rs.security.saml.SamlEnvelopedOutInterceptor;
 import org.apache.cxf.systest.jaxrs.security.Book;
@@ -55,8 +55,8 @@ public class JAXRSSamlAuthorizationTest 
         try {
             wc.post(new Book("CXF", 125L), Book.class);
             fail("403 is expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(403, ex.getStatus());
+        } catch (WebApplicationException ex) {
+            assertEquals(403, ex.getResponse().getStatus());
         }
     }
     
@@ -81,8 +81,8 @@ public class JAXRSSamlAuthorizationTest 
         try {
             wc.post(new Book("CXF", 125L), Book.class);                
             fail("403 is expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(403, ex.getStatus());
+        } catch (WebApplicationException ex) {
+            assertEquals(403, ex.getResponse().getStatus());
         }
     }
     
@@ -109,8 +109,8 @@ public class JAXRSSamlAuthorizationTest 
         try {
             wc.post(new Book("CXF", 125L), Book.class);                
             fail("403 is expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(403, ex.getStatus());
+        } catch (WebApplicationException ex) {
+            assertEquals(403, ex.getResponse().getStatus());
         }
     }
 
@@ -126,8 +126,8 @@ public class JAXRSSamlAuthorizationTest 
         try {
             wc.post(new Book("CXF", 125L), Book.class);                
             fail("403 is expected");
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(403, ex.getStatus());
+        } catch (WebApplicationException ex) {
+            assertEquals(403, ex.getResponse().getStatus());
         }
     }
     

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlTest.java
(original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlTest.java
Tue Sep  4 14:55:57 2012
@@ -23,6 +23,7 @@ import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.Bus;
@@ -30,7 +31,6 @@ import org.apache.cxf.bus.spring.SpringB
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxrs.client.ClientWebApplicationException;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.provider.FormEncodingProvider;
@@ -41,6 +41,7 @@ import org.apache.cxf.rs.security.saml.S
 import org.apache.cxf.rs.security.xml.XmlSigOutInterceptor;
 import org.apache.cxf.systest.jaxrs.security.Book;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -62,7 +63,7 @@ public class JAXRSSamlTest extends Abstr
         try {
             Book book = wc.get(Book.class);
             assertEquals(123L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ClientWebApplicationException ex) {
             if (ex.getCause() != null && ex.getCause().getMessage() != null) {
@@ -87,7 +88,7 @@ public class JAXRSSamlTest extends Abstr
             Book book = wc.post(new Form().set("name", "CXF").set("id", 125),
                                 Book.class);                
             assertEquals(125L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ClientWebApplicationException ex) {
             if (ex.getCause() != null && ex.getCause().getMessage() != null) {
@@ -123,7 +124,7 @@ public class JAXRSSamlTest extends Abstr
         try {
             Book book = wc.post(new Book("CXF", 125L), Book.class);                
             assertEquals(125L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ClientWebApplicationException ex) {
             if (ex.getCause() != null && ex.getCause().getMessage() != null) {

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java?rev=1380674&r1=1380673&r2=1380674&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
(original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
Tue Sep  4 14:55:57 2012
@@ -23,11 +23,13 @@ import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.WebApplicationException;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.jaxrs.client.ClientWebApplicationException;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.rs.security.common.SecurityUtils;
 import org.apache.cxf.rs.security.xml.XmlEncInInterceptor;
@@ -84,7 +86,7 @@ public class JAXRSXmlSecTest extends Abs
         try {
             Book book = store.addBook(new Book("CXF", 126L));
             assertEquals(126L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ClientWebApplicationException ex) {
             if (ex.getCause() != null && ex.getCause().getMessage() != null) {
@@ -134,7 +136,7 @@ public class JAXRSXmlSecTest extends Abs
         try {
             Book book = wc.post(new Book("CXF", 126L), Book.class);
             assertEquals(126L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ClientWebApplicationException ex) {
             if (ex.getCause() != null && ex.getCause().getMessage() != null) {
@@ -229,8 +231,8 @@ public class JAXRSXmlSecTest extends Abs
         try {
             doTestPostEncryptedBook(address, true, properties, SecurityUtils.X509_CERT, 
                                 "http://www.w3.org/2009/xmlenc11#aes128-gcm", null, true);
-        } catch (ServerWebApplicationException ex) {
-            assertEquals(400, ex.getStatus());
+        } catch (BadRequestException ex) {
+            assertEquals(400, ex.getResponse().getStatus());
         }
         
     }
@@ -292,7 +294,7 @@ public class JAXRSXmlSecTest extends Abs
         try {
             Book book = wc.post(new Book("CXF", 126L), Book.class);
             assertEquals(126L, book.getId());
-        } catch (ServerWebApplicationException ex) {
+        } catch (WebApplicationException ex) {
             if (propagateException) {
                 throw ex;
             } else {



Mime
View raw message