@Test
    public void testParseRegionWithBJSEndpoints() {
        // Verify that BJS endpoints parse correctly even though they're non-standard.
        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("iam.cn-north-1.amazonaws.com.cn", "iam"));
        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("ec2.cn-north-1.amazonaws.com.cn", "ec2"));
        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("s3.cn-north-1.amazonaws.com.cn", "s3"));
        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("bucket.name.with.periods.s3.cn-north-1.amazonaws.com.cn", "s3"));

        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("cloudsearch.cn-north-1.amazonaws.com.cn", "cloudsearch"));
        assertEquals("cn-north-1", AwsHostNameUtils.parseRegion("domain.cn-north-1.cloudsearch.amazonaws.com.cn", "cloudsearch"));
    }
Unit tests for the utility methods that parse information from AWS URLs.
aws-java-sdk-core/src/test/java/com/amazonaws/util/AwsHostNameUtilsTest.java