Package com.avaje.tests.lifecycle

Source Code of com.avaje.tests.lifecycle.TestLifecyleAnnotatedBean

package com.avaje.tests.lifecycle;

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

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

public class TestLifecyleAnnotatedBean extends BaseTestCase {

  @Test
  public void test() {
   
    EBasicWithLifecycle bean = new EBasicWithLifecycle();
    bean.setName("hello there");
   
    Ebean.getServerCacheManager();
    Ebean.save(bean);
    Assert.assertEquals("prePersist,postPersist,", bean.getBuffer());

    EBasicWithLifecycle beanWasLoaded = Ebean.find(EBasicWithLifecycle.class, bean.getId());
    Assert.assertEquals("postLoad", beanWasLoaded.getBuffer().toString());
   
    bean.setName("Changed");
    Ebean.save(bean);
   
    Ebean.delete(bean);
   
    Assert.assertEquals("prePersist,postPersist,preUpdate,postUpdate,preRemove,postRemove", bean.getBuffer());
   
  }
 
}
TOP

Related Classes of com.avaje.tests.lifecycle.TestLifecyleAnnotatedBean

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.