public class MockApnsServer extends Object
A mock APNs server emulates the behavior of a real APNs server (but doesn't actually deliver notifications to their destinations). Mock servers are primarily useful for integration tests and benchmarks; most users will not need to interact with mock servers.
Mock servers maintain a registry of tokens for a variety of topics. When first created, no tokens are registered
with a mock server, and all attempts to send notifications will fail until at least one token is registered via the
addToken(String, String, Date)
method.
Modifier and Type | Method and Description |
---|---|
void |
addToken(String topic,
String token,
Date expiration)
Registers a new token for a specific topic.
|
void |
clearTokens()
Unregisters all tokens from this server.
|
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 void addToken(String topic, String token, Date expiration)
topic
- the topic for which to register the given tokentoken
- the token to registerexpiration
- the time at which the token expires (or expired); may be null
, in which case the token
never expirespublic void clearTokens()
public 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–2016 Turo. All rights reserved.