Package com.opengamma.livedata.test

Examples of com.opengamma.livedata.test.CollectingLiveDataListener


    // subscribe on the client side - starts sending heartbeats
    LiveDataSpecification subscription = new LiveDataSpecification(
        dataServer.getDefaultNormalizationRuleSetId(),
        ExternalId.of(identificationDomain, "USSw5 Curncy"));
    CollectingLiveDataListener listener = new CollectingLiveDataListener();
    valueDistributor.addListener(subscription, listener);

    // subscribe on the server side
    dataServer.subscribe(subscription, false);
View Full Code Here


    // subscribe on the client side - starts sending heartbeats
    LiveDataSpecification subscription = new LiveDataSpecification(
        dataServer.getDefaultNormalizationRuleSetId(),
        ExternalId.of(identificationDomain, "USSw5 Curncy"));
    CollectingLiveDataListener listener = new CollectingLiveDataListener();
    valueDistributor.addListener(subscription, listener);

    assertEquals(dataServer.getSubscriptions().size(), 0);

    // subscribe on the server side
View Full Code Here

    LiveDataSpecification spec1 = new LiveDataSpecification(StandardRules.getNoNormalization().getId(),
        ExternalId.of(TEST_IDENTIFICATION_SCHEME, TEST_ID_1));
    LiveDataSpecification spec2 = new LiveDataSpecification(StandardRules.getNoNormalization().getId(),
        ExternalId.of(TEST_IDENTIFICATION_SCHEME, TEST_ID_2));
   
    CollectingLiveDataListener listener = new CollectingLiveDataListener();
   
    _client.subscribe(TEST_USER, Sets.newHashSet(spec1, spec2), listener);
   
    assertEquals(2, listener.getSubscriptionResponses().size());
    assertEquals(LiveDataSubscriptionResult.SUCCESS, listener.getSubscriptionResponses().get(0).getSubscriptionResult());
    assertEquals(LiveDataSubscriptionResult.SUCCESS, listener.getSubscriptionResponses().get(1).getSubscriptionResult());
   
    // Snapshot x 2
    assertEquals(2, listener.getValueUpdates().size());
   
    _server.sendLiveDataToClient();
   
    // Snapshot x 2, subscription data x 2 = 4 overall
    assertEquals(4, listener.getValueUpdates().size());
    for (int i = 0; i < listener.getValueUpdates().size(); i++) {
      LiveDataValueUpdate update = listener.getValueUpdates().get(i);
      if (update.getSpecification().equals(spec1)) {
        assertEquals(_testMsgs[0], update.getFields());
      } else if (update.getSpecification().equals(spec2)) {
        assertEquals(_testMsgs[1], update.getFields());
      } else {
View Full Code Here

  public void subscribeUnsubscribeCycle() {
    _server.start();
   
    assertEquals(0, _server.getSubscriptions().size());
   
    CollectingLiveDataListener listener = new CollectingLiveDataListener();
   
    _client.subscribe(TEST_USER, TEST_LIVE_DATA_SPEC, listener);
   
    assertEquals(1, _server.getSubscriptions().size());
   
    _client.unsubscribe(TEST_USER, TEST_LIVE_DATA_SPEC, listener);
   
    // there would need to be a timeout before actual unsubscribe happens
    assertEquals(1, _server.getSubscriptions().size());
   
    assertEquals(1, listener.getSubscriptionResponses().size());
    assertEquals(1, listener.getStoppedSubscriptions().size());
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Test(invocationCount = 5, successPercentage = 19)
  public void basicOperation() throws InterruptedException, IOException {
    LiveDataHeartbeat heartbeatService = Mockito.mock(LiveDataHeartbeat.class);
    ValueDistributor valueDistributor = new ValueDistributor();
    CollectingLiveDataListener listener1 = new CollectingLiveDataListener();
    LiveDataSpecification spec1 = new LiveDataSpecification(
        "Test",
        ExternalId.of("foo", "bar"));
    LiveDataSpecification spec2 = new LiveDataSpecification(
        "Test",
View Full Code Here

  }

  @Test(groups = {"bbgSubscriptionTests" }, enabled = false)
  public void testSubscribeLimit() throws Exception {
    _server.setSubscriptionLimit(0);
    CollectingLiveDataListener listener = new CollectingLiveDataListener(1, 0);
    subscribe(_liveDataClient, listener, "AAPL US Equity");
    assertTrue(listener.waitUntilEnoughUpdatesReceived(1000));
    Thread.sleep(100000);
    for (LiveDataSubscriptionResponse response : listener.getSubscriptionResponses()) {
      assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.INTERNAL_ERROR);
      assertTrue(response.getUserMessage().toLowerCase().contains("limit"));
    }
  }
View Full Code Here

    }
  }

  @Test(groups = {"bbgSubscriptionTests" }, enabled = false)
  public void testSubscribe() throws Exception {
    CollectingLiveDataListener listener = new CollectingLiveDataListener(5, 5);

    subscribe(_liveDataClient, listener, "USSW5 Curncy");
    subscribe(_liveDataClient, listener, "AAPL US Equity");
    subscribe(_liveDataClient, listener, "GBP Curncy");
   
    assertTrue(listener.waitUntilEnoughUpdatesReceived(30000));
   
    for (LiveDataValueUpdate update : listener.getValueUpdates()) {
      assertEquals(1, update.getSpecification().getIdentifiers().size());
      assertNotNull(update.getSpecification().getIdentifier(ExternalSchemes.BLOOMBERG_BUID));
      assertNotNull(StandardRules.getOpenGammaRuleSetId(), update.getSpecification().getNormalizationRuleSetId());
   
      StandardRulesUtils.validateOpenGammaMsg(update.getFields());
View Full Code Here

    new ClassPathXmlApplicationContext("/com/opengamma/bbg/livedata/bbg-livedata-context.xml");
  }

  @Test(groups = {"bbgSubscriptionTests" }, enabled = false)
  public void swapStripSubscriptions() throws Exception {
    CollectingLiveDataListener oneWeekListener = new CollectingLiveDataListener();
    CollectingLiveDataListener twoWeekListener = new CollectingLiveDataListener();
    CollectingLiveDataListener threeMonthListener = new CollectingLiveDataListener();
   
    subscribe(_liveDataClient, oneWeekListener, "US0001W Index");
    subscribe(_liveDataClient, twoWeekListener, "US0002W Index");
    subscribe(_liveDataClient, threeMonthListener, "US0003M Index");
   
View Full Code Here

    ExternalId working = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER_WEAK, "USPFJD5W Curncy");
    ExternalId workingStrong = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, "USPFJD5W Curncy");
   
    List<ExternalId> instruments = Lists.newArrayList(broken, working, workingStrong);
    int repeats = 2;
    CollectingLiveDataListener listener = new CollectingLiveDataListener(instruments.size() * repeats, 1 * repeats);
    for (int i = 0; i < repeats; i++) {
      subscribe(_liveDataClient, listener, instruments);
      unsubscribe(_liveDataClient, listener, instruments);
      _unitTestingProvider.rejectAllfurtherRequests();
    }
   
    assertTrue(listener.waitUntilEnoughUpdatesReceived(30000));
   
    LiveDataSubscriptionResponse workingSub = null;
    LiveDataSubscriptionResponse workingStrongSub = null;
    for (LiveDataSubscriptionResponse response : listener.getSubscriptionResponses()) {
      if (response.getRequestedSpecification().getIdentifiers().contains(working)) {
        assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.SUCCESS);
        workingSub = response;
      } else if (response.getRequestedSpecification().getIdentifiers().contains(broken)) {
        assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.INTERNAL_ERROR);
      } else if (response.getRequestedSpecification().getIdentifiers().contains(workingStrong)) {
        assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.SUCCESS);
        workingStrongSub = response;
      } else {
        throw new Exception("Unexpected subscription response");
      }
    }
    assertEquals(workingSub.getFullyQualifiedSpecification(), workingStrongSub.getFullyQualifiedSpecification());
    assertEquals(workingSub.getTickDistributionSpecification(), workingStrongSub.getTickDistributionSpecification());
    List<LiveDataValueUpdate> allUpdates = listener.getValueUpdates();
    List<LiveDataValueUpdate> workingUpdates = listener.getValueUpdates(getLiveDataSpec(_liveDataClient, working));
    assertEquals(allUpdates, workingUpdates);
    assertFalse(_unitTestingProvider.hadToRejectRequests()); // Necessary, since exceptions are expected from the live data service
  }
View Full Code Here

  @Test(groups = {"bbgSubscriptionTests" }, enabled = false)
  public void testRealSubscribe() throws Exception {
    ExternalId strong = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, "GBP Curncy");
   
    List<ExternalId> instruments = Lists.newArrayList(strong);
    CollectingLiveDataListener listener = new CollectingLiveDataListener(instruments.size(), 3);
   
    subscribe(_liveDataClient, listener, instruments);
    assertTrue(listener.waitUntilEnoughUpdatesReceived(60000));
    unsubscribe(_liveDataClient, listener, instruments);
    for (LiveDataSubscriptionResponse response : listener.getSubscriptionResponses()) {
      if (response.getRequestedSpecification().getIdentifiers().contains(strong)) {
        assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.SUCCESS);
      }
    }
   
    List<LiveDataValueUpdate> allUpdates = listener.getValueUpdates();
    List<LiveDataValueUpdate> stronUpdates = listener.getValueUpdates(getLiveDataSpec(_liveDataClient, strong));
    assertEquals(allUpdates, stronUpdates);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.livedata.test.CollectingLiveDataListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.