@Test
public void testToByteArrayVariable() {

    int len = 9;
    byte[] dataShort = BitBufferHelper.toByteArray(511, len);
    Assert.assertTrue(dataShort[0] == (byte) 255);
    Assert.assertTrue(dataShort[1] == (byte) 128);
    dataShort = BitBufferHelper.toByteArray(511, len);
    Assert.assertTrue(dataShort[0] == (byte) 255);
    Assert.assertTrue(dataShort[1] == (byte) 128);
    dataShort = BitBufferHelper.toByteArray((long) 511, len);
    Assert.assertTrue(dataShort[0] == (byte) 255);
    Assert.assertTrue(dataShort[1] == (byte) 128);
}