ThreadsEngine { public static void clearThreadPool() { for (ExecutorService pool:threadPool) { pool.shutdown(); } for (ExecutorService pool:threadPool) { try { pool.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } } threadPool.clear(); }  static void setNumberOfThreads(int numThreads); static int getNumberOfThreads(); static ExecutorService getThreadWithIndex(int index); static void submitTopology(Topology topology, int numThreads); static void clearThreadPool();  }
@Test public void testClearThreadPool() { ThreadsEngine.setNumberOfThreads(numThreads); ThreadsEngine.clearThreadPool(); assertEquals("ThreadsEngine was not shutdown properly.", 0, ThreadsEngine.getNumberOfThreads()); }