public static String getHostname() {

    if ( cachedHostname != null ) {
      return cachedHostname;
    }

    // In case we don't want to leave anything to doubt...
    //
    String systemHostname = EnvUtil.getSystemProperty( KETTLE_SYSTEM_HOSTNAME );
    if ( !Utils.isEmpty( systemHostname ) ) {
      cachedHostname = systemHostname;
      return systemHostname;
    }

    String lastHostname = "localhost";
    try {
      Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
      while ( en.hasMoreElements() ) {
        NetworkInterface nwi = en.nextElement();
        Enumeration<InetAddress> ip = nwi.getInetAddresses();

        while ( ip.hasMoreElements() ) {
          InetAddress in = ip.nextElement();
          boolean hasNewHostName = !lastHostname.equalsIgnoreCase( "localhost" );
          if ( InetAddressUtils.isIPv4Address( in.getHostAddress() ) || !hasNewHostName  ) {
            lastHostname = in.getHostName();
          }
          if ( hasNewHostName && lastHostname.indexOf( ':' ) < 0 )  {
            break;
          }
        }
      }
    } catch ( SocketException e ) {
      // Eat exception, just return what you have
    }

    cachedHostname = lastHostname;

    return lastHostname;
  }
@Test
  public void testGetHostName() {
    assertFalse( Const.getHostname().isEmpty() );
  }