Package org.fudgemsg

Examples of org.fudgemsg.FudgeContext


  @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
    while (_collectingReceiver.getMessages().isEmpty()) {
      Thread.sleep(100);
    }
    Thread.sleep(100);
    assertEquals(1, _collectingReceiver.getMessages().size());
   
    FudgeDeserializer deserializer = new FudgeDeserializer(fudgeContext);
    for (byte[] byteArray : _collectingReceiver.getMessages()) {
      FudgeMsgEnvelope msgEnvelope = fudgeContext.deserialize(byteArray);
      LiveDataValueUpdateBean update = LiveDataValueUpdateBeanFudgeBuilder.fromFudgeMsg(deserializer, msgEnvelope.getMessage());
      assertEquals(msg, update.getFields());
    }
  }
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);
    _factory.transportResumed();
    _mdd.distributeLiveData(msg4);
   
    // allow data to flow through
    while (_collectingReceiver.getMessages().size() < 3) {
      Thread.sleep(100);
    }
    Thread.sleep(100);
    assertEquals(3, _collectingReceiver.getMessages().size());
    LiveDataValueUpdateBean[] updates = new LiveDataValueUpdateBean[3];
   
    FudgeDeserializer deserializer = new FudgeDeserializer(fudgeContext);
    for (int i = 0; i < _collectingReceiver.getMessages().size(); i++) {
      FudgeMsgEnvelope msgEnvelope = fudgeContext.deserialize(_collectingReceiver.getMessages().get(i));
      LiveDataValueUpdateBean update = LiveDataValueUpdateBeanFudgeBuilder.fromFudgeMsg(deserializer, msgEnvelope.getMessage());
      updates[i] = update;
    }
   
    assertEquals(msg1, updates[0].getFields());
View Full Code Here

*/
@Test(groups = TestGroup.INTEGRATION)
public class FudgeConduitTest {

  public void oneWayTest() {
    FudgeContext context = new FudgeContext();
    CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver();
    ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver);
    DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender(fudgeReceiver);
    ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context);
   
    MutableFudgeMsg msg = context.newMessage();
    msg.add("Foo", "Bar");
    msg.add("Number Problems", 99);
   
    fudgeSender.send(msg);
   
View Full Code Here

    assertEquals("Bar", receivedMsg.getString("Foo"));
    assertEquals(new Integer(99), receivedMsg.getInt("Number Problems"));
  }
 
  public void requestResponseTest() {
    FudgeContext context = new FudgeContext();
    FudgeRequestReceiver requestReceiver = new FudgeRequestReceiver() {
      @Override
      public FudgeMsg requestReceived(
          FudgeDeserializer deserializer, FudgeMsgEnvelope requestEnvelope) {
        MutableFudgeMsg response = deserializer.getFudgeContext().newMessage();
        response.add("Killing", "In The Name Of");
        return response;
      }
    };
   
    FudgeRequestSender sender = InMemoryRequestConduit.create(requestReceiver);
   
    MutableFudgeMsg request = context.newMessage();
    request.add("Rage", "Against The Machine");
   
    CollectingFudgeMessageReceiver responseReceiver = new CollectingFudgeMessageReceiver();
    sender.sendRequest(request, responseReceiver);
    List<FudgeMsgEnvelope> receivedMessages = responseReceiver.getMessages();
View Full Code Here

    _exgMaster.setClock(Clock.fixed(now, ZoneOffset.UTC));
    _version1Instant = now.minusSeconds(100);
    _version2Instant = now.minusSeconds(50);
    s_logger.debug("test data now:   {}", _version1Instant);
    s_logger.debug("test data later: {}", _version2Instant);
    FudgeContext fudgeContext = OpenGammaFudgeContext.getInstance();
    LobHandler lobHandler = new DefaultLobHandler();
    final JdbcOperations template = _exgMaster.getDbConnector().getJdbcOperations();
    ManageableExchange exchange = new ManageableExchange();
    exchange.setUniqueId(UniqueId.of("DbExg", "101", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange101");
    exchange.setTimeZone(ZoneId.of("Europe/London"));
    byte[] bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange101", "Europe/London", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "102", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B"), ExternalId.of("C", "D"), ExternalId.of("G", "H")));
    exchange.setName("TestExchange102");
    exchange.setTimeZone(ZoneId.of("Europe/Paris"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        102, 102, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange102", "Europe/Paris", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "0"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange201");
    exchange.setTimeZone(ZoneId.of("Asia/Tokyo"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        201, 201, toSqlTimestamp(_version1Instant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
        "TestExchange201", "Asia/Tokyo", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    exchange.setUniqueId(UniqueId.of("DbExg", "201", "1"));
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("C", "D"), ExternalId.of("E", "F")));
    exchange.setName("TestExchange202");
    exchange.setTimeZone(ZoneId.of("Asia/Tokyo"));
    bytes = fudgeContext.toByteArray(fudgeContext.toFudgeMsg(exchange).getMessage());
    template.update("INSERT INTO exg_exchange VALUES (?,?,?,?,?, ?,?,?,?)",
        202, 201, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP,
        "TestExchange202", "Asia/Tokyo", new SqlParameterValue(Types.BLOB, new SqlLobValue(bytes, lobHandler)));
    _totalExchanges = 3;
//  id bigint not null,
View Full Code Here

  public void noTaxonomyFileAvailableYet() throws IOException {
    File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_noTaxonomyFileAvailableYet", ".properties");
    FileUtils.forceDelete(tmpFile);
    FileUtils.forceDeleteOnExit(tmpFile);
   
    FudgeContext context = new FudgeContext();
    CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver();
    ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver);
    DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender(fudgeReceiver);
    ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context);
    TaxonomyGatheringFudgeMessageSender gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender, tmpFile.getAbsolutePath());
View Full Code Here

  public void taxonomyGathering() throws IOException, InterruptedException {
    File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_taxonomyGathering", ".properties");
    FileUtils.forceDelete(tmpFile);
    FileUtils.forceDeleteOnExit(tmpFile);
   
    FudgeContext context = new FudgeContext();
    CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver();
    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);
View Full Code Here

  public void validFileLoadingOnStartup() throws IOException, InterruptedException {
    File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_validFileLoadingOnStartup", ".properties");
    FileUtils.forceDelete(tmpFile);
    FileUtils.forceDeleteOnExit(tmpFile);
   
    FudgeContext context = new FudgeContext();
    CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver();
    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);
View Full Code Here

 
  /**
   *
   */
  public FudgeJSONTest() {
    _fudgeContext = new FudgeContext();
    final Map<Short,FudgeTaxonomy> tr = new HashMap<Short,FudgeTaxonomy>();
    tr.put ((short)1, getTaxonomy());
    _fudgeContext.setTaxonomyResolver (new ImmutableMapTaxonomyResolver(tr));
  }
View Full Code Here

*/
@Test(groups = TestGroup.UNIT)
public class ObjectIdFudgeEncodingTest extends AbstractFudgeBuilderTestCase {

  public void test_builder() {
    FudgeContext context = new FudgeContext();
    context.getObjectDictionary().addBuilder(ObjectId.class, new ObjectIdFudgeBuilder());
    setContext(context);
    ObjectId object = ObjectId.of("A", "B");
    assertEncodeDecodeCycle(ObjectId.class, object);
  }
View Full Code Here

TOP

Related Classes of org.fudgemsg.FudgeContext

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.