### Question:
SPPDecoder implements MALDecoder { @Override public Blob decodeBlob() throws MALException { long length = decodeUInteger().getValue(); if (length > Integer.MAX_VALUE) { throw new MALException(LENGTH_NOT_SUPPORTED); } return new Blob(read((int) length)); } SPPDecoder(final InputStream inputStream, final Map properties); @Override Boolean decodeBoolean(); @Override Boolean decodeNullableBoolean(); @Override Float decodeFloat(); @Override Float decodeNullableFloat(); @Override Double decodeDouble(); @Override Double decodeNullableDouble(); @Override Byte decodeOctet(); @Override Byte decodeNullableOctet(); @Override UOctet decodeUOctet(); @Override UOctet decodeNullableUOctet(); @Override Short decodeShort(); @Override Short decodeNullableShort(); @Override UShort decodeUShort(); @Override UShort decodeNullableUShort(); @Override Integer decodeInteger(); @Override Integer decodeNullableInteger(); @Override UInteger decodeUInteger(); @Override UInteger decodeNullableUInteger(); @Override Long decodeLong(); @Override Long decodeNullableLong(); @Override ULong decodeULong(); @Override ULong decodeNullableULong(); @Override String decodeString(); @Override String decodeNullableString(); @Override Blob decodeBlob(); @Override Blob decodeNullableBlob(); @Override Duration decodeDuration(); @Override Duration decodeNullableDuration(); @Override FineTime decodeFineTime(); @Override FineTime decodeNullableFineTime(); @Override Identifier decodeIdentifier(); @Override Identifier decodeNullableIdentifier(); @Override Time decodeTime(); @Override Time decodeNullableTime(); @Override URI decodeURI(); @Override URI decodeNullableURI(); @Override Element decodeElement(final Element element); @Override Element decodeNullableElement(final Element element); @Override Attribute decodeAttribute(); @Override Attribute decodeNullableAttribute(); @Override MALListDecoder createListDecoder(final List list);  }### Answer:
@Test public void testDecodeBlob1() throws Exception { newBuffer(new byte[]{0}); assertEquals(new Blob(new byte[]{}), decoder.decodeBlob()); }
@Test public void testDecodeBlob2() throws Exception { newBuffer(new byte[]{1, 0}); assertEquals(new Blob(new byte[]{0}), decoder.decodeBlob()); }
@Test public void testDecodeBlob3() throws Exception { newBuffer(new byte[]{4, (byte) 0x01, (byte) 0x02, (byte) 0xFF, (byte) 0xAB}); assertEquals(new Blob(new byte[]{(byte) 0x01, (byte) 0x02, (byte) 0xFF, (byte) 0xAB}), decoder.decodeBlob()); }
@Test public void testDecodeBlob4() throws Exception { final int randomArrLength = 65537; byte[] randomArr = new byte[randomArrLength + 3]; new Random().nextBytes(randomArr); randomArr[0] = (byte) 0b10000001; randomArr[1] = (byte) 0b10000000; randomArr[2] = (byte) 0b00000100; newBuffer(randomArr); assertEquals(new Blob(Arrays.copyOfRange(randomArr, 3, randomArrLength + 3)), decoder.decodeBlob()); }
@Test public void testDecodeBlobExpectedException1() throws Exception { newBuffer(new byte[]{}); try { decoder.decodeBlob(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeBlobExpectedException2() throws Exception { newBuffer(new byte[]{1}); try { decoder.decodeBlob(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeBlobExpectedException3() throws Exception { newBuffer(new byte[]{5, 0, 0, 0, 0}); try { decoder.decodeBlob(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }