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

public class HttpServerFunctionalTest extends Object
This is a base class for functional tests of the HttpServer. The methods are static for other classes to import statically.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    access(String urlstring)
    access a url, ignoring some IOException such as the page does not exist
    static org.apache.hadoop.hbase.http.HttpServer
    Create and start a server with the test webapp
    static org.apache.hadoop.hbase.http.HttpServer
    Create an HttpServer instance for the given webapp
    static org.apache.hadoop.hbase.http.HttpServer
    createServer(String host, int port)
    Create an HttpServer instance on the given address for the given webapp
    static org.apache.hadoop.hbase.http.HttpServer
    createServer(String webapp, org.apache.hadoop.conf.Configuration conf)
    Create an HttpServer instance for the given webapp
    static org.apache.hadoop.hbase.http.HttpServer
    createServer(String webapp, org.apache.hadoop.conf.Configuration conf, String[] pathSpecs)
    Create an HttpServer instance for the given webapp
    static 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 a File.
    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 port
    private static org.apache.hadoop.hbase.http.HttpServer.Builder
     
    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
    Read in the content from a URL
    static void
    stop(org.apache.hadoop.hbase.http.HttpServer server)
    If the server is non null, stop it

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • createTestServer

      public static org.apache.hadoop.hbase.http.HttpServer createTestServer() throws IOException
      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 occurs
      AssertionError - 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 occurs
      AssertionError - 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 occurs
      AssertionError - 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

      protected static void prepareTestWebapp() throws IOException
      Prepare the test webapp by creating the directory from the test properties fail if the directory cannot be created.
      Throws:
      IOException - if an error occurred
      AssertionError - 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 bind
      port - 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 with
      conf - 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

      private static org.apache.hadoop.hbase.http.HttpServer.Builder localServerBuilder(String webapp)
    • 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 with
      conf - the configuration to use for the server
      pathSpecs - the paths specifications the server will service
      Returns:
      the server
      Throws:
      IOException - if it could not be created
    • createAndStartTestServer

      public static org.apache.hadoop.hbase.http.HttpServer createAndStartTestServer() throws IOException
      Create and start a server with the test webapp
      Returns:
      the newly started server
      Throws:
      IOException - on any failure
      AssertionError - if a condition was not met
    • stop

      public static void stop(org.apache.hadoop.hbase.http.HttpServer server) throws Exception
      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

      protected static String readOutput(URL url) throws IOException
      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

      protected static void deleteRecursively(File d)
      Recursively deletes a File.
    • getFreePort

      protected static int getFreePort() throws IOException
      Picks a free port on the host by binding a Socket to '0'.
      Throws:
      IOException
    • access

      public static void access(String urlstring) throws IOException
      access a url, ignoring some IOException such as the page does not exist
      Throws:
      IOException