public OutputBuffer(BufferType type, int outputBufferCapacity) {

    this.type = type;
    if (outputBufferCapacity > 0) {
      switch (type) {
      case DIRECT_BUFFER:
        this.byteBuffer = ByteBuffer.allocateDirect(outputBufferCapacity);
        this.byteBuffer.order(ByteOrder.BIG_ENDIAN);
        break;
      case HEAP_BUFFER:
        this.byteBuffer = ByteBuffer.allocate(outputBufferCapacity);
        this.byteBuffer.order(ByteOrder.BIG_ENDIAN);
        break;
      }
    }
  }
@Test
  public void testOutputBuffer() {
    final int size = 100;
    final OutputBuffer output1 = new OutputBuffer(BufferType.DIRECT_BUFFER, size);
    assertThat(output1.getType()).isEqualTo(BufferType.DIRECT_BUFFER);

    assertThat(output1.length()).isZero();
    assertThat(output1.limit()).isEqualTo(size);

    final OutputBuffer output2 = new OutputBuffer(BufferType.HEAP_BUFFER, size);
    assertThat(output2.getType()).isEqualTo(BufferType.HEAP_BUFFER);

    assertThat(output2.length()).isZero();
    assertThat(output2.limit()).isEqualTo(size);

    final OutputBuffer output3 = new OutputBuffer(new byte[size]);
    assertThat(output3.getType()).isEqualTo(BufferType.HEAP_BUFFER);

    assertThat(output3.length()).isZero();
    assertThat(output3.limit()).isEqualTo(size);
  }