public class MockApnsServer extends Object
A mock APNs server is an HTTP/2 server that can be configured to respond to APNs push notifications with a variety of behaviors. Mock servers are primarily useful for integration tests and benchmarks; users do not need to interact with mock servers as part of normal client operation.
Callers construct mock APNs servers with the MockApnsServerBuilder
class, and provide a
PushNotificationHandlerFactory
at construction time. The factory constructs PushNotificationHandler
instances that control how the server responds to push notifications. Pushy comes with a
ValidatingPushNotificationHandlerFactory
that constructs handlers that emulate the behavior of a real APNs
server (but do not actually deliver push notifications to destination devices) and an
AcceptAllPushNotificationHandlerFactory
that constructs handlers that unconditionally accept push
notifications. Additionally, callers may specify a MockApnsServerListener
that will be notified when
notifications are accepted or rejected by the server.
Modifier and Type | Method and Description |
---|---|
Future<Void> |
shutdown()
Shuts down this server and releases the port to which this server was bound.
|
Future<Void> |
start(int port)
Starts this mock server and listens for traffic on the given port.
|
public Future<Void> start(int port)
port
- the port to which this server should bindFuture
that will succeed when the server has bound to the given port and is ready to accept
trafficpublic Future<Void> shutdown()
Shuts down this server and releases the port to which this server was bound. If a null
event loop
group was provided at construction time, the server will also shut down its internally-managed event loop
group.
If a non-null EventLoopGroup
was provided at construction time, mock servers may be reconnected and
reused after they have been shut down. If no event loop group was provided at construction time, mock servers may
not be restarted after they have been shut down via this method.
Future
that will succeed once the server has finished unbinding from its port and, if the
server was managing its own event loop group, its event loop group has shut downCopyright © 2013–2018 Turo. All rights reserved.