@Test(expected = ZKAddressException.class) public void shouldExceptionWithMalformedAddress() { new ZKAddressParser().validateZkUrl("zk: }
public List<ZKAddress> validateZkUrl(final String zkUrl) { final List<ZKAddress> zkList = new ArrayList<>(); Matcher matcher = Pattern.compile(ZK_PREFIX_REGEX).matcher(zkUrl); if (!matcher.matches()) { throw new ZKAddressException(zkUrl); } String zkStripped = zkUrl.replace(ZKAddress.ZK_PREFIX, "").replace(" ", ""); String[] split = zkStripped.split(","); for (String s : split) { zkList.add(new ZKAddress(s)); } return zkList; }
ZKAddressParser { public List<ZKAddress> validateZkUrl(final String zkUrl) { final List<ZKAddress> zkList = new ArrayList<>(); Matcher matcher = Pattern.compile(ZK_PREFIX_REGEX).matcher(zkUrl); if (!matcher.matches()) { throw new ZKAddressException(zkUrl); } String zkStripped = zkUrl.replace(ZKAddress.ZK_PREFIX, "").replace(" ", ""); String[] split = zkStripped.split(","); for (String s : split) { zkList.add(new ZKAddress(s)); } return zkList; } }
ZKAddressParser { public List<ZKAddress> validateZkUrl(final String zkUrl) { final List<ZKAddress> zkList = new ArrayList<>(); Matcher matcher = Pattern.compile(ZK_PREFIX_REGEX).matcher(zkUrl); if (!matcher.matches()) { throw new ZKAddressException(zkUrl); } String zkStripped = zkUrl.replace(ZKAddress.ZK_PREFIX, "").replace(" ", ""); String[] split = zkStripped.split(","); for (String s : split) { zkList.add(new ZKAddress(s)); } return zkList; }  }
ZKAddressParser { public List<ZKAddress> validateZkUrl(final String zkUrl) { final List<ZKAddress> zkList = new ArrayList<>(); Matcher matcher = Pattern.compile(ZK_PREFIX_REGEX).matcher(zkUrl); if (!matcher.matches()) { throw new ZKAddressException(zkUrl); } String zkStripped = zkUrl.replace(ZKAddress.ZK_PREFIX, "").replace(" ", ""); String[] split = zkStripped.split(","); for (String s : split) { zkList.add(new ZKAddress(s)); } return zkList; }  List<ZKAddress> validateZkUrl(final String zkUrl); }
ZKAddressParser { public List<ZKAddress> validateZkUrl(final String zkUrl) { final List<ZKAddress> zkList = new ArrayList<>(); Matcher matcher = Pattern.compile(ZK_PREFIX_REGEX).matcher(zkUrl); if (!matcher.matches()) { throw new ZKAddressException(zkUrl); } String zkStripped = zkUrl.replace(ZKAddress.ZK_PREFIX, "").replace(" ", ""); String[] split = zkStripped.split(","); for (String s : split) { zkList.add(new ZKAddress(s)); } return zkList; }  List<ZKAddress> validateZkUrl(final String zkUrl); static final String ZK_PREFIX_REGEX; }