ZooKeeperConfig { public ZooKeeperConfig withCredentials(Credentials newCredentials) { return new ZooKeeperConfig( useCurator, servers, chrootPath, inProcess, sessionTimeout, Optional.of(newCredentials)); } ZooKeeperConfig(
      boolean useCurator,
      Iterable<InetSocketAddress> servers,
      Optional<String> chrootPath,
      boolean inProcess,
      Amount<Integer, Time> sessionTimeout,
      Optional<Credentials> credentials); static ZooKeeperConfig create(boolean useCurator, Iterable<InetSocketAddress> servers); ZooKeeperConfig withCredentials(Credentials newCredentials); Iterable<InetSocketAddress> getServers(); Amount<Integer, Time> getSessionTimeout(); Optional<Credentials> getCredentials();  }
@Test public void testWithCredentials() { ZooKeeperConfig config = new ZooKeeperConfig( false, SERVERS, Optional.absent(), false, Amount.of(1, Time.HOURS), Optional.absent()); assertFalse(config.getCredentials().isPresent()); Credentials joeCreds = Credentials.digestCredentials("Joe", "Schmoe"); ZooKeeperConfig joeConfig = config.withCredentials(joeCreds); assertNotSame(config, joeConfig); assertFalse(config.getCredentials().isPresent()); assertTrue(joeConfig.getCredentials().isPresent()); assertEquals(joeCreds, joeConfig.getCredentials().get()); }