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
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.
- Jon Chambers
startStarts this mock server and listens for traffic on the given port.
port- the port to which this server should bind; callers may pass
0to bind to the first available port
- a future that returns the bound port when the server has started and is ready to accept traffic
Shuts down this server and releases the port to which this server was bound. If a
nullevent loop group was provided at construction time, the server will also shut down its internally-managed event loop group.
If a non-null
EventLoopGroupwas 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.
Futurethat 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 down