|
|
|
@@ -0,0 +1,95 @@ |
|
|
|
package com.iformall.service.test; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.service.WxBillSettleService; |
|
|
|
import com.iformall.service.WxCouponSendService; |
|
|
|
import com.iformall.service.WxLevelConfigService; |
|
|
|
import com.iformall.service.WxScoreRulesService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.apache.shiro.authc.UsernamePasswordToken; |
|
|
|
import org.apache.shiro.subject.Subject; |
|
|
|
import org.apache.shiro.util.ThreadContext; |
|
|
|
import org.apache.shiro.web.subject.WebSubject; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.FixMethodOrder; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.junit.runners.MethodSorters; |
|
|
|
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.mock.web.MockHttpServletRequest; |
|
|
|
import org.springframework.mock.web.MockHttpServletResponse; |
|
|
|
import org.springframework.mock.web.MockHttpSession; |
|
|
|
import org.springframework.test.context.ActiveProfiles; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
import org.springframework.test.web.servlet.MockMvc; |
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@AutoConfigureMockMvc |
|
|
|
@FixMethodOrder(MethodSorters.JVM) |
|
|
|
@ActiveProfiles("dev") |
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
@SpringBootTest |
|
|
|
public class Test { |
|
|
|
|
|
|
|
private static final String TENANT_ID = "456"; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private org.apache.shiro.mgt.SecurityManager securityManager; |
|
|
|
@Resource |
|
|
|
private WebApplicationContext webApplicationContext; |
|
|
|
private MockHttpServletRequest mockHttpServletRequest; |
|
|
|
private MockHttpServletResponse mockHttpServletResponse; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxLevelConfigService levelConfigService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponSendService wxCouponSendService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxScoreRulesService wxScoreRulesService ; |
|
|
|
|
|
|
|
private MockMvc mockMvc; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxBillSettleService wxBillSettleService; |
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
public void setUp() { |
|
|
|
mockHttpServletRequest = new MockHttpServletRequest(webApplicationContext.getServletContext()); |
|
|
|
mockHttpServletResponse = new MockHttpServletResponse(); |
|
|
|
MockHttpSession mockHttpSession = new MockHttpSession(webApplicationContext.getServletContext()); |
|
|
|
mockHttpServletRequest.setSession(mockHttpSession); |
|
|
|
SecurityUtils.setSecurityManager(securityManager); |
|
|
|
mockMvc = MockMvcBuilders |
|
|
|
.webAppContextSetup(webApplicationContext) |
|
|
|
.build(); |
|
|
|
login("yftest", "123456zz"); |
|
|
|
} |
|
|
|
|
|
|
|
private void login(String username, String password) { |
|
|
|
Subject subject = new WebSubject.Builder(mockHttpServletRequest, mockHttpServletResponse) |
|
|
|
.buildWebSubject(); |
|
|
|
UsernamePasswordToken token = new UsernamePasswordToken(username, password, true); |
|
|
|
subject.login(token); |
|
|
|
ThreadContext.bind(subject); |
|
|
|
} |
|
|
|
|
|
|
|
@org.junit.Test |
|
|
|
public void levelList() { |
|
|
|
WxBillSettle settle = wxBillSettleService.getById(328411851323572224l); |
|
|
|
log.debug("data:{}", JSON.toJSONString(settle)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |