### Question:
ByteArrayUtil { public static short toUnsignedByte(byte[] bytes) { checkBytesNotNull(bytes); return toUnsignedByte(bytes, 0, bytes.length); }  static byte[] toByteArray(byte value); static byte[] toByteArray(short value); static byte[] toByteArray(int value); static byte[] toByteArray(long value); static byte toByte(byte[] bytes); static byte toByte(byte[] bytes, int offset, int length); static short toUnsignedByte(byte[] bytes); static short toUnsignedByte(byte[] bytes, int offset, int length); static short toShort(byte[] bytes); static short toShort(byte[] bytes, int offset, int length); static int toUnsignedShort(byte[] bytes); static int toUnsignedShort(byte[] bytes, int offset, int length); static int toInt(byte[] bytes); static int toInt(byte[] bytes, int offset, int length); static long toUnsignedInt(byte[] bytes); static long toUnsignedInt(byte[] bytes, int offset, int length); static long toLong(byte[] bytes); static long toLong(byte[] bytes, int offset, int length);  }### Answer:
@Test public void toUnsignedByte() throws Exception { try { ByteArrayUtil.toUnsignedByte(null); Assert.fail(); } catch (IllegalArgumentException e) { } Assert.assertEquals((short)0x12, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12 })); Assert.assertEquals((short)0xFF, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12, (byte)0xFF, (byte)0x56 }, 1, 1)); Assert.assertEquals((short)240, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0xF0 })); Assert.assertEquals((short)240, ByteArrayUtil.toUnsignedByte(new byte[] { (byte)0x12, (byte)0xF0 }, 1, 1)); }