admin
2022-01-28 cd7767932dddeaf6d9c73a83d4a9b38f0341b77f
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.hxh.spring.test;
 
import java.util.List;
 
import org.junit.Test;
 
import com.yeshi.buwan.dao.VideoInfoDao;
import com.yeshi.buwan.service.imp.StatisticsService;
import com.yeshi.buwan.util.BeanUtil;
import com.yeshi.buwan.util.news.SouGouParser;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
 
import javax.annotation.Resource;
 
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
public class StatisticTest {
    // @Test
    public void updateSouGou() {// SouGouParser
        SouGouParser souGouParser = (SouGouParser) BeanUtil.getBean("souGouParser");
        souGouParser.startParse();
    }
 
    // @Test
    public void refreshWatchCount() {
        StatisticsService statisticsService = (StatisticsService) BeanUtil.getBean("statisticsService");
        VideoInfoDao videoInfoDao = (VideoInfoDao) BeanUtil.getBean("videoInfoDao");
        for (int p = 2; p < 10; p++) {
            System.out.println("页码:" + p);
            List list = videoInfoDao.sqlList("select id from wk_video_video", (p - 1) * 10000, 10000, null);
            for (int j = 0; j < list.size(); j++) {
                statisticsService.refreshWatchCount(list.get(j) + "");
                statisticsService.refreshVideoCommentCount(list.get(j) + "");
                // statisticsService.refreshVideoDetailCount(list.get(j) + "");
            }
        }
    }
 
    // @Test
    public void refreshCommentCount() {
 
    }
 
 
    @Resource
    private StatisticsService statisticsService;
 
    @Test
    public void playStatistics() {
        statisticsService.categoryPlayStatistic();
    }
 
}