@Test
public void testIsPathLocal() {

    MockClusterWrapper clusterWrapper = new MockClusterWrapper();
    ActorUtils actorUtils = null;
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal(null));
    assertFalse(actorUtils.isPathLocal(""));
    clusterWrapper.setSelfAddress(null);
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal(""));
    // even if the path is in local format, match the primary path (first 3 elements) and return true
    clusterWrapper.setSelfAddress(new Address("akka", "test"));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://test/user/$a"));
    clusterWrapper.setSelfAddress(new Address("akka", "test"));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://test/user/$a"));
    clusterWrapper.setSelfAddress(new Address("akka", "test"));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://test/user/token2/token3/$a"));
    // self address of remote format,but Tx path local format.
    clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://system/user/shardmanager/shard/transaction"));
    // self address of local format,but Tx path remote format.
    clusterWrapper.setSelfAddress(new Address("akka", "system"));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal("akka://system@127.0.0.1:2550/user/shardmanager/shard/transaction"));
    //local path but not same
    clusterWrapper.setSelfAddress(new Address("akka", "test"));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://test1/user/$a"));
    //ip and port same
    clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertTrue(actorUtils.isPathLocal("akka://system@127.0.0.1:2550/"));
    // forward-slash missing in address
    clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal("akka://system@127.0.0.1:2550"));
    //ips differ
    clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal("akka://system@127.1.0.1:2550/"));
    //ports differ
    clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550));
    actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class));
    assertFalse(actorUtils.isPathLocal("akka://system@127.0.0.1:2551/"));
}