package nicobrowser;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-import nicobrowser.entity.NicoContent;
-import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
+import nicobrowser.entity.NicoContent;
import nicobrowser.entity.NicoContent.Status;
import nicobrowser.search.SearchKind;
+import nicobrowser.search.SearchResult;
import nicobrowser.search.SortKind;
import nicobrowser.search.SortOrder;
-import nicobrowser.search.SearchResult;
import org.apache.http.HttpException;
import org.junit.After;
import org.junit.AfterClass;
+import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import static org.junit.Assert.*;
/**
*
assertTrue(commFile.exists());
assertTrue(tcommFile.exists());
}
+
+ /**
+ *
+ */
+ @Test
+ public void testGetTitleInWatchPageZero() throws NoSuchMethodException, IOException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException {
+ final String title = "【MMD】 WAVEFILE fullver. 【モーション完成】";
+ final Method m = NicoHttpClient.class.getDeclaredMethod("getTitleInWatchPage", InputStream.class);
+ m.setAccessible(true);
+
+ final FileInputStream fisHarajuku = new FileInputStream(new File("testdata/hara_watch.html"));
+ final String titleHarajuku = (String) m.invoke(instance, fisHarajuku);
+ fisHarajuku.close();
+ assertEquals(title, titleHarajuku);
+
+ final FileInputStream fisZero = new FileInputStream(new File("testdata/zero_watch.html"));
+ final String titleZero = (String) m.invoke(instance, fisZero);
+ fisZero.close();
+ assertEquals(title, titleZero);
+ }
}