Helper method to force an OutOfMemory error to occur.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@929391 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -42,6 +43,18 @@ public abstract class GenericTestCaseBase extends TestCase {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static void useAllMemory() throws Exception {
|
||||
LinkedList<long[]> dummy = new LinkedList<long[]>();
|
||||
try {
|
||||
do {
|
||||
dummy.add(new long[1048576]);
|
||||
} while (true);
|
||||
} catch (OutOfMemoryError e) {
|
||||
System.gc();
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertStaticHelperClass(Class<?> clz) throws Exception {
|
||||
Constructor<?>[] constructors = clz.getDeclaredConstructors();
|
||||
assertEquals(clz.getName() + " constructor count", 1, constructors.length);
|
||||
|
||||
Reference in New Issue
Block a user