Browse Source

Add test case for HttpRequest with relative URIs

Test case for #19890
pull/22324/head
Arjen Poutsma 7 years ago
parent
commit
d3b5ba7a36
  1. 26
      spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

26
spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -25,6 +25,7 @@ import java.util.Map; @@ -25,6 +25,7 @@ import java.util.Map;
import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.mock.web.test.MockHttpServletRequest;
@ -518,6 +519,29 @@ public class UriComponentsBuilderTests { @@ -518,6 +519,29 @@ public class UriComponentsBuilderTests {
assertEquals("/foo/", after.getPath());
}
@Test // gh-19890
public void fromHttpRequestWithEmptyScheme() {
HttpRequest request = new HttpRequest() {
@Override
public String getMethodValue() {
return "GET";
}
@Override
public URI getURI() {
return UriComponentsBuilder.fromUriString("/").build().toUri();
}
@Override
public HttpHeaders getHeaders() {
return new HttpHeaders();
}
};
UriComponents result = UriComponentsBuilder.fromHttpRequest(request).build();
assertEquals("/", result.toString());
}
@Test
public void path() {
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/foo/bar");

Loading…
Cancel
Save