You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2010/11/02 20:33:24 UTC
svn commit: r1030189 - in /cxf/trunk:
rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/
systests/jaxrs/src/...
Author: sergeyb
Date: Tue Nov 2 19:33:23 2010
New Revision: 1030189
URL: http://svn.apache.org/viewvc?rev=1030189&view=rev
Log:
[CXF-3090] : Support for request URIs with no trailing slashes
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt
cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Tue Nov 2 19:33:23 2010
@@ -181,7 +181,7 @@ public class ServletController extends A
return;
}
}
- } else if ("/".equals(address) || address.length() == 0) {
+ } else {
updateDests(request);
}
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java Tue Nov 2 19:33:23 2010
@@ -68,9 +68,33 @@ public class JAXRSClientServerResourceCr
}
@Test
+ public void testBasePetStoreWithoutTrailingSlash() throws Exception {
+
+ String endpointAddress = "http://localhost:" + PORT + "/webapp/resources";
+ WebClient client = WebClient.create(endpointAddress);
+ HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
+ conduit.getClient().setReceiveTimeout(1000000);
+ conduit.getClient().setConnectionTimeout(1000000);
+ String value = client.accept("text/plain").get(String.class);
+ assertEquals(PetStore.CLOSED, value);
+ }
+
+ @Test
+ public void testBasePetStore() throws Exception {
+
+ String endpointAddress = "http://localhost:" + PORT + "/webapp/resources/";
+ WebClient client = WebClient.create(endpointAddress);
+ HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
+ conduit.getClient().setReceiveTimeout(1000000);
+ conduit.getClient().setConnectionTimeout(1000000);
+ String value = client.accept("text/plain").get(String.class);
+ assertEquals(PetStore.CLOSED, value);
+ }
+
+ @Test
public void testMultipleRootsWadl() throws Exception {
- List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/",
- "http://localhost:" + PORT + "/webapp/", 2);
+ List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
+ "http://localhost:" + PORT + "/webapp/resources", 2);
String path1 = resourceEls.get(0).getAttribute("path");
int bookStoreInd = path1.contains("/bookstore") ? 0 : 1;
int petStoreInd = bookStoreInd == 0 ? 1 : 0;
@@ -80,22 +104,22 @@ public class JAXRSClientServerResourceCr
@Test
public void testBookStoreWadl() throws Exception {
- List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/",
- "http://localhost:" + PORT + "/webapp/bookstore", 1);
+ List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
+ "http://localhost:" + PORT + "/webapp/resources/bookstore", 1);
checkBookStoreInfo(resourceEls.get(0));
}
@Test
public void testPetStoreWadl() throws Exception {
- List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/",
- "http://localhost:" + PORT + "/webapp/petstore", 1);
+ List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
+ "http://localhost:" + PORT + "/webapp/resources/petstore", 1);
checkPetStoreInfo(resourceEls.get(0));
}
@Test
public void testPetStoreSource() throws Exception {
try {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/webapp/petstore");
+ WebClient wc = WebClient.create("http://localhost:" + PORT + "/webapp/resources/petstore");
HTTPConduit conduit = WebClient.getConfig(wc).getHttpConduit();
conduit.getClient().setReceiveTimeout(1000000);
conduit.getClient().setConnectionTimeout(1000000);
@@ -160,7 +184,7 @@ public class JAXRSClientServerResourceCr
}
private void checkPetStoreInfo(Element resource) {
- assertEquals("/petstore/", resource.getAttribute("path"));
+ assertEquals("/", resource.getAttribute("path"));
}
private List<Element> getWadlResourcesInfo(String baseURI, String requestURI, int size) throws Exception {
@@ -185,7 +209,7 @@ public class JAXRSClientServerResourceCr
public void testGetBook123() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/bookstore/books/123";
+ "http://localhost:" + PORT + "/webapp/resources/bookstore/books/123";
URL url = new URL(endpointAddress);
URLConnection connect = url.openConnection();
connect.addRequestProperty("Accept", "application/json");
@@ -206,7 +230,7 @@ public class JAXRSClientServerResourceCr
public void testGetBookNotFound() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/bookstore/books/12345";
+ "http://localhost:" + PORT + "/webapp/resources/bookstore/books/12345";
URL url = new URL(endpointAddress);
HttpURLConnection connect = (HttpURLConnection)url.openConnection();
connect.addRequestProperty("Accept", "text/plain,application/xml");
@@ -226,7 +250,7 @@ public class JAXRSClientServerResourceCr
public void testGetBookNotExistent() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/bookstore/nonexistent";
+ "http://localhost:" + PORT + "/webapp/resources/bookstore/nonexistent";
URL url = new URL(endpointAddress);
HttpURLConnection connect = (HttpURLConnection)url.openConnection();
connect.addRequestProperty("Accept", "application/xml");
@@ -243,7 +267,7 @@ public class JAXRSClientServerResourceCr
public void testPostPetStatus() throws Exception {
String endpointAddress =
- "http://localhost:" + PORT + "/webapp/petstore/pets";
+ "http://localhost:" + PORT + "/webapp/resources/petstore/pets";
URL url = new URL(endpointAddress);
HttpURLConnection httpUrlConnection = (HttpURLConnection)url.openConnection();
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java Tue Nov 2 19:33:23 2010
@@ -24,7 +24,6 @@ import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
-import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
@@ -100,22 +99,7 @@ public class JAXRSClientServerResourceJa
httpUrlConnection.disconnect();
}
- @Test
- public void testPostPetStatus2() throws Exception {
-
-
- Socket s = new Socket("localhost", Integer.parseInt(PORT));
- IOUtils.copyAndCloseInput(getClass().getResource("resources/formRequest.txt").openStream(),
- s.getOutputStream());
-
- s.getOutputStream().flush();
- try {
- assertTrue("Wrong status returned", getStringFromInputStream(s.getInputStream())
- .contains("open"));
- } finally {
- s.close();
- }
- }
+
private String getStringFromInputStream(InputStream in) throws Exception {
return IOUtils.toString(in);
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java Tue Nov 2 19:33:23 2010
@@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-@Path("/petstore/")
+@Path("/")
public class PetStore {
public static final String CLOSED = "The Pet Store is closed";
@@ -38,7 +38,14 @@ public class PetStore {
}
@GET
- @Path("/pets/{petId}/")
+ @Produces("text/plain")
+ public Response getBaseStatus() throws Exception {
+
+ return Response.ok(CLOSED).build();
+ }
+
+ @GET
+ @Path("/petstore/pets/{petId}/")
@Produces("text/xml")
public Response getStatus(@PathParam("petId")
String petId) throws Exception {
@@ -47,11 +54,10 @@ public class PetStore {
}
@POST
- @Path("/pets/")
+ @Path("/petstore/pets/")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces("text/xml")
public Response updateStatus(MultivaluedMap<String, String> params) throws Exception {
- System.out.println(params);
return Response.ok(params.getFirst("status")).build();
}
}
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt Tue Nov 2 19:33:23 2010
@@ -1,4 +1,4 @@
-POST /webapp/petstore/pets HTTP/1.1
+POST /webapp/resources/petstore/pets HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: en-ie
Content-Type: application/x-www-form-urlencoded
Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1030189&r1=1030188&r2=1030189&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml Tue Nov 2 19:33:23 2010
@@ -27,7 +27,7 @@ http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<jaxrs:server id="bookservice"
- address="/">
+ address="/resources">
<jaxrs:serviceBeans>
<ref bean="petstore"/>
<ref bean="bookstore"/>