You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
package com.bupt.note;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
@SpringBootTest
|
|
class NoteApplicationTests {
|
|
|
|
@Autowired
|
|
private WebApplicationContext context;
|
|
|
|
protected MockMvc mvc;
|
|
|
|
@BeforeEach
|
|
public void setUp() {
|
|
mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
|
}
|
|
|
|
//注册接口
|
|
@Test
|
|
public void testSignup() throws Exception {
|
|
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.post("/v1/api/sign_up")
|
|
.content("{\"userName\":\"test\",\"password\":\"123\"}")
|
|
.contentType(MediaType.APPLICATION_JSON);
|
|
mvc.perform(builder).andDo(MockMvcResultHandlers.print());
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|