实现文件上传和数据库记录、Element+vue登录注册UI
This commit is contained in:
@@ -28,12 +28,14 @@ public class LoginControllerTest {
|
||||
|
||||
@Test
|
||||
public void doLogin() throws Exception {
|
||||
//测试正常登录
|
||||
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "root"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
//测试密码错误
|
||||
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "123"))
|
||||
.andExpect(MockMvcResultMatchers.content().json("{\n" +
|
||||
" \"code\": 101,\n" +
|
||||
" \"message\": \"用户不存在\",\n" +
|
||||
" \"code\": 105,\n" +
|
||||
" \"message\": \"用户名或密码错误\",\n" +
|
||||
" \"data\": null\n" +
|
||||
"}"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.fjy.spring.controller;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
public class RegisterControllerTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mvc;
|
||||
|
||||
@Test
|
||||
public void doRegister()throws Exception {
|
||||
//测试正常注册,abc每次调试必须改,因为唯一约束
|
||||
mvc.perform(MockMvcRequestBuilders.post("/register/doregister")
|
||||
.param("colname", "abc")
|
||||
.param("colpassword", "123456")
|
||||
.param("colemail","test@gmail.com")
|
||||
.param("colstudentno","0003")
|
||||
.param("colrealname","TestRegister"))
|
||||
.andExpect(MockMvcResultMatchers.content().json("{\n" +
|
||||
" \"code\": 0,\n" +
|
||||
" \"message\": \"请求成功\",\n" +
|
||||
" \"data\": null\n" +
|
||||
"}"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user