Package com.avaje.tests.update

Source Code of com.avaje.tests.update.TestMarkAsDirty

package com.avaje.tests.update;

import java.sql.Timestamp;

import org.junit.Assert;
import org.junit.Test;

import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.tests.model.basic.EBasicVer;

public class TestMarkAsDirty extends BaseTestCase {

  @Test
  public void test() throws InterruptedException {
   
    EBasicVer bean = new EBasicVer();
    bean.setName("markAsDirty");
   
    Ebean.save(bean);
   
    Timestamp lastUpdate = bean.getLastUpdate();
    Assert.assertNotNull(lastUpdate);
   
    Thread.sleep(100);
   
    // ensure the update occurs and version property is updated/incremented
    Ebean.markAsDirty(bean);
    Ebean.save(bean);

    Timestamp lastUpdate2 = bean.getLastUpdate();
    Assert.assertNotNull(lastUpdate2);
    Assert.assertNotEquals(lastUpdate, lastUpdate2);
   
  }
 
}
TOP

Related Classes of com.avaje.tests.update.TestMarkAsDirty

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.