Package com.xebialabs.restito.server
Class StubServer
java.lang.Object
com.xebialabs.restito.server.StubServer
The HttpServer wrapper which is responsible for operations like starting and stopping and holding objects that describe server behavior.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
boolean
Whether the server should run in HTTPS mode. -
Constructor Summary
ConstructorsConstructorDescriptionStubServer
(int portRangeStart, int portRangeEnd, Stub... stubs) This constructor allows to specify the port range beside stubs.StubServer
(int port, Stub... stubs) This constructor allows to specify the port beside stubs.StubServer
(Stub... stubs) Creates a server based on stubs that are used to determine behavior. -
Method Summary
Modifier and TypeMethodDescriptionIt is possible to add a stub even after the server is startedclear()
Clears the server state.Removes any registered stubs calls.Removes any previously registered stubs.clientAuth
(byte[] trustStore, String trustStorePass) Sets the Server to require client authentication (implies Secure mode).getCalls()
Returns calls performed to the server.int
getPort()
Returns the port which the server is running atgetStubs()
Returns stubs associated with the server.boolean
Defines whether stubs calls will be registered or not.run()
Starts the serversecured()
Sets the Server in Secure mode.void
setRegisterCalls
(boolean registerCalls) Defines whether stubs calls will be registered or not.void
start()
Alias for StubServer.run()stop()
Stops the server
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
secured
public boolean securedWhether the server should run in HTTPS mode.
-
-
Constructor Details
-
StubServer
Creates a server based on stubs that are used to determine behavior. -
StubServer
This constructor allows to specify the port range beside stubs. Grizzly will select the first available port. -
StubServer
This constructor allows to specify the port beside stubs. If the port is busy, Restito won't try to pick different one and java.net.BindException will be thrown.
-
-
Method Details
-
addStub
It is possible to add a stub even after the server is started -
clearStubs
Removes any previously registered stubs. -
clearCalls
Removes any registered stubs calls. -
clear
Clears the server state. -
isRegisterCalls
public boolean isRegisterCalls()Defines whether stubs calls will be registered or not.- Returns:
- current flag value
-
setRegisterCalls
public void setRegisterCalls(boolean registerCalls) Defines whether stubs calls will be registered or not.- Parameters:
registerCalls
- new flag value
-
run
Starts the server -
start
public void start()Alias for StubServer.run() -
stop
Stops the server -
secured
Sets the Server in Secure mode. If it is already running, ignores the call. -
clientAuth
Sets the Server to require client authentication (implies Secure mode). If it is already running, ignores the call. -
getPort
public int getPort()Returns the port which the server is running at -
getCalls
Returns calls performed to the server. Returned list is actually a copy of the original one. This is done to prevent concurrency issues. See #33. -
getStubs
Returns stubs associated with the server. Returned list is actually a copy of the original one. This is done to prevent concurrency issues. See #33.
-