private static synchronized void registerTimer(Timer timer){ if(MockFramework.isEnabled()) { try{ ThreadCounter.getInstance().checkIfCanStartNewThread(); } catch(RuntimeException e) { timer.cancel(); } } instances.add(timer); }
private ThreadCounter(){ resetSingleton(); }
System.resetRuntime(); MockThread.reset(); ThreadCounter.getInstance().resetSingleton(); MockTimeZone.reset(); MockLocale.reset();
@Override @EvoSuiteExclude public synchronized void start() { if(!MockFramework.isEnabled()) { super.start(); return; } if(!isSutRelated()) { //no point in starting those 3rd party threads return; } ThreadCounter.getInstance().checkIfCanStartNewThread(); /* TODO: we could rather buffer them like we did for hooks, and execute them at the end. We could even have methods in the test-cluster to execute some of those threads till they yield within the test case */ super.start(); }