ApiServiceDispatcher { public SortedMap<String, ApiDispatchConfig> getPatternClients() { return patternClients; }  static synchronized ApiServiceDispatcher getInstance(); ApiDispatchConfig findConfigForUri(String uri); List<ApiDispatchConfig> findMatchingConfigsForUri(String uri); synchronized void registerServiceClient(ApiListener listener); synchronized void unregisterServiceClient(ApiListener listener); SortedMap<String, ApiDispatchConfig> getPatternClients(); static Json2XmlValidator getJsonValidator(PipeLine pipeline); void clear();  }
@Test public void testAddManyConcurrentSimultaneousListeners() throws ListenerException, InterruptedException { List<Thread> list = new ArrayList<Thread>(); for (int i = 0; i < amount; i++) { String name = "thread"+i; CreateListener target = new CreateListener(name); Thread t = new Thread(target); t.setName(name); t.start(); list.add(t); } for (Thread thread : list) { thread.join(); } assertEquals(amount, dispatcher.getPatternClients().size()); }