HBASE-20782 Fix duplication of TestServletFilter.access
Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
This commit is contained in:
parent
71a1cd83fc
commit
9a89ea53d2
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue