mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Before deprecating `TestRestTemplate`, we must first stop using it in smoke tests and replace it with: * `RestTestClient` when the Spring MVC infrastructure is present * `RestClient` when the test does not have Spring MVC on classpath See gh-46632
51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
/*
|
|
* Copyright 2012-present 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.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package smoketest.jetty.jsp;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|
import org.springframework.test.web.servlet.client.RestTestClient;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
/**
|
|
* Basic integration tests for JSP application.
|
|
*
|
|
* @author Phillip Webb
|
|
*/
|
|
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
|
@AutoConfigureRestTestClient
|
|
class SampleWebJspApplicationTests {
|
|
|
|
@Autowired
|
|
private RestTestClient restTestClient;
|
|
|
|
@Test
|
|
void testJspWithEl() {
|
|
this.restTestClient.get()
|
|
.uri("/")
|
|
.exchangeSuccessfully()
|
|
.expectBody(String.class)
|
|
.value((body) -> assertThat(body).contains("/resources/text.txt"));
|
|
}
|
|
|
|
}
|