@Test @SneakyThrows public void assertGetHostName() { assertNotNull(IpUtils.getHostName()); Field field = IpUtils.class.getDeclaredField("cachedHostName"); field.setAccessible(true); String hostName = (String) field.get(null); assertThat(hostName, is(IpUtils.getHostName())); }
public static String getHostName() { if (null != cachedHostName) { return cachedHostName; } try { cachedHostName = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { cachedHostName = "unknown"; } return cachedHostName; }
IpUtils { public static String getHostName() { if (null != cachedHostName) { return cachedHostName; } try { cachedHostName = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { cachedHostName = "unknown"; } return cachedHostName; } }
IpUtils { public static String getHostName() { if (null != cachedHostName) { return cachedHostName; } try { cachedHostName = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { cachedHostName = "unknown"; } return cachedHostName; }  }
IpUtils { public static String getHostName() { if (null != cachedHostName) { return cachedHostName; } try { cachedHostName = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { cachedHostName = "unknown"; } return cachedHostName; }  static String getIp(); static String getHostName(); }
IpUtils { public static String getHostName() { if (null != cachedHostName) { return cachedHostName; } try { cachedHostName = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { cachedHostName = "unknown"; } return cachedHostName; }  static String getIp(); static String getHostName(); static final String IP_REGEX; }