ValhallaAppTests.java
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cn.fw.valhalla;
import cn.fw.common.util.ValidationUtils;
import org.junit.jupiter.api.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.result.MockMvcResultHandlers;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ValhallaApplication.class})
@AutoConfigureMockMvc
class ValhallaAppTests {
private final MockMvc mvc;
@Autowired
ValhallaAppTests(final MockMvc mvc) {
this.mvc = mvc;
}
@Test
public void exampleTest() throws Exception {
this.mvc.perform(
get("/app/accident/demo")
.header("Authorization", "4B70342B7CC9709C7D76A982217570ADB407D23ECDC0763C4AD3F5D069B8DEB33C5FCE9E493D9F6DE05D532E7A8B5DD1")
.param("val", "12345"))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
}
@Test
public void phoneTest() {
String phone = "+8619142820251";
System.out.println(ValidationUtils.checkMobile(phone));
}
}