xmlparsernewssearchresultstest.java

来自「yahoo api,包括各版本的」· Java 代码 · 共 42 行

JAVA
42
字号
package com.yahoo.search.xmlparser;import com.yahoo.search.NewsSearchResults;import com.yahoo.XmlParserTestUtil;import junit.framework.TestCase;import java.math.BigInteger;public class XmlParserNewsSearchResultsTest extends TestCase {    public void testParseNewsSearchResults() throws Exception {        NewsSearchResults results = new XmlParserNewsSearchResults(XmlParserTestUtil.parseTest("/com/yahoo/search/xmlparser/newsSearch.xml"));        assertEquals(new BigInteger("1"), results.getFirstResultPosition());        assertEquals(new BigInteger("442"), results.getTotalResultsAvailable());        assertEquals(new BigInteger("10"), results.getTotalResultsReturned());        assertEquals(10, results.listResults().length);        assertEquals("Madonna Said to Owe Thousands in Fees", results.listResults()[0].getTitle());        assertEquals("A British director and several British companies involved in the creation of Madonna's European TV concert special have sued the singer, alleging she still owes more than $;300,000 in directing and production fees.", results.listResults()[0].getSummary());        assertEquals("http://news.yahoo.com/news?tmpl=story&u=/ap/20050422/ap_en_mu/people_madonna_4", results.listResults()[0].getUrl());        assertEquals("http://news.yahoo.com/news?tmpl=story&u=/ap/20050422/ap_en_mu/people_madonna_4", results.listResults()[0].getClickUrl());        assertEquals("AP via Yahoo! News", results.listResults()[0].getNewsSource());        assertEquals("http://news.yahoo.com/", results.listResults()[0].getNewsSourceUrl());        assertEquals("en", results.listResults()[0].getLanguage());        assertEquals("1114169993", results.listResults()[0].getPublishDate());        assertNull(results.listResults()[0].getModificationDate());        assertNull(results.listResults()[0].getThumbnail());        assertEquals("Billboard.com -- Madonna Sued Over Euro TV Show", results.listResults()[1].getTitle());        assertEquals("British director Hamish Hamilton and his companies filed suit Wednesday (April 20) against Madonna and her Tadpole Film Inc., seeking more than $330,000 in unpaid compensation and expenses related to the 2004 \"Re-Invention Tour.\"", results.listResults()[1].getSummary());        assertEquals("http://www.billboard.com/bb/yahoo/search/article_display.jsp?vnu_content_id=1000893569", results.listResults()[1].getUrl());        assertEquals("http://www.billboard.com/bb/yahoo/search/article_display.jsp?vnu_content_id=1000893569", results.listResults()[1].getClickUrl());        assertEquals("Billboard.com", results.listResults()[1].getNewsSource());        assertEquals("http://www.billboard.com/", results.listResults()[1].getNewsSourceUrl());        assertEquals("en", results.listResults()[1].getLanguage());        assertEquals("1114198497", results.listResults()[1].getPublishDate());        assertEquals("1114198500", results.listResults()[1].getModificationDate());        assertEquals("http://us.news2.yimg.com/us.yimg.com/p/ap/20050422/vsthumb.ny10704220235.britain_people_madonna_ny107.jpg", results.listResults()[1].getThumbnail().getUrl());        assertEquals(new BigInteger("81", 10), results.listResults()[1].getThumbnail().getHeight());        assertEquals(new BigInteger("61", 10), results.listResults()[1].getThumbnail().getWidth());    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?