@Before
 public void setup() throws Exception {
   moduleManager = new ModuleManager();
   provider = new MockConfigurationProvider();
   populateConfigurationProvider(provider);
   moduleManager.setConfigurationProvider(provider);
   moduleManager.init();
   dataSink = new DataSink();
   moduleManager.addSinkListener(dataSink);
   factory = getFactory();
   startModule();
 }
 @Test
 public void dataRequestProducesData() throws Exception {
   assertTrue(moduleManager.getDataFlows(true).isEmpty());
   MarketDataRequest request = MarketDataRequestBuilder.newRequest().withSymbols("GOOG").create();
   final DataFlowID flowID =
       moduleManager.createDataFlow(
           new DataRequest[] {new DataRequest(getInstanceURN(), request)});
   // wait until some arbitrary number of ticks have been received
   AbstractMarketDataFeedTest.wait(
       new Callable<Boolean>() {
         @Override
         public Boolean call() throws Exception {
           return dataSink.getData(flowID).size() > 20;
         }
       });
   // cancel the flow
   moduleManager.cancel(flowID);
 }
 @Test
 @Ignore
 public void reconnect() throws Exception {
   MarketDataRequest request = MarketDataRequestBuilder.newRequest().withSymbols("GOOG").create();
   final DataFlowID flowID =
       moduleManager.createDataFlow(
           new DataRequest[] {new DataRequest(getInstanceURN(), request)});
   // wait until some arbitrary number of ticks have been received
   AbstractMarketDataFeedTest.wait(
       new Callable<Boolean>() {
         @Override
         public Boolean call() throws Exception {
           return dataSink.getData(flowID).size() > 20;
         }
       });
   // reconnect and wait for more data
   // TODO - need to figure out how to make this magic incantation work
   ObjectName objectName = getInstanceURN().toObjectName();
   MBeanServerConnection mMBeanServer = null;
   AbstractMarketDataModuleMXBean mMBeanProxy =
       JMX.newMXBeanProxy(mMBeanServer, objectName, AbstractMarketDataModuleMXBean.class, true);
 }
 @Override
 public final synchronized void startFlow(final K key) {
   Validate.notNull(key);
   if (mSubscribers.containsKey(key)) {
     return;
   }
   IMarketDataSubscriber subscriber = createSubscriber(key);
   try {
     /*
      * Unlike other module operations, module creation is done
      * synchronously here. This is because 1) we know the from the
      * implementation of the module that it is a quick operation, and 2)
      * it is not dependent on any other potentially queued operations.
      * As a side effect, it allows assertion errors to be reported
      * immediately
      */
     ModuleURN subscriberURN =
         mModuleManager.createModule(MarketDataReceiverFactory.PROVIDER_URN, subscriber);
     if (mSourceModule != null) {
       startModule(subscriberURN);
     }
     mSubscribers.put(key, subscriberURN);
   } catch (InvalidURNException e) {
     // the provider URN should never be invalid
     throw new AssertionError(e);
   } catch (ModuleCreationException e) {
     // should not happen, we know we are creating it properly
     throw new AssertionError(e);
   } catch (MXBeanOperationException e) {
     // should not happen
     throw new IllegalStateException(e);
   } catch (ModuleException e) {
     // something went wrong creating the module, throw runtime exception
     // since no error handling is supported at this point
     throw new IllegalStateException(e);
   }
 }
 @After
 public void cleanup() throws Exception {
   stopModule();
   moduleManager.stop();
   moduleManager = null;
 }
 /**
  * Stops the module to be tested and verifies that it has stopped.
  *
  * @throws Exception if an error occurs
  */
 protected void stopModule() throws Exception {
   moduleManager.stop(getInstanceURN());
   assertEquals(ModuleState.STOPPED, moduleManager.getModuleInfo(getInstanceURN()).getState());
 }