|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* Copyright 2002-2020 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. |
|
|
|
@ -49,6 +49,7 @@ import org.springframework.web.servlet.support.SessionFlashMapManager;
@@ -49,6 +49,7 @@ import org.springframework.web.servlet.support.SessionFlashMapManager;
|
|
|
|
|
import org.springframework.web.util.UriComponentsBuilder; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Unit tests for building a {@link MockHttpServletRequest} with |
|
|
|
@ -88,7 +89,8 @@ public class MockHttpServletRequestBuilderTests {
@@ -88,7 +89,8 @@ public class MockHttpServletRequestBuilderTests {
|
|
|
|
|
assertThat(request.getServerName()).isEqualTo("java.sun.com"); |
|
|
|
|
assertThat(request.getServerPort()).isEqualTo(8080); |
|
|
|
|
assertThat(request.getRequestURI()).isEqualTo("/javase/6/docs/api/java/util/BitSet.html"); |
|
|
|
|
assertThat(request.getRequestURL().toString()).isEqualTo("https://java.sun.com:8080/javase/6/docs/api/java/util/BitSet.html"); |
|
|
|
|
assertThat(request.getRequestURL().toString()) |
|
|
|
|
.isEqualTo("https://java.sun.com:8080/javase/6/docs/api/java/util/BitSet.html"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -107,6 +109,12 @@ public class MockHttpServletRequestBuilderTests {
@@ -107,6 +109,12 @@ public class MockHttpServletRequestBuilderTests {
|
|
|
|
|
assertThat(request.getRequestURI()).isEqualTo("/test//currentlyValid/0"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // gh-24556
|
|
|
|
|
public void requestUriWithoutScheme() { |
|
|
|
|
assertThatIllegalArgumentException().isThrownBy(() -> MockMvcRequestBuilders.get("localhost:8080/path")) |
|
|
|
|
.withMessage("'url' should start with a path or be a complete HTTP URL: localhost:8080/path"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathEmpty() { |
|
|
|
|
this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/foo"); |
|
|
|
|