Package org.fudgemsg

Examples of org.fudgemsg.MutableFudgeMsg


  @Test(timeOut=30000, enabled = false)
  public void simpleScenario() throws Exception {
    ensureStarted();
   
    FudgeContext fudgeContext = OpenGammaFudgeContext.getInstance();
    MutableFudgeMsg msg = fudgeContext.newMessage();
    msg.add("name", "ruby");
   
    _mdd.distributeLiveData(msg);
    _mdd.distributeLiveData(FudgeContext.EMPTY_MESSAGE); // empty message not sent
   
    // allow data to flow through
View Full Code Here


  @Test(timeOut=30000, enabled = false)
  public void reconnectionScenario() throws Exception {
    ensureStarted();
   
    FudgeContext fudgeContext = OpenGammaFudgeContext.getInstance();
    MutableFudgeMsg msg1 = fudgeContext.newMessage();
    msg1.add("name", "olivia");
   
    MutableFudgeMsg msg2 = fudgeContext.newMessage();
    msg2.add("name", "ruby");
   
    MutableFudgeMsg msg3 = fudgeContext.newMessage();
    msg3.add("name", "sophie"); // will overwrite ruby
    msg3.add("address", "london");
   
    MutableFudgeMsg msg4 = fudgeContext.newMessage();
    msg4.add("name", "chloe");
   
    _mdd.distributeLiveData(msg1);
    _factory.transportInterrupted();
    _mdd.distributeLiveData(msg2);
    _mdd.distributeLiveData(msg3);
View Full Code Here

  }

  public void bidAskOnly() {
    MarketValueCalculator calculator = new MarketValueCalculator();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add(MarketDataRequirementNames.BID, 50.80);
    msg.add(MarketDataRequirementNames.ASK, 50.90);
   
    FieldHistoryStore store = new FieldHistoryStore();
    store.liveDataReceived(msg);
   
    MutableFudgeMsg normalized = calculator.apply(msg, "123", store);
    assertEquals(3, normalized.getAllFields().size());
    assertEquals(50.85, normalized.getDouble(MarketDataRequirementNames.MARKET_VALUE), 0.0001);
  }
View Full Code Here

  }

  public void lastOnly() {
    MarketValueCalculator calculator = new MarketValueCalculator();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add(MarketDataRequirementNames.LAST, 50.89);
   
    FieldHistoryStore store = new FieldHistoryStore();
    store.liveDataReceived(msg);
   
    MutableFudgeMsg normalized = calculator.apply(msg, "123", store);
    assertEquals(2, normalized.getAllFields().size());
    assertEquals(50.89, normalized.getDouble(MarketDataRequirementNames.MARKET_VALUE), 0.0001);
  }
View Full Code Here

  }

  public void bigSpread() {
    MarketValueCalculator calculator = new MarketValueCalculator();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add(MarketDataRequirementNames.BID, 50.0);
    msg.add(MarketDataRequirementNames.ASK, 100.0);
    msg.add(MarketDataRequirementNames.LAST, 55.12);
   
    FieldHistoryStore store = new FieldHistoryStore();
    store.liveDataReceived(msg);
   
    MutableFudgeMsg normalized = calculator.apply(msg, "123", store);
    assertEquals(4, normalized.getAllFields().size());
    assertEquals(55.12, normalized.getDouble(MarketDataRequirementNames.MARKET_VALUE), 0.0001);
  }
View Full Code Here

    ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver);
    DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender(fudgeReceiver);
    ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context);
    TaxonomyGatheringFudgeMessageSender gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender, tmpFile.getAbsolutePath(), context, 1000L);
   
    MutableFudgeMsg msg1 = context.newMessage();
    msg1.add("name1", 1);
    msg1.add("name2", 1);
    msg1.add("name3", 1);
    msg1.add("name1", 1);
    MutableFudgeMsg msg2 = context.newMessage();
    msg1.add("name4", msg2);
    msg2.add(14, 1);
    msg2.add("name5", "foo");
   
    gatheringSender.send(msg1);
    gatheringSender.waitForNextWrite();
    gatheringSender.getTimer().cancel();
View Full Code Here

  /** Field name. */
  public static final String ATTRIBUTES_FIELD_NAME = "attributes";

  @Override
  public MutableFudgeMsg buildMessage(FudgeSerializer serializer, ComponentInfo object) {
    final MutableFudgeMsg msg = serializer.newMessage();
    ComponentInfoFudgeBuilder.toFudgeMsg(serializer, object, msg);
    return msg;
  }
View Full Code Here

@FudgeBuilderFor(FuturePriceCurveData.class)
public class FuturePriceCurveDataFudgeBuilder implements FudgeBuilder<FuturePriceCurveData<?>> {

  @Override
  public MutableFudgeMsg buildMessage(final FudgeSerializer serializer, final FuturePriceCurveData<?> object) {
    final MutableFudgeMsg message = serializer.newMessage();
    message.add("target", FudgeSerializer.addClassHeader(serializer.objectToFudgeMsg(object.getTarget()), object.getTarget().getClass()));
    serializer.addToMessage(message, "target", null, object.getTarget());
    message.add("definitionName", object.getDefinitionName());
    message.add("specificationName", object.getSpecificationName());
    for (final Object x : object.getXs()) {
      if (x != null) {
        message.add("xs", null, FudgeSerializer.addClassHeader(serializer.objectToFudgeMsg(x), x.getClass()));
      }
    }
    for (final Entry<?, Double> entry : object.asMap().entrySet()) {
      final Object x = entry.getKey();
      final MutableFudgeMsg subMessage = serializer.newMessage();
      if (x != null) {
        subMessage.add("x", null, serializer.objectToFudgeMsg(x));
        subMessage.add("value", null, entry.getValue());
        message.add("values", null, subMessage);
      }
    }
    return message;
  }
View Full Code Here

    ComponentInfoFudgeBuilder.toFudgeMsg(serializer, object, msg);
    return msg;
  }

  public static MutableFudgeMsg toFudgeMsg(FudgeSerializer serializer, ComponentInfo object) {
    final MutableFudgeMsg msg = serializer.newMessage();
    ComponentInfoFudgeBuilder.toFudgeMsg(serializer, object, msg);
    return msg;
  }
View Full Code Here

    addToMessage(msg, TYPE_FIELD_NAME, object.getType().getName());
    addToMessage(msg, CLASSIFIER_FIELD_NAME, object.getClassifier());
    if (object.getUri() != null) {
      addToMessage(msg, URI_FIELD_NAME, object.getUri().toString());
    }
    MutableFudgeMsg attributesMsg = serializer.newMessage();
    for (Entry<String, String> entry : object.getAttributes().entrySet()) {
      attributesMsg.add(entry.getKey(), entry.getValue());
    }
    addToMessage(msg, ATTRIBUTES_FIELD_NAME, attributesMsg);
  }
View Full Code Here

TOP

Related Classes of org.fudgemsg.MutableFudgeMsg

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.