SPR-7211 - Extend HttpMessage interface to expose requestURL
This commit is contained in:
@@ -83,9 +83,11 @@ public abstract class AbstractHttpRequestFactoryTestCase {
|
||||
|
||||
@Test
|
||||
public void status() throws Exception {
|
||||
URI uri = new URI(BASE_URL + "/status/notfound");
|
||||
ClientHttpRequest request =
|
||||
factory.createRequest(new URI(BASE_URL + "/status/notfound"), HttpMethod.GET);
|
||||
factory.createRequest(uri, HttpMethod.GET);
|
||||
assertEquals("Invalid HTTP method", HttpMethod.GET, request.getMethod());
|
||||
assertEquals("Invalid HTTP URI", uri, request.getURI());
|
||||
ClientHttpResponse response = request.execute();
|
||||
assertEquals("Invalid status code", HttpStatus.NOT_FOUND, response.getStatusCode());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,16 +16,17 @@
|
||||
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -48,6 +49,16 @@ public class ServletHttpRequestTests {
|
||||
assertEquals("Invalid method", HttpMethod.POST, request.getMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getURI() throws Exception {
|
||||
URI uri = new URI("http://example.com/path?query");
|
||||
mockRequest.setServerName(uri.getHost());
|
||||
mockRequest.setServerPort(uri.getPort());
|
||||
mockRequest.setRequestURI(uri.getPath());
|
||||
mockRequest.setQueryString(uri.getQuery());
|
||||
assertEquals("Invalid uri", uri, request.getURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeaders() throws Exception {
|
||||
String headerName = "MyHeader";
|
||||
|
||||
Reference in New Issue
Block a user