Ejemplo n.º 1
0
  public void testGetUser() throws Exception {
    User u1 = testHelper.makeDummyUser();
    u1 = userService.createUser(u1);

    MockHttpServletRequest request = createMockRequest("GET", "/user/" + u1.getUsername());
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);

    assertEquals(response.getStatus(), MockHttpServletResponse.SC_OK);
    assertNotNull(response.getHeader("ETag"));

    CmpUser user = createUserFromXml(readXmlResponse(response));
    assertNotNull("user null", user);
    assertNotNull("user has no username", user.getUsername());
    assertEquals("usernames don't match", user.getUsername(), u1.getUsername());
    assertNotNull("user has no first name", user.getFirstName());
    assertEquals("first names don't match", user.getFirstName(), u1.getFirstName());
    assertNotNull("user has no last name", user.getLastName());
    assertEquals("last names don't match", user.getLastName(), u1.getLastName());
    assertNotNull("user has no email", user.getEmail());
    assertEquals("emails don't match", user.getEmail(), u1.getEmail());
    assertNotNull("user has no creation date", user.getCreationDate());
    assertEquals(
        "creation dates don't match",
        DateUtil.formatRfc3339Date(user.getCreationDate()),
        DateUtil.formatRfc3339Date(u1.getCreationDate()));
    assertNotNull("user has no modification date", user.getModifiedDate());
    assertEquals(
        "modification dates don't match",
        DateUtil.formatRfc3339Date(user.getModifiedDate()),
        DateUtil.formatRfc3339Date(u1.getModifiedDate()));
    assertNotNull("user has no administrator boolean", user.getAdmin());
    assertEquals("administrator booleans don't match", user.getAdmin(), u1.getAdmin());
    assertNotNull("user has no url", user.getUrl());
    assertNotNull("user has no homedir url", user.getHomedirUrl());
  }