Пример #1
0
  @Test
  public void testLastUpdateChanged() {
    Article article = new Article(admin, "art1", "cont1");
    articleService.persist(article);

    long created = article.getCreated().getTime();
    long updated = article.getUpdated().getTime();

    LOG.info("Created: " + created);
    LOG.info("Updated: " + updated);

    Assert.assertEquals(created, updated);

    try {
      Thread.sleep(5);
    } catch (InterruptedException e) {
    }

    article.setContent("Content upr");
    articleService.merge(article);

    article = articleService.get(article.getId());
    Assert.assertEquals("Content upr", article.getContent());

    LOG.info("Updated after update: " + article.getUpdated().getTime());
    Assert.assertTrue(updated < article.getUpdated().getTime());

    LOG.info("Created after update: " + article.getCreated().getTime());
    Assert.assertEquals(created, article.getCreated().getTime());
  }