Package test.wo

Source Code of test.wo.TestVideoService

package test.wo;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.skyline.wo.model.Video;
import com.skyline.wo.service.VideoService;

public class TestVideoService {
  private static VideoService videoService;
  //@BeforeClass
  public static void before() {
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
        "config/context/applicationContext.xml");
    videoService = (VideoService) ctx.getBean("videoService");
    //photoDao = (PhotoDao) ctx.getBean("photoDao");
  }

  //@Test
  public void testAdd(){
    videoService.addVideo(1l, "ownerPortrait", "ownerNickname", "title", "thumbnail", "summary", "time", "source", "pageUrl", "flashUrl", "htmlCode");
    //ownerPortrait, ownerNickname, title, thumbnail, summary, time, source, pageUrl, flashUrl, htmlCode)
  }
 
  //@Test
  public void testQueryById(){
    Video video=videoService.getVideoById(2l);
    System.out.println(video.getTitle());
  }
 
  @Test
  public void testReplice(){
    String str="<embed src=\"http://player.youku.com/player.php/sid/XMzE1ODg0NzUy/v.swf\" allowfullscreen=\"true\" quality=\"high\" width=\"480\" height=\"400\" align=\"middle\" allowscriptaccess=\"always\" type=\"application/x-shockwave-flash\">";
  System.out.println(str.replaceAll("\"","\'"));
  }
 
  //@Test
  public void testGetVideoInfo(){
    String[] urls={
        "http://www.tudou.com/programs/view/PXN70lSxn7c/",
        "http://www.tudou.com/programs/view/9Q_afZH3wkg/",
        "http://www.tudou.com/programs/view/arwuiSKzu7E/",
        "http://www.tudou.com/playlist/p/l13990759.html",
        "http://www.tudou.com/playlist/p/l13986923.html",
        "http://www.tudou.com/playlist/p/a66967i107643933.html",
        "http://www.tudou.com/playlist/p/l11202082i107640441.html",
        "http://www.tudou.com/programs/view/BfZ5RZbatgE/",
        "http://www.tudou.com/playlist/p/l12547099i107575744.html",
        "http://www.tudou.com/playlist/p/l13990449.html",
        "http://www.tudou.com/playlist/p/l13991466.html",
        "http://www.tudou.com/programs/view/ixXkWHiSDLk/",
        "http://www.tudou.com/programs/view/G4PlLuWXxVI/",
        "http://6.cn/watch/14757577.html",
        "http://v.youku.com/v_show/id_XMzE1NjI1Njc2.html",
        "http://v.youku.com/v_show/id_XMzE1ODkwOTE2.html",
        "http://v.youku.com/v_playlist/f16497456o1p0.html",
        "http://v.youku.com/v_playlist/f16570114o1p0.html",
        "http://v.youku.com/v_show/id_XMzE1ODc2OTY4.html",
        };
    for(String url:urls){
      try {
        Video video=videoService.queryVideoInfo(url);
        System.out.println("出处:\t"+video.getSource());
        System.out.println("标题:\t"+video.getTitle());
        System.out.println("片长:\t"+video.getTime());
        System.out.println("缩略图:\t"+video.getThumbnail());
        System.out.println("flash地址:\t"+video.getFlashUrl());
        System.out.println("html代码:\t"+video.getHtmlCode());
        System.out.println("链接:\t"+video.getPageUrl());
        System.out.println("简介:\t"+video.getSummary());
        System.out.println("==========================");
      } catch (Exception e) {
        //e.printStackTrace();
        System.out.println(url);
      }
    }
  }
}
TOP

Related Classes of test.wo.TestVideoService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.