?? xmlparserwebsearchresultstest.java
字號:
package com.yahoo.search.xmlparser;import com.yahoo.search.WebSearchResults;import com.yahoo.XmlParserTestUtil;import junit.framework.TestCase;import java.math.BigInteger;public class XmlParserWebSearchResultsTest extends TestCase { public void testParseWebSearchResults() throws Exception { WebSearchResults results = new XmlParserWebSearchResults(XmlParserTestUtil.parseTest("/com/yahoo/search/xmlparser/webSearch.xml")); assertEquals(new BigInteger("1"), results.getFirstResultPosition()); assertEquals(new BigInteger("4952325"), results.getTotalResultsAvailable()); assertEquals(new BigInteger("10"), results.getTotalResultsReturned()); assertEquals(10, results.listResults().length); assertEquals("Madonna", results.listResults()[0].getTitle()); assertEquals("official site, with news, music, media, and fan club. Includes information on Madonna's 2004 Re-Invention tour.", results.listResults()[0].getSummary()); assertEquals("http://home.madonna.com/", results.listResults()[0].getUrl()); assertEquals("http://rds.yahoo.com/S=96857362/K=madonna/v=2/XP=yws/SID=e/l=WS1/R=1/H=1/IPC=us/SHE=0/SIG=11cloopi8/EXP=1114303092/*-http%3A//home.madonna.com/", results.listResults()[0].getClickUrl()); assertNull(results.listResults()[0].getModificationDate()); assertNull(results.listResults()[0].getMimeType()); assertNull(results.listResults()[0].getCache()); assertEquals("MTV.com: Madonna", results.listResults()[1].getTitle()); assertEquals("Madonna profile page, featuring news, video and audio, photo gallery, and biography.", results.listResults()[1].getSummary()); assertEquals("http://www.mtv.com/bands/az/madonna/artist.jhtml", results.listResults()[1].getUrl()); assertEquals("http://rds.yahoo.com/S=96857362/K=madonna/v=2/XP=yws/SID=e/l=WS1/R=2/SS=96305700/H=1/IPC=us/SHE=0/SIG=124ski7bm/EXP=1114303092/*-http%3A//www.mtv.com/bands/az/madonna/artist.jhtml", results.listResults()[1].getClickUrl()); assertEquals("1114153200", results.listResults()[1].getModificationDate()); assertEquals("text/html", results.listResults()[1].getMimeType()); assertEquals("http://rds.yahoo.com/S=96857362/K=madonna/v=2/XP=yws/SID=e/l=WS5/R=2/SIG=15ppq1693/EXP=1114303092/*-http%3A//216.109.117.135/search/cache?ei=UTF-8&eo=UTF-8&ac=0&n=10&b=1&va=madonna&vm=r&u=www.mtv.com/bands/az/madonna/artist.jhtml&w=madonna&d=090AFFB09F&icp=1&.intl=us", results.listResults()[1].getCache().getUrl()); assertEquals("78898", results.listResults()[1].getCache().getSize()); } public void testParseZeroWebSearchResults() throws Exception { WebSearchResults results = new XmlParserWebSearchResults(XmlParserTestUtil.parseTest("/com/yahoo/search/xmlparser/webSearch-noresults.xml")); assertEquals(new BigInteger("1"), results.getFirstResultPosition()); assertEquals(new BigInteger("0"), results.getTotalResultsAvailable()); assertEquals(new BigInteger("0"), results.getTotalResultsReturned()); assertEquals(0, results.listResults().length); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -