MirroringRetriever createRetrieverToCall(File publicKeyFile)
     throws IOException, InvalidPublicKeyFileException, PublicInformationInvalidException,
         SSLSocketSetupException {
   String ip = MartusUtilities.extractIpFromFileName(publicKeyFile.getName());
   CallerSideMirroringGateway gateway = createGatewayToCall(ip, publicKeyFile);
   return new MirroringRetriever(getStore(), gateway, ip, logger);
 }
  public void testExtractIpFromFileName() throws Exception {
    try {
      MartusUtilities.extractIpFromFileName("code=x.y.z");
      fail("Should have thrown missing ip=");
    } catch (InvalidPublicKeyFileException ignoreExpectedException) {
    }

    try {
      MartusUtilities.extractIpFromFileName("ip=1.2.3");
      fail("Should have thrown not enough dots");
    } catch (InvalidPublicKeyFileException ignoreExpectedException) {
    }

    assertEquals("1.2.3.4", MartusUtilities.extractIpFromFileName("ip=1.2.3.4"));
    assertEquals("2.3.4.5", MartusUtilities.extractIpFromFileName("ip=2.3.4.5.txt"));
    assertEquals("3.4.5.6", MartusUtilities.extractIpFromFileName("code=x.y.z-ip=3.4.5.6.txt"));
  }