Ejemplo n.º 1
0
  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());
  }
Ejemplo n.º 2
0
  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
  }