You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ja...@apache.org on 2019/05/27 21:52:16 UTC
[hbase] branch branch-2 updated: HBASE-20782 Fix duplication of
TestServletFilter.access
This is an automated email from the ASF dual-hosted git repository.
janh pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 9a89ea5 HBASE-20782 Fix duplication of TestServletFilter.access
9a89ea5 is described below
commit 9a89ea53d2ca9b2d2ff96faa4b2ca6474f8f3e41
Author: Xu Cang <xu...@apache.org>
AuthorDate: Fri May 24 14:18:16 2019 -0700
HBASE-20782 Fix duplication of TestServletFilter.access
Signed-off-by: Jan Hentschel <ja...@ultratendency.com>
---
.../hbase/http/HttpServerFunctionalTest.java | 29 +++++++++++++++++++++-
.../apache/hadoop/hbase/http/TestGlobalFilter.java | 25 -------------------
.../apache/hadoop/hbase/http/TestPathFilter.java | 26 -------------------
.../hadoop/hbase/http/TestServletFilter.java | 25 -------------------
4 files changed, 28 insertions(+), 77 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 b81826b..a854690 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 cb2a674..cb377cb 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 d8a5e64..1e0d5af 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 35c5531..ee035dd 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