Package org.apache.hadoop.hbase.http
Class HttpServerFunctionalTest
java.lang.Object
org.apache.hadoop.hbase.http.HttpServerFunctionalTest
- Direct Known Subclasses:
TestGlobalFilter
,TestHttpServer
,TestHttpServerLifecycle
,TestHttpServerWebapps
,TestJMXJsonServlet
,TestLdapHttpServer
,TestPathFilter
,TestProxyUserSpnegoHttpServer
,TestServletFilter
,TestSpnegoHttpServer
,TestSSLHttpServer
This is a base class for functional tests of the
HttpServer
. The methods are static for
other classes to import statically.-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
expected location of the test.build.webapps dir: "src/test/resources/webapps"private static final org.slf4j.Logger
private static final String
name of the test webapp: "test"static final String
JVM property for the webapp test dir : "test.build.webapps" -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
access a url, ignoring some IOException such as the page does not existstatic org.apache.hadoop.hbase.http.HttpServer
Create and start a server with the test webappstatic org.apache.hadoop.hbase.http.HttpServer
createServer
(String webapp) Create an HttpServer instance for the given webappstatic org.apache.hadoop.hbase.http.HttpServer
createServer
(String host, int port) Create an HttpServer instance on the given address for the given webappstatic org.apache.hadoop.hbase.http.HttpServer
createServer
(String webapp, org.apache.hadoop.conf.Configuration conf) Create an HttpServer instance for the given webappstatic org.apache.hadoop.hbase.http.HttpServer
createServer
(String webapp, org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) Create an HttpServer instance for the given webappstatic org.apache.hadoop.hbase.http.HttpServer
createServer
(String webapp, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl) static org.apache.hadoop.hbase.http.HttpServer
Create but do not start the test webapp server.static org.apache.hadoop.hbase.http.HttpServer
createTestServer
(org.apache.hadoop.conf.Configuration conf) Create but do not start the test webapp server.static org.apache.hadoop.hbase.http.HttpServer
createTestServer
(org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) Create but do not start the test webapp server.static org.apache.hadoop.hbase.http.HttpServer
createTestServer
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl) static org.apache.hadoop.hbase.http.HttpServer
createTestServerWithSecurity
(org.apache.hadoop.conf.Configuration conf) static org.apache.hadoop.hbase.http.HttpServer
createTestServerWithSecurityAndAcl
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList acl) protected static void
Recursively deletes aFile
.protected static int
Picks a free port on the host by binding a Socket to '0'.static URL
getServerURL
(org.apache.hadoop.hbase.http.HttpServer server) Pass in a server, return a URL bound to localhost and its portprivate static org.apache.hadoop.hbase.http.HttpServer.Builder
localServerBuilder
(String webapp) protected static void
Prepare the test webapp by creating the directory from the test properties fail if the directory cannot be created.protected static String
readOutput
(URL url) Read in the content from a URLstatic void
stop
(org.apache.hadoop.hbase.http.HttpServer server) If the server is non null, stop it
-
Field Details
-
LOG
-
TEST_BUILD_WEBAPPS
JVM property for the webapp test dir : "test.build.webapps"- See Also:
-
BUILD_WEBAPPS_DIR
expected location of the test.build.webapps dir: "src/test/resources/webapps"- See Also:
-
TEST
name of the test webapp: "test"- See Also:
-
-
Constructor Details
-
HttpServerFunctionalTest
public HttpServerFunctionalTest()
-
-
Method Details
-
createTestServer
Create but do not start the test webapp server. The test webapp dir is prepared/checked in advance.- Returns:
- the server instance
- Throws:
IOException
- if a problem occursAssertionError
- if a condition was not met
-
createTestServer
public static org.apache.hadoop.hbase.http.HttpServer createTestServer(org.apache.hadoop.conf.Configuration conf) throws IOException Create but do not start the test webapp server. The test webapp dir is prepared/checked in advance.- Parameters:
conf
- the server configuration to use- Returns:
- the server instance
- Throws:
IOException
- if a problem occursAssertionError
- if a condition was not met
-
createTestServer
public static org.apache.hadoop.hbase.http.HttpServer createTestServer(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl) throws IOException - Throws:
IOException
-
createTestServer
public static org.apache.hadoop.hbase.http.HttpServer createTestServer(org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) throws IOException Create but do not start the test webapp server. The test webapp dir is prepared/checked in advance.- Parameters:
conf
- the server configuration to use- Returns:
- the server instance
- Throws:
IOException
- if a problem occursAssertionError
- if a condition was not met
-
createTestServerWithSecurity
public static org.apache.hadoop.hbase.http.HttpServer createTestServerWithSecurity(org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
createTestServerWithSecurityAndAcl
public static org.apache.hadoop.hbase.http.HttpServer createTestServerWithSecurityAndAcl(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList acl) throws IOException - Throws:
IOException
-
prepareTestWebapp
Prepare the test webapp by creating the directory from the test properties fail if the directory cannot be created.- Throws:
IOException
- if an error occurredAssertionError
- if a condition was not met
-
createServer
public static org.apache.hadoop.hbase.http.HttpServer createServer(String host, int port) throws IOException Create an HttpServer instance on the given address for the given webapp- Parameters:
host
- to bindport
- to bind- Returns:
- the server
- Throws:
IOException
- if it could not be created
-
createServer
public static org.apache.hadoop.hbase.http.HttpServer createServer(String webapp) throws IOException Create an HttpServer instance for the given webapp- Parameters:
webapp
- the webapp to work with- Returns:
- the server
- Throws:
IOException
- if it could not be created
-
createServer
public static org.apache.hadoop.hbase.http.HttpServer createServer(String webapp, org.apache.hadoop.conf.Configuration conf) throws IOException Create an HttpServer instance for the given webapp- Parameters:
webapp
- the webapp to work withconf
- the configuration to use for the server- Returns:
- the server
- Throws:
IOException
- if it could not be created
-
createServer
public static org.apache.hadoop.hbase.http.HttpServer createServer(String webapp, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.AccessControlList adminsAcl) throws IOException - Throws:
IOException
-
localServerBuilder
-
createServer
public static org.apache.hadoop.hbase.http.HttpServer createServer(String webapp, org.apache.hadoop.conf.Configuration conf, String[] pathSpecs) throws IOException Create an HttpServer instance for the given webapp- Parameters:
webapp
- the webapp to work withconf
- the configuration to use for the serverpathSpecs
- the paths specifications the server will service- Returns:
- the server
- Throws:
IOException
- if it could not be created
-
createAndStartTestServer
Create and start a server with the test webapp- Returns:
- the newly started server
- Throws:
IOException
- on any failureAssertionError
- if a condition was not met
-
stop
If the server is non null, stop it- Parameters:
server
- to stop- Throws:
Exception
- on any failure
-
getServerURL
public static URL getServerURL(org.apache.hadoop.hbase.http.HttpServer server) throws MalformedURLException Pass in a server, return a URL bound to localhost and its port- Parameters:
server
- server- Returns:
- a URL bonded to the base of the server
- Throws:
MalformedURLException
- if the URL cannot be created.
-
readOutput
Read in the content from a URL- Parameters:
url
- URL To read- Returns:
- the text from the output
- Throws:
IOException
- if something went wrong
-
deleteRecursively
Recursively deletes aFile
. -
getFreePort
Picks a free port on the host by binding a Socket to '0'.- Throws:
IOException
-
access
access a url, ignoring some IOException such as the page does not exist- Throws:
IOException
-