public void testUserinfo() {
    final Reference reference = new Reference("http://*****:*****@localhost:81", reference.getAuthority());
    assertEquals("localhost", reference.getHostDomain());
    assertEquals(81, reference.getHostPort());
    assertEquals("login:password", reference.getUserInfo());

    reference.setHostDomain("www.example.com");
    assertEquals("login:[email protected]:81", reference.getAuthority());
    assertEquals("www.example.com", reference.getHostDomain());
    assertEquals(81, reference.getHostPort());
    assertEquals("login:password", reference.getUserInfo());

    reference.setHostPort(82);
    assertEquals("login:[email protected]:82", reference.getAuthority());
    assertEquals("www.example.com", reference.getHostDomain());
    assertEquals(82, reference.getHostPort());
    assertEquals("login:password", reference.getUserInfo());

    reference.setUserInfo("login");
    assertEquals("[email protected]:82", reference.getAuthority());
    assertEquals("www.example.com", reference.getHostDomain());
    assertEquals(82, reference.getHostPort());
    assertEquals("login", reference.getUserInfo());
  }
  public void testEmptyRef() {
    Reference reference = new Reference();
    reference.setAuthority("testAuthority"); // must not produce NPE

    reference = new Reference();
    reference.setBaseRef("http://localhost"); // must not produce NPE

    reference = new Reference();
    reference.setFragment("fragment"); // must not produce NPE

    reference = new Reference();
    reference.setHostDomain("localhost"); // must not produce NPE
    assertEquals("localhost", reference.getAuthority());
    reference.setHostPort(new Integer(4711)); // must not produce NPE
    assertEquals("localhost:4711", reference.getAuthority());
    reference.setUserInfo("sdgj:skdfj"); // must not produce NPE
    assertEquals("sdgj:skdfj@localhost:4711", reference.getAuthority());

    reference = new Reference();
    reference.setIdentifier("http://host/abc/wkj"); // must not produce NPE

    reference = new Reference();
    reference.setPath("loc/alhost"); // must not produce NPE

    reference = new Reference();
    reference.setProtocol(Protocol.HTTPS); // must not produce NPE

    reference = new Reference();
    reference.setQuery("a=b&c=&g=1"); // must not produce NPE

    reference = new Reference();
    reference.setRelativePart("http://localhost"); // must not produce NPE

    reference = new Reference();
    reference.setScheme("skjf"); // must not produce NPE

    reference = new Reference();
    reference.setSchemeSpecificPart("host/afjhsd"); // must not produce NPE

    reference = new Reference();
    final List<String> segments = new ArrayList<String>();
    segments.add("skhf");
    segments.add("sgdfg");
    segments.add("xiz");
    reference.setSegments(segments); // must not produce NPE
  }
 /**
  * Tests the parsing of a reference into its components
  *
  * @param reference
  * @param scheme
  * @param authority
  * @param path
  * @param query
  * @param fragment
  */
 private void testRef0(
     String reference,
     String scheme,
     String authority,
     String path,
     String query,
     String fragment) {
   final Reference ref = new Reference(reference);
   assertEquals(scheme, ref.getScheme());
   assertEquals(authority, ref.getAuthority());
   assertEquals(path, ref.getPath());
   assertEquals(query, ref.getQuery());
   assertEquals(fragment, ref.getFragment());
 }
 /**
  * Test the behaviour of several getters upon a Reference object.
  *
  * @param reference
  * @param query
  * @param fragment
  * @param toString
  */
 private void testRef4(
     Reference reference,
     String scheme,
     String authority,
     String path,
     String remainingPart,
     String toString,
     String targetRef,
     String query,
     String relativePart) {
   assertEquals(reference.getScheme(), scheme);
   assertEquals(reference.getAuthority(), authority);
   assertEquals(reference.getPath(), path);
   assertEquals(reference.getRemainingPart(), remainingPart);
   assertEquals(reference.toString(), toString);
   assertEquals(reference.getTargetRef().toString(), targetRef);
   assertEquals(reference.getQuery(), query);
   assertEquals(reference.getRelativePart(), relativePart);
 }