| | |
| | | import java.io.InputStreamReader; |
| | | |
| | | import com.yeshi.buwan.domain.AcFunTemporary; |
| | | import com.yeshi.buwan.job.VideoUpdateJob; |
| | | 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 { |
| | | |
| | | @org.junit.Test |
| | | public void test1() { |
| | | VideoUpdateJob videoUpdateJob = BeanUtil.getBean(VideoUpdateJob.class); |
| | | videoUpdateJob.updateAcFun(); |
| | | } |
| | | @Resource |
| | | private JuHeVideoUpdateJob juHeVideoUpdateJob; |
| | | |
| | | @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"); |
| | | @org.junit.Test |
| | | public void test1() { |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | @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(""); |
| | | } |
| | | |
| | | } |