public void testStopsWhenQueryBetterThanElapsed() throws Exception { System.gc(); BestQueryExplainer bq = new BestQueryExplainer(); bq.add(q1); // Takes 600 milliseconds Thread.sleep(700); try { bq.add(q2); fail("Expected: BestQueryException"); } catch (BestQueryException e) { } }
public void testReturnBest() throws Exception { System.gc(); BestQueryExplainer bq = new BestQueryExplainer(); bq.add(q1); bq.add(q2); assertEquals(q1, bq.getBestQuery()); bq = new BestQueryExplainer(); bq.add(q2); bq.add(q1); assertEquals(q1, bq.getBestQuery()); }
/** Runs all JSR166 unit tests using junit.textui.TestRunner */ public static void main(String[] args) { int iters = 1; if (args.length > 0) iters = Integer.parseInt(args[0]); Test s = suite(); for (int i = 0; i < iters; ++i) { junit.textui.TestRunner.run(s); System.gc(); System.runFinalization(); } System.exit(0); }
// [myakovlev] Do not delete - it is for debugging public static void tryGc(int times) { if ((ourMode & RUN_GC) == 0) return; for (int qqq = 1; qqq < times; qqq++) { try { Thread.sleep(qqq * 1000); } catch (InterruptedException e) { e.printStackTrace(); } System.gc(); // long mem = Runtime.getRuntime().totalMemory(); log("Runtime.getRuntime().totalMemory() = " + Runtime.getRuntime().totalMemory()); } }
/** Runs all JSR166 unit tests using junit.textui.TestRunner */ public static void main(String[] args) { if (useSecurityManager) { System.err.println("Setting a permissive security manager"); Policy.setPolicy(permissivePolicy()); System.setSecurityManager(new SecurityManager()); } int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]); Test s = suite(); for (int i = 0; i < iters; ++i) { junit.textui.TestRunner.run(s); System.gc(); System.runFinalization(); } System.exit(0); }