From 5f36fc21b0b0d2b4b313c5f3b17e2badb7496021 Mon Sep 17 00:00:00 2001 From: Xu Cang Date: Sun, 22 Jul 2018 22:11:08 -0700 Subject: [PATCH] HBASE-20782 Fix duplication of TestServletFilter.access --- .../hbase/http/HttpServerFunctionalTest.java | 24 ++++++++++++++++++++++ .../apache/hadoop/hbase/http/TestPathFilter.java | 19 ----------------- .../hadoop/hbase/http/TestServletFilter.java | 20 ------------------ 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java index 69972a2e12..a9f2568509 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java @@ -24,13 +24,16 @@ import org.junit.Assert; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.http.HttpServer.Builder; +import java.io.BufferedReader; import java.io.File; +import java.io.InputStreamReader; import java.io.IOException; import java.io.InputStream; import java.net.ServerSocket; import java.net.URI; import java.net.URL; import java.net.MalformedURLException; +import java.net.URLConnection; /** * This is a base class for functional tests of the {@link HttpServer}. @@ -269,4 +272,25 @@ public class HttpServerFunctionalTest extends Assert { } } } + + /** + * access a url, ignoring some IOException such as the page does not exist + */ + public static void access(String urlstring) throws IOException { + URL url = new URL(urlstring); + + URLConnection connection = url.openConnection(); + connection.connect(); + + try { + BufferedReader in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + try { + for(; in.readLine() != null; ); + } finally { + in.close(); + } + } catch(IOException ioe) { + } + } } diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java index 47e6ea26f1..dcaf0d2f68 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java @@ -90,26 +90,7 @@ public class TestPathFilter extends HttpServerFunctionalTest { } - /** access a url, ignoring some IOException such as the page does not exist */ - static void access(String urlstring) throws IOException { - LOG.warn("access " + urlstring); - URL url = new URL(urlstring); - URLConnection connection = url.openConnection(); - connection.connect(); - - try { - BufferedReader in = new BufferedReader(new InputStreamReader( - connection.getInputStream())); - try { - for(; in.readLine() != null; ); - } finally { - in.close(); - } - } catch(IOException ioe) { - LOG.warn("urlstring=" + urlstring, ioe); - } - } @Test public void testPathSpecFilters() throws Exception { diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java index 6c70dbc9d8..577404b601 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java @@ -97,26 +97,6 @@ public class TestServletFilter extends HttpServerFunctionalTest { + StringUtils.stringifyException(t), msg.contains(string)); } - /** access a url, ignoring some IOException such as the page does not exist */ - static void access(String urlstring) throws IOException { - LOG.warn("access " + urlstring); - URL url = new URL(urlstring); - URLConnection connection = url.openConnection(); - connection.connect(); - - try { - BufferedReader in = new BufferedReader(new InputStreamReader( - connection.getInputStream())); - try { - for(; in.readLine() != null; ); - } finally { - in.close(); - } - } catch(IOException ioe) { - LOG.warn("urlstring=" + urlstring, ioe); - } - } - @Test @Ignore //From stack -- 2.14.3 (Apple Git-98)