Remove unused ServerConfig debugSql options, Update Tests to use agentloader

This commit is contained in:
Robin Bygrave
2013-04-29 22:42:27 +12:00
parent bb2479c9e7
commit 2f97c5c36e
217 changed files with 6351 additions and 6740 deletions
@@ -1,8 +1,10 @@
package com.avaje.tests.cache;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.SqlUpdate;
import com.avaje.ebean.cache.ServerCache;
@@ -10,64 +12,65 @@ import com.avaje.ebean.cache.ServerCacheManager;
import com.avaje.tests.model.basic.Country;
import com.avaje.tests.model.basic.ResetBasicData;
public class TestExternalNotification extends TestCase {
public class TestExternalNotification extends BaseTestCase {
public void testNotify() {
ResetBasicData.reset();
Ebean.runCacheWarming(Country.class);
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
Assert.assertTrue(countryCache.size() > 0);
// inserts don't remove from bean cache
Ebean.externalModification("o_country", true, false, false);
Assert.assertTrue(countryCache.size() > 0);
@Test
public void testNotify() {
// updates flush cache
Ebean.externalModification("o_country", false, true, false);
Assert.assertEquals(0, countryCache.size());
ResetBasicData.reset();
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
Ebean.runCacheWarming(Country.class);
// deletes flush cache
Ebean.externalModification("o_country", false, false, true);
Assert.assertEquals(0, countryCache.size());
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
Assert.assertTrue(countryCache.size() > 0);
ServerCacheManager serverCacheManager = Ebean.getServerCacheManager();
serverCacheManager.clearAll();
Assert.assertEquals(0, countryCache.size());
// inserts don't remove from bean cache
Ebean.externalModification("o_country", true, false, false);
Assert.assertTrue(countryCache.size() > 0);
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
// updates flush cache
Ebean.externalModification("o_country", false, true, false);
Assert.assertEquals(0, countryCache.size());
Ebean.getServerCacheManager().clear(Country.class);
Assert.assertEquals(0, countryCache.size());
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
Ebean.runCacheWarming(Country.class);
int cacheSize = countryCache.size();
Assert.assertTrue("cacheSize: "+cacheSize,cacheSize > 0);
// deletes flush cache
Ebean.externalModification("o_country", false, false, true);
Assert.assertEquals(0, countryCache.size());
SqlUpdate sqlUpdate = Ebean.createSqlUpdate("update o_country set name = :name where code = :code");
sqlUpdate.setParameter("name", "Aotearoa");
sqlUpdate.setParameter("code","NZ");
// this should just clear the entire country cache
int rows = sqlUpdate.execute();
Assert.assertEquals(1, rows);
Assert.assertEquals(0, countryCache.size());
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
// set it back...
sqlUpdate.setParameter("name","New Zealand");
sqlUpdate.setParameter("code","NZ");
rows = sqlUpdate.execute();
Assert.assertEquals(1, rows);
}
ServerCacheManager serverCacheManager = Ebean.getServerCacheManager();
serverCacheManager.clearAll();
Assert.assertEquals(0, countryCache.size());
Ebean.runCacheWarming(Country.class);
Assert.assertTrue(countryCache.size() > 0);
Ebean.getServerCacheManager().clear(Country.class);
Assert.assertEquals(0, countryCache.size());
Ebean.runCacheWarming(Country.class);
int cacheSize = countryCache.size();
Assert.assertTrue("cacheSize: " + cacheSize, cacheSize > 0);
SqlUpdate sqlUpdate = Ebean
.createSqlUpdate("update o_country set name = :name where code = :code");
sqlUpdate.setParameter("name", "Aotearoa");
sqlUpdate.setParameter("code", "NZ");
// this should just clear the entire country cache
int rows = sqlUpdate.execute();
Assert.assertEquals(1, rows);
Assert.assertEquals(0, countryCache.size());
// set it back...
sqlUpdate.setParameter("name", "New Zealand");
sqlUpdate.setParameter("code", "NZ");
rows = sqlUpdate.execute();
Assert.assertEquals(1, rows);
}
}