DnsNamingService implements NamingService { @Override public List<ServiceInstance> lookup(SubscribeInfo subscribeInfo) { InetAddress[] addresses; try { addresses = InetAddress.getAllByName(host); } catch (UnknownHostException ex) { throw new IllegalArgumentException("unknown http host"); } List<ServiceInstance> instances = new ArrayList<ServiceInstance>(); for (InetAddress address : addresses) { ServiceInstance instance = new ServiceInstance(address.getHostAddress(), port); if (subscribeInfo != null && StringUtils.isNoneBlank(subscribeInfo.getServiceId())) { instance.setServiceName(subscribeInfo.getServiceId()); } instances.add(instance); } return instances; } DnsNamingService(BrpcURL namingUrl); @Override List<ServiceInstance> lookup(SubscribeInfo subscribeInfo); @Override void subscribe(SubscribeInfo subscribeInfo, final NotifyListener listener); @Override void unsubscribe(SubscribeInfo subscribeInfo); @Override void register(RegisterInfo registerInfo); @Override void unregister(RegisterInfo registerInfo); @Override void destroy(); String getHostPort();  }
@Test(expected = IllegalArgumentException.class) public void testEmptyServerList() { DnsNamingService namingService = new DnsNamingService(new BrpcURL("")); namingService.lookup(null); }