Пример #1
0
  public void testValidationWithNestedGroupAndStandardFields() throws InvalidMessage {
    final quickfix.fix44.QuoteRequest quoteRequest = new quickfix.fix44.QuoteRequest();

    final quickfix.field.QuoteReqID gQuoteReqID = new quickfix.field.QuoteReqID();
    gQuoteReqID.setValue("12342");
    quoteRequest.setField(gQuoteReqID);

    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        buildNestedGroupWithStandardFields("DEFAULT_VALUE");
    gNoRelatedSym.setField(new Symbol("SYM00"));

    quoteRequest.addGroup(gNoRelatedSym);

    quoteRequest.addGroup(gNoRelatedSym);

    final String sourceFIXString = quoteRequest.toString();

    final quickfix.fix44.QuoteRequest validatedMessage =
        (quickfix.fix44.QuoteRequest) buildValidatedMessage(sourceFIXString, defaultDataDictionary);
    String validateFIXString = null;
    if (validatedMessage != null) {
      validateFIXString = validatedMessage.toString();
    }

    assertEquals("Message validation failed", sourceFIXString, validateFIXString);
  }
Пример #2
0
  public void testSettingGettingNestedGroupWithStandardFields() throws FieldNotFound {
    final String settingValue = "SETTING_VALUE";

    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        buildNestedGroupWithStandardFields(settingValue);

    // Getting part
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs getgrp =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    gNoRelatedSym.getGroup(1, getgrp);
    final LegSymbol accessorFieldStd = new LegSymbol(); // Standard Field
    final LegSymbol gotFieldStd = (LegSymbol) getgrp.getField(accessorFieldStd);

    assertEquals(
        "GettingValue is not the same the SettingValue", settingValue, gotFieldStd.getValue());
  }
Пример #3
0
  public void testSettingGettingNestedGroupWithCustomFields() throws FieldNotFound {
    final String settingValue = "SETTING_VALUE";

    // The root group
    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        buildNestedGroupWithCustomFields(settingValue);

    // Getting part
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs getgrp =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    gNoRelatedSym.getGroup(1, getgrp);
    final StringField accessorField = new StringField(9001); // Custom Field
    final StringField gotFieldStd = getgrp.getField(accessorField);

    assertEquals(
        "GettingValue is not the same the SettingValue", settingValue, gotFieldStd.getValue());
  }
Пример #4
0
  public void testGroupFieldsOrderWithCustomDataDictionary() throws InvalidMessage {
    final quickfix.fix44.QuoteRequest quoteRequest = new quickfix.fix44.QuoteRequest();

    final quickfix.field.QuoteReqID gQuoteReqID = new quickfix.field.QuoteReqID();
    gQuoteReqID.setValue("12342");
    quoteRequest.setField(gQuoteReqID);

    // The root group
    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        new quickfix.fix44.QuoteRequest.NoRelatedSym();
    gNoRelatedSym.setField(new Symbol("SYM00"));

    // The nested group
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs nestedgroup =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    nestedgroup.setField(new LegSymbol("DEFAULT_VALUE"));
    nestedgroup.setField(new OrderID("111")); // The non ordered field
    nestedgroup.setField(new StringField(9001, "1.9001")); // The custom non ordered field
    gNoRelatedSym.addGroup(nestedgroup);

    // Adding a second fake nested group to avoid being the case of having
    // one element which is not relevant :-)
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs oneMoreNestedgroup =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    oneMoreNestedgroup.setField(new LegSymbol("Donald"));
    oneMoreNestedgroup.setField(new OrderID("112")); // The non ordered field
    oneMoreNestedgroup.setField(new StringField(9001, "2.9001")); // The custom non ordered field
    gNoRelatedSym.addGroup(oneMoreNestedgroup);

    quoteRequest.addGroup(gNoRelatedSym);

    final String sourceFIXString = quoteRequest.toString();
    final quickfix.fix44.QuoteRequest validatedMessage =
        (quickfix.fix44.QuoteRequest) buildValidatedMessage(sourceFIXString, customDataDictionary);

    assertNull("Invalid message", validatedMessage.getException());

    String validatedFIXString = null;
    if (validatedMessage != null) {
      validatedFIXString = validatedMessage.toString();
    }

    assertEquals(
        "Message validation failed", checkSum(sourceFIXString), checkSum(validatedFIXString));
  }
Пример #5
0
  private quickfix.fix44.QuoteRequest.NoRelatedSym buildNestedGroupWithCustomFields(
      String settingValue) {
    // The root group
    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        new quickfix.fix44.QuoteRequest.NoRelatedSym();

    // The nested group
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs nestedgroup =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    nestedgroup.setField(new StringField(9001, settingValue));
    gNoRelatedSym.addGroup(nestedgroup);

    // Adding a second fake nested group to avoid being the case of having
    // one element which is not relevant :-)
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs oneMoreNestedgroup =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    oneMoreNestedgroup.setField(new StringField(9001, "Donald"));
    gNoRelatedSym.addGroup(oneMoreNestedgroup);

    return gNoRelatedSym;
  }
Пример #6
0
  // Testing group re-usability when setting values
  public void testSettingGettingGroupByReusingGroup() throws FieldNotFound {
    // The root group
    final quickfix.fix44.QuoteRequest.NoRelatedSym gNoRelatedSym =
        new quickfix.fix44.QuoteRequest.NoRelatedSym();

    // Create the initial group
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs nestedgroup =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    final String notOverridenFieldValue = "Value1.1";
    nestedgroup.setField(new LegSymbol(notOverridenFieldValue));
    nestedgroup.setField(new StringField(9001, "Value1.2"));
    gNoRelatedSym.addGroup(nestedgroup);

    // Create the second group by re-using the same group and changing one value of only one field
    final String overridenFieldValue = "Value2.2";
    nestedgroup.setField(new StringField(9001, overridenFieldValue));
    gNoRelatedSym.addGroup(nestedgroup);

    // Getting part
    final quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs getgrp =
        new quickfix.fix44.QuoteRequest.NoRelatedSym.NoLegs();
    gNoRelatedSym.getGroup(2, getgrp);
    final StringField accessorField = new StringField(9001); // Custom Field
    final StringField gotField = getgrp.getField(accessorField);

    final LegSymbol accessorFieldStd = new LegSymbol(); // Standard Field
    final LegSymbol gotFieldStd = (LegSymbol) getgrp.getField(accessorFieldStd);

    // Ensures that the field overriden has been set correctly
    assertEquals(
        "GettingValue is not the same the SettingValue", overridenFieldValue, gotField.getValue());

    // Ensures that the field not overriden has been set correctly
    assertEquals(
        "GettingValue is not the same the SettingValue",
        notOverridenFieldValue,
        gotFieldStd.getValue());
  }