[jboss-cvs] JBossCache/tests/perf/org/jboss/cache/manualtests ...
Manik Surtani
msurtani at jboss.com
Thu Mar 1 14:09:32 EST 2007
User: msurtani
Date: 07/03/01 14:09:32
Added: tests/perf/org/jboss/cache/manualtests
PojoCacheMemoryLeakTest.java
CacheMemoryLeakTest.java
Log:
Mem leak tests
Revision Changes Path
1.1 date: 2007/03/01 19:09:32; author: msurtani; state: Exp;JBossCache/tests/perf/org/jboss/cache/manualtests/PojoCacheMemoryLeakTest.java
Index: PojoCacheMemoryLeakTest.java
===================================================================
package org.jboss.cache.manualtests;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import junit.framework.TestCase;
public class PojoCacheMemoryLeakTest extends TestCase
{
public void testMemoryLeak()
{
PojoCache cache = PojoCacheFactory.createCache("META-INF/unit-test-cache-service.xml", false);
cache.getCache().getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.start();
String category = "testCat";
while (true)
{
for (int i = 0; i < 100; i++)
{
Person person = new Person();
person.setName("aaa");
cache.attach(category + "/testPerson" + i, person);
assertEquals(person, cache.find(category + "/testPerson" + i));
}
// delete from the cache.
cache.getCache().getRoot().removeChild(Fqn.fromString(category));
assertFalse("Should have removed child", cache.getCache().getRoot().hasChild(Fqn.fromString(category)));
assertNull(cache.find(category + "/testPerson0"));
System.out.println("sleep and gc()");
System.gc();
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
}
}
}
}
1.1 date: 2007/03/01 19:09:32; author: msurtani; state: Exp;JBossCache/tests/perf/org/jboss/cache/manualtests/CacheMemoryLeakTest.java
Index: CacheMemoryLeakTest.java
===================================================================
package org.jboss.cache.manualtests;
import junit.framework.TestCase;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.Fqn;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
public class CacheMemoryLeakTest extends TestCase
{
public void testMemoryLeak() throws Exception
{
Cache cache = DefaultCacheFactory.getInstance().createCache("META-INF/unit-test-cache-service.xml", false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.start();
String category = "testCat";
while (true)
{
for (int i = 0; i < 100; i++)
{
Person person = new Person();
person.setName("aaa");
cache.put(Fqn.fromString(category + "/testPerson" + i), "key", person);
assertEquals(person, cache.get(Fqn.fromString(category + "/testPerson" + i), "key"));
}
// delete from the cache.
cache.getRoot().removeChild(Fqn.fromString(category));
assertFalse("Should have removed child", cache.getRoot().hasChild(Fqn.fromString(category)));
assertNull(cache.get(Fqn.fromString(category + "/testPerson" + 0), "key"));
System.out.println("sleep and gc()");
System.gc();
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
}
}
}
}
More information about the jboss-cvs-commits
mailing list