### Question:
SPPDecoder implements MALDecoder { @Override public String decodeString() throws MALException { long length = decodeUShort().getValue(); if (length > Integer.MAX_VALUE) { throw new MALException(LENGTH_NOT_SUPPORTED); } String ret = null; try { ret = new String(read((int) length), "UTF-8"); } catch (UnsupportedEncodingException ex) { } return ret; } 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 testDecodeString1() throws Exception { newBuffer(new byte[]{0}); assertEquals("", decoder.decodeString()); }
@Test public void testDecodeString2() throws Exception { newBuffer(new byte[]{(byte) 3, (byte) 0x44, (byte) 0x4C, (byte) 0x52}); assertEquals("DLR", decoder.decodeString()); }
@Test public void testDecodeString4() throws Exception { newBuffer(new byte[]{ (byte) 8, (byte) 0xF0, (byte) 0x9F, (byte) 0x93, (byte) 0xA1, (byte) 0xF0, (byte) 0x9F, (byte) 0x91, (byte) 0xAC }); assertEquals("\ud83d\udce1\ud83d\udc6c", decoder.decodeString()); }
@Test public void testDecodeStringExpectedException1() throws Exception { newBuffer(new byte[]{}); try { decoder.decodeString(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeStringExpectedException2() throws Exception { newBuffer(new byte[]{1}); try { decoder.decodeString(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeStringExpectedException3() throws Exception { newBuffer(new byte[]{2, 0x20}); try { decoder.decodeString(); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }