@Test
  public void testHash() {
    UserPrincipal p1 = new UserPrincipal("FOO");
    UserPrincipal p2 = new UserPrincipal("FOO");

    assertEquals(p1.hashCode(), p1.hashCode());
    assertEquals(p1.hashCode(), p2.hashCode());
  }
  @Test
  public void testEquals() {
    UserPrincipal p1 = new UserPrincipal("FOO");
    UserPrincipal p2 = new UserPrincipal("FOO");
    UserPrincipal p3 = new UserPrincipal("BAR");

    assertTrue(p1.equals(p1));
    assertTrue(p1.equals(p2));
    assertFalse(p1.equals(null));
    assertFalse(p1.equals("FOO"));
    assertFalse(p1.equals(p3));
  }
  @Test
  public void testArguments() {
    UserPrincipal principal = new UserPrincipal("FOO");

    assertEquals("FOO", principal.getName());

    try {
      new UserPrincipal(null);
      fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException ingore) {

    }
  }