添加运行日志处理,频率为每天对error和info级别的日志进行文件保存
实现判断注册用户名是否已存在
This commit is contained in:
23
src/test/java/com/fjy/spring/LoggerTest.java
Normal file
23
src/test/java/com/fjy/spring/LoggerTest.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.fjy.spring;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
public class LoggerTest {
|
||||
@Test
|
||||
public void test1(){
|
||||
String name ="fjy";
|
||||
String date = "2018-2-24";
|
||||
|
||||
log.debug("debug...");
|
||||
log.info("info...");
|
||||
log.info("name:{}, data:{}",name,date);
|
||||
log.error("error...");
|
||||
}
|
||||
}
|
||||
@@ -51,14 +51,26 @@ public class RegisterControllerTest {
|
||||
@Test
|
||||
public void doCheckStudent()throws Exception {
|
||||
//测试学号与姓名不匹配
|
||||
mvc.perform(MockMvcRequestBuilders.post("/CheckStudent")
|
||||
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
||||
.param("studentno","15251101238")
|
||||
.param("realname","符嘉"))
|
||||
.andExpect(MockMvcResultMatchers.content().string("false"));
|
||||
//测试学号与姓名匹配
|
||||
mvc.perform(MockMvcRequestBuilders.post("/CheckStudent")
|
||||
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
||||
.param("studentno","15251101238")
|
||||
.param("realname","符嘉阳"))
|
||||
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doUserName()throws Exception {
|
||||
//测试用户名已存在
|
||||
mvc.perform(MockMvcRequestBuilders.get("/CheckUserName")
|
||||
.param("name","root"))
|
||||
.andExpect(MockMvcResultMatchers.content().string("false"));
|
||||
//测试用户名不存在
|
||||
mvc.perform(MockMvcRequestBuilders.get("/CheckUserName")
|
||||
.param("name","root1"))
|
||||
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user