DemoApplicationTests.java 732 字节
Newer Older
B
bikebilly 已提交
1 2
package com.example.demo;

3
import org.junit.jupiter.api.Test;
B
bikebilly 已提交
4 5 6 7
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
8
import static org.junit.jupiter.api.Assertions.assertEquals;
B
bikebilly 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class DemoApplicationTests {

	@Test
	public void contextLoads() {
	}

	@Autowired
	private TestRestTemplate restTemplate;

	@Test
	public void homeResponse() {
		String body = this.restTemplate.getForObject("/", String.class);
23
		assertEquals("Spring is here!", body);
B
bikebilly 已提交
24 25
	}
}