public class AppServer extends Object
Tests should start the server in their setUp()
method and stop the
server in their tearDown()
method. Only while started the server's
URL and/or port number can be obtained.
Modifier and Type | Field and Description |
---|---|
static String |
password
Password for
username in secured access areas. |
static String |
realm
Realm name for the secure access areas.
|
static String |
username
Username for secured access areas.
|
Constructor and Description |
---|
AppServer()
Constructor for
AppServer . |
AppServer(int port)
Constructor for
AppServer . |
AppServer(int port,
int sslPort)
Constructor for
AppServer . |
Modifier and Type | Method and Description |
---|---|
org.eclipse.jetty.servlet.ServletContextHandler |
addContext(String path)
Create a new servlet context within the server.
|
org.eclipse.jetty.servlet.ServletContextHandler |
authBasic(org.eclipse.jetty.servlet.ServletContextHandler ctx,
String... methods)
Configure basic authentication.
|
int |
getPort()
Get port.
|
List<AccessEvent> |
getRequests()
Get requests.
|
List<AccessEvent> |
getRequests(String path)
Get requests.
|
List<AccessEvent> |
getRequests(URIish base,
String path)
Get requests.
|
int |
getSecurePort()
Get secure port.
|
URI |
getURI()
Get the URI to reference this server.
|
void |
setUp()
Start the server on a random local port.
|
void |
tearDown()
Shutdown the server.
|
public static final String realm
public static final String username
public static final String password
username
in secured access areas.public AppServer()
AppServer
.public AppServer(int port)
AppServer
.port
- the http port number; may be zero to allocate a port
dynamicallypublic AppServer(int port, int sslPort)
AppServer
.port
- for http, may be zero to allocate a port dynamicallysslPort
- for https,may be zero to allocate a port dynamically. If
negative, the server will be set up without https support.public org.eclipse.jetty.servlet.ServletContextHandler addContext(String path)
This method should be invoked before the server is started, once for each context the caller wants to register.
path
- path of the context; use "/" for the root context if binding
to the root is desired.public org.eclipse.jetty.servlet.ServletContextHandler authBasic(org.eclipse.jetty.servlet.ServletContextHandler ctx, String... methods)
ctx
- methods
- public void setUp() throws Exception
Exception
- the server cannot be started, testing is not possible.public void tearDown() throws Exception
Exception
- the server refuses to halt, or wasn't running.public URI getURI()
The returned URI includes the proper host name and port number, but does not contain a path.
public int getPort()
public int getSecurePort()
public List<AccessEvent> getRequests()
public List<AccessEvent> getRequests(URIish base, String path)
base
- base URI used to access the server.path
- the path to locate requests for, relative to base
.public List<AccessEvent> getRequests(String path)
path
- the path to locate requests for.Copyright © 2019 Eclipse JGit Project. All rights reserved.