@Test
  public void testLoginComponent() throws Exception {
    Identity identity = Identity.instance();

    assertFalse(identity.isLoggedIn());
    identity.setUsername("gavin");
    identity.setPassword("foobar");
    identity.login();

    User user = (User) Component.getInstance("user");
    assertEquals("Gavin King", user.getName());
    assertEquals("gavin", user.getUsername());
    assertEquals("foobar", user.getPassword());
    assertTrue(identity.isLoggedIn());
    identity.logout();
    assertFalse(identity.isLoggedIn());
    identity.setUsername("gavin");
    identity.setPassword("tiger");
    identity.login();
    assertFalse(identity.isLoggedIn());
  }
  @Test
  public void testLogin() throws Exception {
    Identity identity = Identity.instance();

    assertFalse(identity.isLoggedIn());

    identity.setUsername("gavin");
    identity.setPassword("foobar");
    identity.login();

    User user = (User) Component.getInstance("user");
    assertEquals("Gavin King", user.getName());
    assertEquals("gavin", user.getUsername());
    assertEquals("foobar", user.getPassword());
    assertFalse(Manager.instance().isLongRunningConversation());
    assertTrue(identity.isLoggedIn());

    identity.logout();
    assertTrue(Session.instance().isInvalid());

    assertFalse(identity.isLoggedIn());
  }