@Test public void userAgentStringEmpty() throws Exception { String userAgentString = UpdateCheck.getUserAgentString("cluster1"); Mockito.when(EC2MetadataUtils.getUserData()) .thenThrow(new SdkClientException("Unable to contact EC2 metadata service.")); System.out.println(userAgentString); Assert.assertTrue( userAgentString.equals(String.format("Alluxio/%s (cluster1)", ProjectConstants.VERSION))); }
@VisibleForTesting public static String getUserAgentString(String clusterID) throws IOException { Joiner joiner = Joiner.on("; ").skipNulls(); boolean isGCE = EnvironmentUtils.isGoogleComputeEngine(); String sysInfo = joiner.join( clusterID, EnvironmentUtils.isDocker() ? "docker" : null, EnvironmentUtils.isKubernetes() ? "kubernetes" : null, isGCE ? "gce" : null ); if (!isGCE) { List<String> ec2Info = getEC2Info(); if (ec2Info.size() != 0) { sysInfo = joiner.join(sysInfo, joiner.join(ec2Info)); } } return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION, sysInfo); }
UpdateCheck { @VisibleForTesting public static String getUserAgentString(String clusterID) throws IOException { Joiner joiner = Joiner.on("; ").skipNulls(); boolean isGCE = EnvironmentUtils.isGoogleComputeEngine(); String sysInfo = joiner.join( clusterID, EnvironmentUtils.isDocker() ? "docker" : null, EnvironmentUtils.isKubernetes() ? "kubernetes" : null, isGCE ? "gce" : null ); if (!isGCE) { List<String> ec2Info = getEC2Info(); if (ec2Info.size() != 0) { sysInfo = joiner.join(sysInfo, joiner.join(ec2Info)); } } return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION, sysInfo); } }
UpdateCheck { @VisibleForTesting public static String getUserAgentString(String clusterID) throws IOException { Joiner joiner = Joiner.on("; ").skipNulls(); boolean isGCE = EnvironmentUtils.isGoogleComputeEngine(); String sysInfo = joiner.join( clusterID, EnvironmentUtils.isDocker() ? "docker" : null, EnvironmentUtils.isKubernetes() ? "kubernetes" : null, isGCE ? "gce" : null ); if (!isGCE) { List<String> ec2Info = getEC2Info(); if (ec2Info.size() != 0) { sysInfo = joiner.join(sysInfo, joiner.join(ec2Info)); } } return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION, sysInfo); } private  UpdateCheck(); }
UpdateCheck { @VisibleForTesting public static String getUserAgentString(String clusterID) throws IOException { Joiner joiner = Joiner.on("; ").skipNulls(); boolean isGCE = EnvironmentUtils.isGoogleComputeEngine(); String sysInfo = joiner.join( clusterID, EnvironmentUtils.isDocker() ? "docker" : null, EnvironmentUtils.isKubernetes() ? "kubernetes" : null, isGCE ? "gce" : null ); if (!isGCE) { List<String> ec2Info = getEC2Info(); if (ec2Info.size() != 0) { sysInfo = joiner.join(sysInfo, joiner.join(ec2Info)); } } return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION, sysInfo); } private  UpdateCheck(); static String getLatestVersion(String clusterID, long connectionRequestTimeout,
      long connectTimeout, long socketTimeout); @VisibleForTesting static String getUserAgentString(String clusterID); }
UpdateCheck { @VisibleForTesting public static String getUserAgentString(String clusterID) throws IOException { Joiner joiner = Joiner.on("; ").skipNulls(); boolean isGCE = EnvironmentUtils.isGoogleComputeEngine(); String sysInfo = joiner.join( clusterID, EnvironmentUtils.isDocker() ? "docker" : null, EnvironmentUtils.isKubernetes() ? "kubernetes" : null, isGCE ? "gce" : null ); if (!isGCE) { List<String> ec2Info = getEC2Info(); if (ec2Info.size() != 0) { sysInfo = joiner.join(sysInfo, joiner.join(ec2Info)); } } return String.format("Alluxio/%s (%s)", ProjectConstants.VERSION, sysInfo); } private  UpdateCheck(); static String getLatestVersion(String clusterID, long connectionRequestTimeout,
      long connectTimeout, long socketTimeout); @VisibleForTesting static String getUserAgentString(String clusterID);  }