mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add MetaInfoManager API, remove MetaQueryStatistic entity bean, refactor query execution stats collection
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
|
||||
|
||||
package com.avaje.tests.basic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
public class TestWeakPersistenceContext extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testOne() {
|
||||
|
||||
PersistenceContext ctx = inner();
|
||||
|
||||
System.gc();
|
||||
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// this is really only a HINT, so no guarantee
|
||||
// .. but the SUN JVM does do the business
|
||||
System.gc();
|
||||
|
||||
// Pass on the SUN JVM
|
||||
Object o3 = ctx.get(Order.class, 1);
|
||||
Assert.assertNull("Sun JVM should have GC'ed this bean",o3);
|
||||
|
||||
}
|
||||
|
||||
private PersistenceContext inner() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Transaction transaction = Ebean.beginTransaction();
|
||||
SpiTransaction st = (SpiTransaction)transaction;
|
||||
PersistenceContext ctx = st.getPersistenceContext();
|
||||
|
||||
List<Order> list = Ebean.find(Order.class)
|
||||
//.select("id")
|
||||
.findList();
|
||||
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
|
||||
Object o1 = ctx.get(Order.class, 1);
|
||||
|
||||
Assert.assertNotNull(o1);
|
||||
|
||||
Ebean.endTransaction();
|
||||
|
||||
Object o2 = ctx.get(Order.class, 1);
|
||||
Assert.assertNotNull(o2);
|
||||
|
||||
System.gc();
|
||||
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user