コード例 #1
0
  @Test
  public void testWriteEmptyAcknowledgement() throws Exception {
    byte[] acknowledgement = new byte[0];

    byte[] expected = PayloadBuilder.build(START_OF_BLOCK, END_OF_BLOCK, END_OF_DATA);

    mllpSocketWriter.writeEnvelopedPayload(TEST_MESSAGE.getBytes(), acknowledgement);

    assertArrayEquals(expected, fakeSocket.payload());
  }
コード例 #2
0
  @Test(expected = MllpAcknowledgementDeliveryException.class)
  public void testWriteToClosedSocket() throws Exception {
    fakeSocket.closed = true;

    try {
      mllpSocketWriter.writeEnvelopedPayload(
          TEST_MESSAGE.getBytes(), TEST_ACKNOWLEDGEMENT.getBytes());
    } catch (MllpAcknowledgementDeliveryException expectedEx) {
      verifyException(expectedEx);
      throw expectedEx;
    }
  }
コード例 #3
0
  @Test(expected = MllpAcknowledgementDeliveryException.class)
  public void testGetOutputStreamFailure() throws Exception {
    fakeSocket.fakeSocketOutputStream = null;

    try {
      mllpSocketWriter.writeEnvelopedPayload(
          TEST_MESSAGE.getBytes(), TEST_ACKNOWLEDGEMENT.getBytes());
    } catch (MllpAcknowledgementDeliveryException expectedEx) {
      verifyException(expectedEx);
      throw expectedEx;
    }
  }
コード例 #4
0
  @Test(expected = MllpAcknowledgementDeliveryException.class)
  public void testWriteEndOfMessageFailure() throws Exception {
    fakeSocket.fakeSocketOutputStream.writeArrayFailOn = PAYLOAD_TERMINATOR;

    try {
      mllpSocketWriter.writeEnvelopedPayload(
          TEST_MESSAGE.getBytes(), TEST_ACKNOWLEDGEMENT.getBytes());
    } catch (MllpAcknowledgementDeliveryException expectedEx) {
      verifyException(expectedEx);
      throw expectedEx;
    }
  }
コード例 #5
0
  @Test(expected = MllpAcknowledgementDeliveryException.class)
  public void testWriteStartOfBlockFailure() throws Exception {
    fakeSocket.fakeSocketOutputStream.writeFailOn = new Byte((byte) START_OF_BLOCK);

    try {
      mllpSocketWriter.writeEnvelopedPayload(
          TEST_MESSAGE.getBytes(), TEST_ACKNOWLEDGEMENT.getBytes());
    } catch (MllpAcknowledgementDeliveryException expectedEx) {
      verifyException(expectedEx);
      throw expectedEx;
    }
  }