Author: mattmann Date: Fri Dec 18 19:01:23 2009 New Revision: 892350 URL: http://svn.apache.org/viewvc?rev=892350&view=rev Log: - fix for NUTCH-777 Upgrading to jetty6 broke unit tests
Modified: lucene/nutch/trunk/CHANGES.txt lucene/nutch/trunk/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java lucene/nutch/trunk/src/test/org/apache/nutch/crawl/CrawlDBTestUtil.java lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java Modified: lucene/nutch/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/CHANGES.txt?rev=892350&r1=892349&r2=892350&view=diff ============================================================================== --- lucene/nutch/trunk/CHANGES.txt (original) +++ lucene/nutch/trunk/CHANGES.txt Fri Dec 18 19:01:23 2009 @@ -2,6 +2,8 @@ Unreleased Changes +* NUTCH-777 Upgrading to jetty6 broke unit tests (mattmann) + * NUTCH-767 Update Tika to v0.5 for the MimeType detection (Julien Nioche via ab) * NUTCH-769 Fetcher to skip queues for URLS getting repeated exceptions Modified: lucene/nutch/trunk/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java?rev=892350&r1=892349&r2=892350&view=diff ============================================================================== --- lucene/nutch/trunk/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java (original) +++ lucene/nutch/trunk/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java Fri Dec 18 19:01:23 2009 @@ -21,10 +21,11 @@ import java.net.MalformedURLException; import junit.framework.TestCase; import org.mortbay.jetty.Server; -import org.mortbay.jetty.servlet.ServletHttpContext; +import org.mortbay.jetty.bio.SocketConnector; +import org.mortbay.jetty.handler.ContextHandler; +import org.mortbay.jetty.handler.ResourceHandler; import org.mortbay.jetty.servlet.ServletHandler; -import org.mortbay.http.SocketListener; -import org.mortbay.http.handler.ResourceHandler; +import org.mortbay.jetty.servlet.SessionHandler; import org.apache.hadoop.conf.Configuration; import org.apache.nutch.crawl.CrawlDatum; import org.apache.nutch.net.protocols.Response; @@ -44,14 +45,16 @@ protected void setUp() throws Exception { - ServletHttpContext context = new ServletHttpContext(); + ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setResourceBase(RES_DIR); - context.addServlet("JSP", "*.jsp", "org.apache.jasper.servlet.JspServlet"); - context.addHandler(new ResourceHandler()); + ServletHandler sh = new ServletHandler(); + sh.addServlet("org.apache.jasper.servlet.JspServlet", "*.jsp"); + context.addHandler(sh); + context.addHandler(new SessionHandler()); server = new Server(); - server.addContext(context); + server.addHandler(context); conf = new Configuration(); conf.addResource("nutch-default.xml"); @@ -152,10 +155,10 @@ */ private void startServer(int portno) throws Exception { port = portno; - SocketListener listener = new SocketListener(); + SocketConnector listener = new SocketConnector(); listener.setHost("127.0.0.1"); listener.setPort(port); - server.addListener(listener); + server.addConnector(listener); server.start(); } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/crawl/CrawlDBTestUtil.java URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/test/org/apache/nutch/crawl/CrawlDBTestUtil.java?rev=892350&r1=892349&r2=892350&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/crawl/CrawlDBTestUtil.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/crawl/CrawlDBTestUtil.java Fri Dec 18 19:01:23 2009 @@ -16,7 +16,6 @@ */ package org.apache.nutch.crawl; -import java.io.File; import java.io.IOException; import java.net.UnknownHostException; import java.util.Iterator; @@ -30,10 +29,12 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.MapFile; import org.apache.hadoop.io.Text; -import org.mortbay.http.HttpContext; -import org.mortbay.http.SocketListener; -import org.mortbay.http.handler.ResourceHandler; + import org.mortbay.jetty.Server; +import org.mortbay.jetty.bio.SocketConnector; +import org.mortbay.jetty.handler.ContextHandler; +import org.mortbay.jetty.handler.ResourceHandler; + public class CrawlDBTestUtil { @@ -131,15 +132,15 @@ */ public static Server getServer(int port, String staticContent) throws UnknownHostException{ Server webServer = new org.mortbay.jetty.Server(); - SocketListener listener = new SocketListener(); + SocketConnector listener = new SocketConnector(); listener.setPort(port); listener.setHost("127.0.0.1"); - webServer.addListener(listener); - HttpContext staticContext = new HttpContext(); + webServer.addConnector(listener); + ContextHandler staticContext = new ContextHandler(); staticContext.setContextPath("/"); staticContext.setResourceBase(staticContent); staticContext.addHandler(new ResourceHandler()); - webServer.addContext(staticContext); + webServer.addHandler(staticContext); return webServer; } } Modified: lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java?rev=892350&r1=892349&r2=892350&view=diff ============================================================================== --- lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java (original) +++ lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java Fri Dec 18 19:01:23 2009 @@ -67,7 +67,7 @@ server.start(); } - protected void tearDown() throws InterruptedException, IOException{ + protected void tearDown() throws Exception{ server.stop(); fs.delete(testdir, true); } @@ -164,7 +164,7 @@ } private void addUrl(ArrayList<String> urls, String page) { - urls.add("http://127.0.0.1:" + server.getListeners()[0].getPort() + "/" + page); + urls.add("http://127.0.0.1:" + server.getConnectors()[0].getPort() + "/" + page); } public void testAgentNameCheck() {