Class MockApnsServer
- java.lang.Object
-
- com.eatthepath.pushy.apns.server.MockApnsServer
-
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
MockApnsServerBuilderclass, and provide aPushNotificationHandlerFactoryat construction time. The factory constructsPushNotificationHandlerinstances that control how the server responds to push notifications. Pushy comes with aValidatingPushNotificationHandlerFactorythat constructs handlers that emulate the behavior of a real APNs server (but do not actually deliver push notifications to destination devices) and anAcceptAllPushNotificationHandlerFactorythat constructs handlers that unconditionally accept push notifications. Additionally, callers may specify aMockApnsServerListenerthat will be notified when notifications are accepted or rejected by the server.- Since:
- 0.8
- Author:
- Jon Chambers
-
-
Method Detail
-
start
public Future<Void> start(int port)
Starts this mock server and listens for traffic on the given port.- Parameters:
port- the port to which this server should bind- Returns:
- a
Futurethat will succeed when the server has bound to the given port and is ready to accept traffic
-
shutdown
public Future<Void> shutdown()
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.- Returns:
- a
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
-
-