import akka.actor.ActorRef;
import akka.actor.ActorSystem;
-import akka.testkit.JavaTestKit;
import akka.testkit.TestProbe;
+import akka.testkit.javadsl.TestKit;
import com.google.common.collect.Iterables;
import java.util.Optional;
import java.util.function.Consumer;
protected TestProbe replyToProbe;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MockitoAnnotations.initMocks(this);
system = ActorSystem.apply();
backendProbe = new TestProbe(system);
contextProbe = new TestProbe(system);
- context = new ClientActorContext(contextProbe.ref(), system.scheduler(), system.dispatcher(),
- PERSISTENCE_ID, CLIENT_ID);
+ context = new ClientActorContext(contextProbe.ref(), PERSISTENCE_ID, system,
+ CLIENT_ID, AccessClientUtil.newMockClientActorConfig());
replyToProbe = new TestProbe(system);
connection = createConnection();
}
protected abstract T createConnection();
@Test
- public void testLocalActor() throws Exception {
+ public void testLocalActor() {
Assert.assertEquals(contextProbe.ref(), connection.localActor());
}
@Test
- public abstract void testReconnectConnection() throws Exception;
+ public abstract void testReconnectConnection();
@Test
- public void testPoison() throws Exception {
+ public void testPoison() {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request = createRequest(replyToProbe.ref());
final ConnectionEntry entry = new ConnectionEntry(request, callback, 0L);
}
@Test
- public void testSendRequestReceiveResponse() throws Exception {
+ public void testSendRequestReceiveResponse() {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request = createRequest(replyToProbe.ref());
connection.sendRequest(request, callback);
}
@Test
- public void testRun() throws Exception {
+ public void testRun() {
final ClientActorBehavior<U> behavior = mock(ClientActorBehavior.class);
Assert.assertSame(behavior, connection.runTimer(behavior));
}
@Test
- public void testCheckTimeoutEmptyQueue() throws Exception {
+ public void testCheckTimeoutEmptyQueue() {
final Optional<Long> timeout = connection.checkTimeout(context.ticker().read());
Assert.assertFalse(timeout.isPresent());
}
@Test
- public void testCheckTimeoutConnectionTimeouted() throws Exception {
- final Consumer<Response<?, ?>> callback = mock(Consumer.class);
- connection.sendRequest(createRequest(replyToProbe.ref()), callback);
- final long now = context.ticker().read() + ConnectedClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS;
- final Optional<Long> timeout = connection.checkTimeout(now);
- Assert.assertNull(timeout);
- }
-
- @Test
- public void testCheckTimeout() throws Exception {
+ public void testCheckTimeout() {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
connection.sendRequest(createRequest(replyToProbe.ref()), callback);
final long now = context.ticker().read();
}
@Test
- public void testReplay() throws Exception {
+ public void testReplay() {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request1 = createRequest(replyToProbe.ref());
final Request<?, ?> request2 = createRequest(replyToProbe.ref());
}
@After
- public void tearDown() throws Exception {
- JavaTestKit.shutdownActorSystem(system);
+ public void tearDown() {
+ TestKit.shutdownActorSystem(system);
}
protected Request<?, ?> createRequest(final ActorRef replyTo) {
return new AbortLocalTransactionRequest(identifier, replyTo);
}
-}
\ No newline at end of file
+}