@Test public void testAysncEventListenerPoolThreads(){ AsyncEventListener<QuerySuccess> ayncListener = new DummyAsncEventListener(); for(int i=0; i<10; i++){ try { //A pool thread is created each time an event is submitted until core pool size is reached which is 5 //for this test case. @see org.apache.lens.server.api.events.AsyncEventListener.processor ayncListener.onEvent(null); } catch (LensException e) { assert(false); //Not Expected } } //Verify the core pool Threads after the events have been fired ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); int count = currentTG.activeCount(); Thread[] threads = new Thread[count]; currentTG.enumerate(threads); Set<String> aysncThreadNames = new HashSet<String>(); for(Thread t : threads){ if (t.getName().contains("DummyAsncEventListener_AsyncThread")){ aysncThreadNames.add(t.getName()); } } assertTrue(aysncThreadNames.containsAll(Arrays.asList( "DummyAsncEventListener_AsyncThread-1", "DummyAsncEventListener_AsyncThread-2", "DummyAsncEventListener_AsyncThread-3", "DummyAsncEventListener_AsyncThread-4", "DummyAsncEventListener_AsyncThread-5"))); }