Example #1
0
  @Test
  public void notInt() {
    value.setString("FOO");

    exception.expect(FIXValueFormatException.class);

    value.asInt();
  }
Example #2
0
  @Test
  public void notTimestamp() {
    value.setString("FOO");

    exception.expect(FIXValueFormatException.class);

    value.asTimestamp(new MutableDateTime());
  }
Example #3
0
  public void byteAt() {
    value.setString("FOO");

    byte[] bytes = new byte[value.length()];

    for (int i = 0; i < value.length(); i++) bytes[i] = value.byteAt(i);

    assertArrayEquals(new byte[] {'F', 'O', 'O'}, bytes);
  }
Example #4
0
  @Test
  public void set() {
    FIXValue anotherValue = new FIXValue(32);

    anotherValue.setString("FOO");

    value.set(anotherValue);

    assertPutEquals("FOO\u0001");
  }
Example #5
0
  private void assertPutEquals(String s) {
    ByteBuffer buffer = ByteBuffer.allocate(s.length());

    value.put(buffer);
    buffer.flip();

    assertEquals(s, ByteBuffers.getString(buffer));
  }
Example #6
0
  @Test
  public void asTimeOnlyWithoutMillis() throws FIXValueOverflowException {
    get("09:30:05");

    MutableDateTime t = new MutableDateTime();

    value.asTimeOnly(t);

    assertEquals(new LocalTime(9, 30, 5, 0), new LocalTime(t));
  }
Example #7
0
  @Test
  public void asTimestampWithoutMillis() throws FIXValueOverflowException {
    get("20150924-09:30.05");

    MutableDateTime t = new MutableDateTime();

    value.asTimestamp(t);

    assertEquals(new MutableDateTime(2015, 9, 24, 9, 30, 5, 0), t);
  }
Example #8
0
  @Test
  public void asStringToStringBuilder() throws FIXValueOverflowException {
    get("FOO\u0001");

    StringBuilder s = new StringBuilder();

    value.asString(s);

    assertEquals("FOO", s.toString());
  }
Example #9
0
  @Test
  public void asDate() throws FIXValueOverflowException {
    get("20150924");

    MutableDateTime d = new MutableDateTime();

    value.asDate(d);

    assertEquals(new MutableDateTime(2015, 9, 24, 0, 0, 0, 0), d);
  }
Example #10
0
  @Test
  public void readOverflow() throws FIXValueOverflowException {
    exception.expect(FIXValueOverflowException.class);

    value.get(ByteBuffers.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
  }
Example #11
0
  @Test
  public void asFloatWithoutDecimals() throws FIXValueOverflowException {
    get("12\u0001");

    assertEquals(12.00, value.asFloat(), 0.01);
  }
Example #12
0
  @Test
  public void setCheckSum() {
    value.setCheckSum(320);

    assertPutEquals("064\u0001");
  }
Example #13
0
  @Test
  public void asCheckSum() throws FIXValueOverflowException {
    get("064\u0001");

    assertEquals(64, value.asCheckSum());
  }
Example #14
0
  @Test
  public void setFloatWithoutDecimals() {
    value.setFloat(12.00, 0);

    assertPutEquals("12\u0001");
  }
Example #15
0
  @Test
  public void setNegativeFloat() {
    value.setFloat(-12.50, 2);

    assertPutEquals("-12.50\u0001");
  }
Example #16
0
  @Test
  public void setFloatWithRoundingDown() {
    value.setFloat(12.50, 2);

    assertPutEquals("12.50\u0001");
  }
Example #17
0
  @Test
  public void setChar() {
    value.setChar('Y');

    assertPutEquals("Y\u0001");
  }
Example #18
0
  @Test
  public void setFloatWithRoundingUp() {
    value.setFloat(12.505, 2);

    assertPutEquals("12.51\u0001");
  }
Example #19
0
  @Test
  public void setDate() {
    value.setDate(new MutableDateTime(2015, 9, 24, 0, 0, 0, 0));

    assertPutEquals("20150924\u0001");
  }
Example #20
0
  @Test
  public void setString() {
    value.setString("FOO");

    assertPutEquals("FOO\u0001");
  }
Example #21
0
 @Test
 public void readPartial() throws FIXValueOverflowException {
   assertEquals(false, value.get(ByteBuffers.wrap("foo")));
 }
Example #22
0
  @Test
  public void asNegativeFloat() throws FIXValueOverflowException {
    get("-12.50\u0001");

    assertEquals(-12.50, value.asFloat(), 0.01);
  }
Example #23
0
 private void get(String s) throws FIXValueOverflowException {
   value.get(ByteBuffers.wrap(s));
 }
Example #24
0
  @Test
  public void setTimestampWithoutMillis() {
    value.setTimestamp(new MutableDateTime(2015, 9, 24, 9, 30, 5, 250), false);

    assertPutEquals("20150924-09:30:05\u0001");
  }
Example #25
0
  @Test
  public void asChar() throws FIXValueOverflowException {
    get("Y\u0001");

    assertEquals('Y', value.asChar());
  }
Example #26
0
  @Test
  public void asString() throws FIXValueOverflowException {
    get("FOO\u0001");

    assertEquals("FOO", value.asString());
  }
Example #27
0
  @Test
  public void setInt() {
    value.setInt(123);

    assertPutEquals("123\u0001");
  }
Example #28
0
  @Test
  public void setTimeOnlyWithMillis() {
    value.setTimeOnly(new MutableDateTime(2015, 9, 24, 9, 30, 5, 250), true);

    assertPutEquals("09:30:05.250\u0001");
  }
Example #29
0
  @Test
  public void asZeroInt() throws FIXValueOverflowException {
    get("0\u0001");

    assertEquals(0, value.asInt());
  }
Example #30
0
  @Test
  public void setZeroFloat() {
    value.setFloat(0.00, 2);

    assertPutEquals("0.00\u0001");
  }