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 b81826bd484..a854690eb3f 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 @@ -18,25 +18,31 @@ package org.apache.hadoop.hbase.http; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.ServerSocket; import java.net.URI; import java.net.URL; - +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.http.HttpServer.Builder; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.authorize.AccessControlList; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is a base class for functional tests of the {@link HttpServer}. * The methods are static for other classes to import statically. */ public class HttpServerFunctionalTest extends Assert { + private static final Logger LOG = LoggerFactory.getLogger(HttpServerFunctionalTest.class); /** JVM property for the webapp test dir : {@value} */ public static final String TEST_BUILD_WEBAPPS = "test.build.webapps"; /** expected location of the test.build.webapps dir: {@value} */ @@ -270,4 +276,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(), StandardCharsets.UTF_8))){ + for(; in.readLine() != null;) { + continue; + } + } catch(IOException ioe) { + LOG.info("Got exception: ", ioe); + } + } + + } diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java index cb2a674d152..cb377cb2e45 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java @@ -17,11 +17,7 @@ */ package org.apache.hadoop.hbase.http; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; import java.util.Set; import java.util.TreeSet; import javax.servlet.Filter; @@ -89,27 +85,6 @@ public class TestGlobalFilter extends HttpServerFunctionalTest { } } - /** - * access a url, ignoring some IOException such as the page does not exist - */ - private static void access(String urlstring) throws IOException { - LOG.warn("access " + urlstring); - URL url = new URL(urlstring); - URLConnection connection = url.openConnection(); - connection.connect(); - - try { - try (BufferedReader in = new BufferedReader( - new InputStreamReader(connection.getInputStream(), "UTF-8"))) { - for (; in.readLine() != null; ) { - // Ignoring the content of the URLs. Only checking if something is there. - } - } - } catch(IOException ioe) { - LOG.warn("urlstring=" + urlstring, ioe); - } - } - @Test public void testServletFilter() throws Exception { Configuration conf = new Configuration(); 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 d8a5e647f64..1e0d5afc71b 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 @@ -17,11 +17,7 @@ */ package org.apache.hadoop.hbase.http; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; import java.util.Set; import java.util.TreeSet; import javax.servlet.Filter; @@ -89,28 +85,6 @@ public class TestPathFilter extends HttpServerFunctionalTest { } } - /** - * access a url, ignoring some IOException such as the page does not exist - */ - private static void access(String urlstring) throws IOException { - LOG.warn("access " + urlstring); - URL url = new URL(urlstring); - - URLConnection connection = url.openConnection(); - connection.connect(); - - try { - try (BufferedReader in = new BufferedReader( - new InputStreamReader(connection.getInputStream(), "UTF-8"))) { - for (; in.readLine() != null; ) { - // Ignoring the content of the URLs. Only checking if something is there. - } - } - } catch(IOException ioe) { - LOG.warn("urlstring=" + urlstring, ioe); - } - } - @Test public void testPathSpecFilters() throws Exception { Configuration conf = new Configuration(); 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 35c55319cae..ee035dda5b9 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 @@ -17,11 +17,7 @@ */ package org.apache.hadoop.hbase.http; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; import java.util.Random; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -97,27 +93,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 - */ - private static void access(String urlstring) throws IOException { - LOG.warn("access " + urlstring); - URL url = new URL(urlstring); - URLConnection connection = url.openConnection(); - connection.connect(); - - try { - try (BufferedReader in = new BufferedReader(new InputStreamReader( - connection.getInputStream(), "UTF-8"))) { - for (; in.readLine() != null; ) { - // Ignoring the content of the URLs. Only checking if something is there. - } - } - } catch(IOException ioe) { - LOG.warn("urlstring=" + urlstring, ioe); - } - } - @Test @Ignore //From stack