@Test
    public void testParseRegionWithStandardEndpointsWithServiceHint() {
        // Verify that standard endpoints parse correctly with a service hint
        assertEquals("us-east-1", AwsHostNameUtils.parseRegion("iam.amazonaws.com", "iam"));
        assertEquals("us-west-2", AwsHostNameUtils.parseRegion("iam.us-west-2.amazonaws.com", "iam"));
        assertEquals("us-west-2", AwsHostNameUtils.parseRegion("ec2.us-west-2.amazonaws.com", "ec2"));

        assertEquals("us-east-1", AwsHostNameUtils.parseRegion("s3.amazonaws.com", "s3"));
        assertEquals("us-east-1", AwsHostNameUtils.parseRegion("bucket.name.s3.amazonaws.com", "s3"));

        assertEquals("eu-west-1", AwsHostNameUtils.parseRegion("s3-eu-west-1.amazonaws.com", "s3"));
        assertEquals("eu-west-1", AwsHostNameUtils.parseRegion("s3.eu-west-1.amazonaws.com", "s3"));
        assertEquals("eu-west-1", AwsHostNameUtils.parseRegion("bucket.name.with.periods.s3-eu-west-1.amazonaws.com", "s3"));
        assertEquals("eu-west-1", AwsHostNameUtils.parseRegion("bucket.name.with.periods.s3.eu-west-1.amazonaws.com", "s3"));

        assertEquals("us-west-2", AwsHostNameUtils.parseRegion("cloudsearch.us-west-2.amazonaws.com", "cloudsearch"));
        assertEquals("us-west-2", AwsHostNameUtils.parseRegion("domain.us-west-2.cloudsearch.amazonaws.com", "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