admin
2024-10-30 010ef2a907e66efd4702443c06cdd18f8a7ffa5b
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
58
59
60
61
62
63
64
65
66
67
68
69
package com.hxh.spring.test;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
 
import com.yeshi.buwan.domain.AcFunTemporary;
import com.yeshi.buwan.job.JuHeVideoUpdateJob;
import com.yeshi.buwan.service.imp.AcFunTemporaryService;
import com.yeshi.buwan.util.BeanUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.video.AcfunApiUtil;
import org.junit.Test;
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 AcfunTest {
 
    @Resource
    private JuHeVideoUpdateJob juHeVideoUpdateJob;
 
    @org.junit.Test
    public void test1() {
    }
 
    @org.junit.Test
    public void test2() {
        AcFunTemporaryService acFunTemporaryService =
                BeanUtil.getBean(AcFunTemporaryService.class);
        InputStreamReader isr = null;
        try {
            isr = new InputStreamReader(
                    new FileInputStream(new File("C:/Users/Administrator/Desktop/动态分类/myprint.log")), "UTF-8");
 
            BufferedReader br = new BufferedReader(isr);
            String lineTxt = null;
            while ((lineTxt = br.readLine()) != null) {
                if (!StringUtil.isNullOrEmpty(lineTxt)) {
                    StringBuffer buffer = new StringBuffer(lineTxt);
                    int p = buffer.indexOf("[INFO]");
                    AcFunTemporary act = new AcFunTemporary();
                    act.setJson(buffer.substring(p + 6).trim());
                    act.setIsConsume(false);
                    act.setErrorCount(0);
                    acFunTemporaryService.save(act);
                }
            }
            br.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
 
    @Test
    public void getVideoList() {
        AcfunApiUtil.videoList("");
    }
 
}