@Test
public void testCreateFromString() throws Exception {

    Assert.assertEquals(new URIAuthority("somehost", 8080), URIAuthority.create("somehost:8080"));
    Assert.assertEquals(new URIAuthority("SomeHost", 8080), URIAuthority.create("SomeHost:8080"));
    Assert.assertEquals(new URIAuthority("somehost", 1234), URIAuthority.create("somehost:1234"));
    Assert.assertEquals(new URIAuthority("somehost", -1), URIAuthority.create("somehost"));
    Assert.assertEquals(new URIAuthority("user", "somehost", -1), URIAuthority.create("user@somehost"));
    try {
        URIAuthority.create(" host");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
    try {
        URIAuthority.create("host  ");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
    try {
        URIAuthority.create("host :8080");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
    try {
        URIAuthority.create("user @ host:8080");
        Assert.fail("URISyntaxException expected");
    } catch (final URISyntaxException expected) {
    }
}