@Test
public void testParse() throws Exception {

    MatcherAssert.assertThat(URIAuthority.parse("somehost"),
            CoreMatchers.equalTo(new URIAuthority("somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost/blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost?blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost#blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("aaaa@:8080"),
            CoreMatchers.equalTo(new URIAuthority("aaaa", "", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("@:"),
            CoreMatchers.equalTo(new URIAuthority(null, "", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost:8080"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost:8080/blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost:8080?blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost:8080#blah"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("somehost:008080"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    try {
        URIAuthority.create("somehost:aaaaa");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
    try {
        URIAuthority.create("somehost:90ab");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost/blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost?blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost#blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:/blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:?blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:#blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", -1)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:8080"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:8080/blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:8080?blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("someuser@somehost:8080#blah"),
            CoreMatchers.equalTo(new URIAuthority("someuser", "somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("@somehost:8080"),
            CoreMatchers.equalTo(new URIAuthority("somehost", 8080)));
    MatcherAssert.assertThat(URIAuthority.parse("test:test@localhost:38339"),
            CoreMatchers.equalTo(new URIAuthority("test:test", "localhost", 38339)));
    try {
        URIAuthority.create("blah@goggle.com:80@google.com/");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
}