Fix for #201: Change BeanPersistListener to use isRegisterFor() method rather than generics type (just like BeanPersistController)

This commit is contained in:
rbygrave
2014-11-19 19:43:34 +13:00
parent e04d6979d1
commit c95d76d6f6
12 changed files with 215 additions and 319 deletions
@@ -2,6 +2,7 @@ package com.avaje.tests.basic;
import java.util.List;
import com.avaje.tests.model.basic.MyEBasicConfigStartup;
import org.junit.Assert;
import org.junit.Test;
@@ -10,10 +11,16 @@ import com.avaje.ebean.Ebean;
import com.avaje.ebean.EbeanServer;
import com.avaje.tests.model.basic.EBasic;
import static org.junit.Assert.assertEquals;
public class TestExplicitInsert extends BaseTestCase {
@Test
public void test() {
public void test() throws InterruptedException {
Thread.sleep(100);
MyEBasicConfigStartup.resetCounters();
EBasic b = new EBasic();
b.setName("exp insert");
@@ -34,9 +41,22 @@ public class TestExplicitInsert extends BaseTestCase {
Assert.assertNotNull(b2.getId());
Assert.assertTrue(!b.getId().equals(b2.getId()));
List<EBasic> list = server.find(EBasic.class).where().in("id",b.getId(), b2.getId()).findList();
List<EBasic> list = server.find(EBasic.class).where().in("id", b.getId(), b2.getId()).findList();
Assert.assertEquals(2, list.size());
assertEquals(2, list.size());
b2.setName("do an update");
server.save(b2);
server.delete(b);
server.delete(b2);
// just sleep a little to allow the background thread to fire
Thread.sleep(100);
assertEquals(2, MyEBasicConfigStartup.insertCount.get());
assertEquals(1, MyEBasicConfigStartup.updateCount.get());
assertEquals(2, MyEBasicConfigStartup.deleteCount.get());
}
}