96 lines
3.8 KiB
Java
96 lines
3.8 KiB
Java
import android.app.Application;
|
|
|
|
import com.github.catvod.spider.Init;
|
|
import com.github.catvod.spider.QxiTv;
|
|
import com.github.catvod.spider.W55Movie;
|
|
import com.github.catvod.utils.Json;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.GsonBuilder;
|
|
import com.google.gson.JsonObject;
|
|
|
|
import org.junit.Assert;
|
|
import org.junit.runner.RunWith;
|
|
import org.robolectric.RobolectricTestRunner;
|
|
import org.robolectric.RuntimeEnvironment;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
|
|
@RunWith(RobolectricTestRunner.class)
|
|
public class W55MovieTest {
|
|
// @Mock
|
|
private Application mockContext;
|
|
|
|
private W55Movie spider;
|
|
|
|
@org.junit.Before
|
|
public void setUp() throws Exception {
|
|
mockContext = RuntimeEnvironment.application;
|
|
Init.init(mockContext);
|
|
spider = new W55Movie();
|
|
spider.init(mockContext, "https://w55xy.com/");
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void homeContent() throws Exception {
|
|
String content = spider.homeContent(true);
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
|
|
System.out.println("homeContent--" + gson.toJson(map));
|
|
|
|
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void homeVideoContent() throws Exception {
|
|
String content = spider.homeVideoContent();
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
|
|
System.out.println("homeVideoContent--" + gson.toJson(map));
|
|
|
|
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void categoryContent() throws Exception {
|
|
String content = spider.categoryContent("/vodshow/1", "2", true, null);
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
System.out.println("categoryContent--" + gson.toJson(map));
|
|
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void detailContent() throws Exception {
|
|
|
|
String content = spider.detailContent(Arrays.asList("489833.html"));
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
System.out.println("detailContent--" + gson.toJson(map));
|
|
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void playerContent() throws Exception {
|
|
String froms = "极速线路11$$$极速线路31$$$极速线路41$$$备用高清11$$$备用高清21$$$极速线路21$$$蓝光专享31$$$蓝光专享51$$$555蓝光1$$$蓝光专享41";
|
|
String urls = "HD中字$472585-2-1.html$$$正片$472585-7-1.html$$$HD$472585-3-1.html$$$HD$472585-4-1.html$$$正片$472585-6-1.html$$$HD$472585-5-1.html$$$正片$472585-8-1.html$$$正片$472585-10-1.html$$$预告片$472585-1-1.html$$$正片$472585-9-1.html";
|
|
for (int i = 0; i < urls.split("\\$\\$\\$").length; i++) {
|
|
String content = spider.playerContent(froms.split("\\$\\$\\$")[i], urls.split("\\$\\$\\$")[i].split("\\$")[1], new ArrayList<>());
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
System.out.println("playerContent--" + gson.toJson(map));
|
|
Assert.assertFalse(map.getAsJsonPrimitive("url").getAsString().isEmpty());
|
|
}
|
|
}
|
|
|
|
@org.junit.Test
|
|
public void searchContent() throws Exception {
|
|
String content = spider.searchContent("红海", false);
|
|
JsonObject map = Json.safeObject(content);
|
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
System.out.println("searchContent--" + gson.toJson(map));
|
|
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
|
}
|
|
} |