use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class TestEntityIdentityScopeTest method testDetach.
public void testDetach() {
TestEntity entity = createEntity(null);
dao.insert(entity);
dao.detach(entity);
TestEntity entity2 = dao.load(entity.getId());
dao.detach(entity2);
TestEntity entity3 = dao.load(entity.getId());
assertNotSame(entity, entity2);
assertNotSame(entity2, entity3);
assertNotSame(entity, entity3);
}
use of org.greenrobot.greendao.daotest.TestEntity in project greenDAO by greenrobot.
the class DeadlockPreventionTest method _testLoadAll.
// Runs pretty long, only run manually
public void _testLoadAll() throws InterruptedException {
dao = daoSession.getTestEntityDao();
List<TestEntity> entities = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
TestEntity entity = new TestEntity();
entity.setSimpleStringNotNull("Text" + i);
entities.add(entity);
}
dao.insertInTx(entities);
System.out.println("Entities inserted");
LoadThread loadThread = new LoadThread();
InsertThread insertThread = new InsertThread();
InsertBatchThread insertBatchThread = new InsertBatchThread();
loadThread.start();
insertThread.start();
insertBatchThread.start();
int lastCounterInsert = insertThread.counter;
int lastCounterInsertBatch = insertBatchThread.counter;
int noProgressCount = 0;
while (!done.await(10, TimeUnit.SECONDS)) {
if (lastCounterInsert == insertThread.counter && lastCounterInsertBatch == insertBatchThread.counter) {
noProgressCount++;
System.err.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
System.err.println("No progress #" + noProgressCount + ", dumping threads");
System.err.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
dumpStacktrace("LOAD", loadThread);
dumpStacktrace("INSERT", insertThread);
dumpStacktrace("INSERT BATCH", insertBatchThread);
if (noProgressCount >= 3) {
// Test seems to be stuck, kill everything!
System.exit(1);
}
} else {
lastCounterInsert = insertThread.counter;
lastCounterInsertBatch = insertBatchThread.counter;
noProgressCount = 0;
}
}
loadThread.join();
insertThread.join();
insertBatchThread.join();
}
Aggregations