### Question:
StubPlugin extends AbstractThreadedObservablePlugin { public void plugStubReaders(Set<String> names, Boolean synchronous) { logger.debug("Plugging {} readers ..", names.size()); Set<String> newNames = new HashSet<String>(names); newNames.removeAll(connectedStubNames); logger.debug("New readers to be created #{}", newNames.size()); if (newNames.size() > 0) { if (synchronous) { List<StubReader> newReaders = new ArrayList<StubReader>(); for (String name : newNames) { newReaders.add(new StubReader(name)); } readers.addAll(newReaders); } connectedStubNames.addAll(names); } else { logger.error("All {} readers were already plugged", names.size()); } } private  StubPlugin(); static StubPlugin getInstance(); @Override Map<String, String> getParameters(); @Override void setParameter(String key, String value); void plugStubReader(String name, Boolean synchronous); void plugStubReaders(Set<String> names, Boolean synchronous); void unplugStubReader(String name, Boolean synchronous); void unplugStubReaders(Set<String> names, Boolean synchronous);  }### Answer:
@Test public void testE_PlugMultiReadersCount() throws InterruptedException, KeypleReaderException { Set<String> newReaders = new HashSet<String>(Arrays.asList("EC_reader1", "EC_reader2", "EC_reader3")); stubPlugin.plugStubReaders(newReaders, true); logger.info("Stub Readers connected {}", stubPlugin.getReaderNames()); Assert.assertEquals(newReaders, stubPlugin.getReaderNames()); Assert.assertEquals(3, stubPlugin.getReaders().size()); }
@Test public void testE_PlugMultiReadersEvent() throws InterruptedException, KeypleReaderException { final Set<String> READERS = new HashSet<String>(Arrays.asList("E_Reader1", "E_Reader2", "E_Reader3")); final CountDownLatch readerConnected = new CountDownLatch(1); stubPlugin.addObserver(new ObservablePlugin.PluginObserver() { @Override public void update(PluginEvent event) { logger.info("event {} {}", event.getEventType(), event.getReaderNames().size()); Assert.assertEquals(PluginEvent.EventType.READER_CONNECTED, event.getEventType()); Assert.assertEquals(3, event.getReaderNames().size()); Assert.assertEquals(READERS, event.getReaderNames()); readerConnected.countDown(); } }); stubPlugin.plugStubReaders(READERS, false); readerConnected.await(2, TimeUnit.SECONDS); Assert.assertEquals(0, readerConnected.getCount()); }