24 lines
771 B
Java
24 lines
771 B
Java
package com.example.springboot;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
public class HelloControllerIT {
|
|
@Autowired
|
|
private TestRestTemplate template;
|
|
|
|
public static void main(String[] args) {
|
|
new HelloControllerIT().getHello();
|
|
}
|
|
|
|
@Test
|
|
public void getHello() {
|
|
var response = template.getForEntity("/", String.class);
|
|
assertThat(response.getBody()).isEqualTo("Greetings from Spring Boot!");
|
|
}
|
|
}
|