forked from osopromadze/Spring-Boot-Blog-REST-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractTest.java
More file actions
35 lines (27 loc) · 1.14 KB
/
AbstractTest.java
File metadata and controls
35 lines (27 loc) · 1.14 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
package com.sopromadze.blogapi;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
import javax.annotation.PostConstruct;
import javax.servlet.Filter;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = BlogApiApplication.class)
@WebAppConfiguration
public abstract class AbstractTest {
protected MockMvc mvc;
@Autowired
protected WebApplicationContext webApplicationContext;
@Autowired
protected Filter springSecurityFilterChain;
@PostConstruct
protected void setUp() {
mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity(springSecurityFilterChain))
.build();
}
}