package com.hxh.spring.test.video;
|
|
|
import com.yeshi.buwan.domain.video.InternetSearchVideo;
|
import com.yeshi.buwan.job.video.YouKuVideoUpdate;
|
import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService;
|
import com.yeshi.buwan.service.inter.juhe.YouKuService;
|
import com.yeshi.buwan.util.factory.InternetSearchVideoFactory;
|
import com.yeshi.buwan.videos.youku.YouKuApiUtil;
|
import com.yeshi.buwan.videos.youku.entity.YouKuShowDetail;
|
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;
|
import java.util.List;
|
|
//
|
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
|
@ContextConfiguration(locations = {"classpath:spring.xml"})
|
@WebAppConfiguration
|
public class YouKuTest {
|
|
@Resource
|
private YouKuVideoUpdate youKuVideoUpdate;
|
|
@Resource
|
private InternetSearchVideoService internetSearchVideoService;
|
|
@Resource
|
private YouKuService youKuService;
|
|
@Test
|
public void test1() {
|
try {
|
youKuVideoUpdate.updateLatestVideo("fedf102940f74187909b");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
|
|
@Test
|
public void test2() {
|
List<YouKuShowDetail> details = youKuService.list("电影", 1, 2000);
|
for (YouKuShowDetail detail : details) {
|
try {
|
InternetSearchVideo video = InternetSearchVideoFactory.create(detail);
|
internetSearchVideoService.save(video);
|
} catch (Exception e) {
|
System.out.println(detail.getName() + ":" + detail.getId());
|
e.printStackTrace();
|
}
|
}
|
}
|
|
@Test
|
public void test3() {
|
try {
|
youKuVideoUpdate.updatebyCategoryUrl("https://www.youku.com/category/show/c_96_s_1.html?theme=dark");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void getDetail() {
|
YouKuShowDetail detail = YouKuApiUtil.getShowDetail("ceba4745ea10415eb791");
|
try {
|
youKuService.addToInternetSearch(detail);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
}
|