### Question:
AwsHostNameUtils { public static String parseRegionName(final String host, final String serviceHint) { String regionNameInInternalConfig = parseRegionNameByInternalConfig(host); if (regionNameInInternalConfig != null) { return regionNameInInternalConfig; } if (host.endsWith(".amazonaws.com")) { int index = host.length() - ".amazonaws.com".length(); return parseStandardRegionName(host.substring(0, index)); } if (serviceHint != null) { if (serviceHint.equals("cloudsearch") && !host.startsWith("cloudsearch.")) { Matcher matcher = EXTENDED_CLOUDSEARCH_ENDPOINT_PATTERN .matcher(host); if (matcher.matches()) { return matcher.group(1); } } Pattern pattern = Pattern.compile( "^(?:.+\\.)?" + Pattern.quote(serviceHint) + "[.-]([a-z0-9-]+)\\." ); Matcher matcher = pattern.matcher(host); if (matcher.find()) { return matcher.group(1); } } return "us-east-1"; }  static String parseRegionName(final String host, final String serviceHint); static String parseServiceName(URI endpoint);  }### Answer:
@Test public void testParseRegion() { Assert.assertEquals( AwsHostNameUtils.parseRegionName("test.s3.cn-north-1.amazonaws.com.cn", "s3"), "cn-north-1" ); }
@Test public void testParseDefaultRegion() { Assert.assertEquals( AwsHostNameUtils.parseRegionName("s3.amazonaws.com", "s3"), "us-east-1" ); }