|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2019 the original author or authors. |
| 2 | + * Copyright 2014-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.restdocs.mockmvc;
|
18 | 18 |
|
19 |
| -import java.net.URI; |
20 |
| - |
21 | 19 | import org.junit.Rule;
|
22 | 20 | import org.junit.Test;
|
23 | 21 |
|
24 |
| -import org.springframework.hateoas.mvc.BasicLinkBuilder; |
25 | 22 | import org.springframework.mock.web.MockHttpServletRequest;
|
26 | 23 | import org.springframework.restdocs.JUnitRestDocumentation;
|
27 | 24 | import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
28 | 25 | import org.springframework.web.context.request.RequestContextHolder;
|
29 | 26 | import org.springframework.web.context.request.ServletRequestAttributes;
|
| 27 | +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; |
| 28 | +import org.springframework.web.util.UriComponents; |
30 | 29 |
|
31 | 30 | import static org.assertj.core.api.Assertions.assertThat;
|
32 | 31 |
|
@@ -89,10 +88,10 @@ private void assertUriConfiguration(String scheme, String host, int port) {
|
89 | 88 | assertThat(port).isEqualTo(this.request.getServerPort());
|
90 | 89 | RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(this.request));
|
91 | 90 | try {
|
92 |
| - URI uri = BasicLinkBuilder.linkToCurrentMapping().toUri(); |
93 |
| - assertThat(scheme).isEqualTo(uri.getScheme()); |
94 |
| - assertThat(host).isEqualTo(uri.getHost()); |
95 |
| - assertThat(port).isEqualTo(uri.getPort()); |
| 91 | + UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentServletMapping().build(); |
| 92 | + assertThat(scheme).isEqualTo(uriComponents.getScheme()); |
| 93 | + assertThat(host).isEqualTo(uriComponents.getHost()); |
| 94 | + assertThat(port).isEqualTo(uriComponents.getPort()); |
96 | 95 | }
|
97 | 96 | finally {
|
98 | 97 | RequestContextHolder.resetRequestAttributes();
|
|
0 commit comments