共用方式為


LocalTestServer Class

  • java.lang.Object
    • com.azure.core.test.http.LocalTestServer

public class LocalTestServer

Local server that will reply to requests based on the configured HttpServlet.

Constructor Summary

Constructor Description
LocalTestServer(LocalTestServer.RequestHandler requestHandler)

Creates a new instance of LocalTestServer that will reply to requests based on the passed RequestHandler.

LocalTestServer(LocalTestServer.RequestHandler requestHandler, int maxThreads)

Creates a new instance of LocalTestServer that will reply to requests based on the passed RequestHandler.

Method Summary

Modifier and Type Method and Description
int getHttpPort()

Gets the HTTP port that the local server is listening on.

String getHttpUri()

Gets the HTTP URI that the local server is listening on.

int getHttpsPort()

Gets the HTTPS port that the local server is listening on.

String getHttpsUri()

Gets the HTTPS URI that the local server is listening on.

void start()

Starts the local server.

void stop()

Stops the local server.

Methods inherited from java.lang.Object

Constructor Details

LocalTestServer

public LocalTestServer(LocalTestServer.RequestHandler requestHandler)

Creates a new instance of LocalTestServer that will reply to requests based on the passed RequestHandler.

Parameters:

requestHandler - The request handler that will be used to process requests.

LocalTestServer

public LocalTestServer(LocalTestServer.RequestHandler requestHandler, int maxThreads)

Creates a new instance of LocalTestServer that will reply to requests based on the passed RequestHandler.

Parameters:

requestHandler - The request handler that will be used to process requests.
maxThreads - The maximum number of threads that the server will use to process requests.

Method Details

getHttpPort

public int getHttpPort()

Gets the HTTP port that the local server is listening on.

Returns:

The HTTP port that the local server is listening on.

getHttpUri

public String getHttpUri()

Gets the HTTP URI that the local server is listening on.

Returns:

The HTTP URI that the local server is listening on.

getHttpsPort

public int getHttpsPort()

Gets the HTTPS port that the local server is listening on.

Returns:

The HTTPS port that the local server is listening on.

getHttpsUri

public String getHttpsUri()

Gets the HTTPS URI that the local server is listening on.

Returns:

The HTTPS URI that the local server is listening on.

start

public void start()

Starts the local server.

This must be called before any requests will be processed.

stop

public void stop()

Stops the local server.

This must be called to close any server resources.

Applies to