@Test
public void testDoPost() throws IOException, EntityNotFoundException {

  final HttpServletRequest request = mock(HttpServletRequest.class);
  final HttpServletResponse response = mock(HttpServletResponse.class);
  final String guestbookName = "TestGuestbook";
  final String testContent = "Test Content";
  when(request.getParameter("guestbookName")).thenReturn(guestbookName);
  when(request.getParameter("content")).thenReturn(testContent);
  final Date priorToRequest = new Date();
  signGuestbookServlet.doPost(request, response);
  final Date afterRequest = new Date();
  verify(response).sendRedirect("/guestbook.jsp?guestbookName=TestGuestbook");
  final User currentUser = UserServiceFactory.getUserService().getCurrentUser();
  final Entity greeting = DatastoreServiceFactory.getDatastoreService().prepare(new Query()).asSingleEntity();
  assertEquals(guestbookName, greeting.getKey().getParent().getName());
  assertEquals(testContent, greeting.getProperty("content"));
  assertEquals(currentUser, greeting.getProperty("user"));
  final Date date = (Date) greeting.getProperty("date");
  assertTrue("The date in the entity [" + date + "] is prior to the request being performed",
      priorToRequest.before(date) || priorToRequest.equals(date));
  assertTrue("The date in the entity [" + date + "] is after to the request completed",
      afterRequest.after(date) || afterRequest.equals(date));
}