import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
-import akka.testkit.JavaTestKit;
import akka.testkit.TestProbe;
+import akka.testkit.javadsl.TestKit;
import java.util.Collections;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
private DataTree dataTree;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MockitoAnnotations.initMocks(this);
system = ActorSystem.apply();
contextProbe = new TestProbe(system, "context");
}
@After
- public void tearDown() throws Exception {
- JavaTestKit.shutdownActorSystem(system);
+ public void tearDown() {
+ TestKit.shutdownActorSystem(system);
}
@Test
- public void testResolveShardForPathNonNullCookie() throws Exception {
+ public void testResolveShardForPathNonNullCookie() {
when(shardStrategy.findShard(YangInstanceIdentifier.EMPTY)).thenReturn("default");
final Long cookie = moduleShardBackendResolver.resolveShardForPath(YangInstanceIdentifier.EMPTY);
Assert.assertEquals(0L, cookie.longValue());
}
@Test
- public void testResolveShardForPathNullCookie() throws Exception {
+ public void testResolveShardForPathNullCookie() {
when(shardStrategy.findShard(YangInstanceIdentifier.EMPTY)).thenReturn("foo");
final Long cookie = moduleShardBackendResolver.resolveShardForPath(YangInstanceIdentifier.EMPTY);
Assert.assertEquals(1L, cookie.longValue());
public void testGetBackendInfoFail() throws Exception {
final CompletionStage<ShardBackendInfo> i = moduleShardBackendResolver.getBackendInfo(0L);
final ConnectClientRequest req = contextProbe.expectMsgClass(ConnectClientRequest.class);
- final RuntimeRequestException cause = new RuntimeRequestException("fail", new RuntimeException());
- final ConnectClientFailure response =
- req.toRequestFailure(cause);
+ final RuntimeException cause = new RuntimeException();
+ final ConnectClientFailure response = req.toRequestFailure(new RuntimeRequestException("fail", cause));
contextProbe.reply(response);
final CompletionStage<ShardBackendInfo> stage = moduleShardBackendResolver.getBackendInfo(0L);
final ExecutionException caught =
TestUtils.assertOperationThrowsException(() -> TestUtils.getWithTimeout(stage.toCompletableFuture()),
ExecutionException.class);
- Assert.assertNotNull(caught.getCause());
- Assert.assertEquals(cause, caught.getCause().getCause());
+ Assert.assertEquals(cause, caught.getCause());
}
@Test