FileDocCategorySizeDatePackage
Wap230WspContentTypeTest.javaAPI DocAndroid 5.1 API39013Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony

Wap230WspContentTypeTest

public class Wap230WspContentTypeTest extends TestCase

Fields Summary
public static final Map
WELL_KNOWN_SHORT_MIME_TYPES
public static final Map
WELL_KNOWN_LONG_MIME_TYPES
public static final Map
WELL_KNOWN_PARAMETERS
final int
WSP_DEFINED_SHORT_MIME_TYPE_COUNT
final int
WSP_DEFINED_LONG_MIME_TYPE_COUNT
private static final byte
WSP_STRING_TERMINATOR
private static final byte
WSP_SHORT_INTEGER_MASK
private static final byte
WSP_LENGTH_QUOTE
private static final byte
WSP_QUOTE
private static final short
LONG_MIME_TYPE_OMA_DIRECTORY_XML
private static final short
LONG_MIME_TYPE_UNASSIGNED
private static final byte
SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE
private static final byte
SHORT_MIME_TYPE_UNASSIGNED
private static final String
STRING_MIME_TYPE_ROLLOVER_CERTIFICATE
private static final byte
TYPED_PARAM_Q
private static final byte
TYPED_PARAM_DOMAIN
private static final byte
PARAM_UNASSIGNED
private static final byte
PARAM_NO_VALUE
private static final byte
TYPED_PARAM_SEC
private static final byte
TYPED_PARAM_MAC
Constructors Summary
Methods Summary
public voidtestConstrainedMediaExtensionMedia()


        String testType = "application/wibble";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(testType.getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));
        String mimeType = unit.getValueString();
        assertEquals(testType, mimeType);
        assertEquals(-1, unit.getValue32());
        assertEquals(19, unit.getDecodedDataLength());
    
public voidtestConstrainedMediaExtensionMediaWithSpace()


        String testType = " application/wibble";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(testType.getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(testType, mimeType);
        assertEquals(-1, unit.getValue32());
        assertEquals(20, unit.getDecodedDataLength());

    
public voidtestDecodeReturnsFalse_WhenOnlyAZeroBytePresent()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x00);
        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertFalse(unit.decodeContentType(0));
    
public voidtestDecodesReturnsFalse_ForParamWithMissingValue()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x09);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertFalse(unit.decodeContentType(0));
    
public voidtestDecodesReturnsFalse_WhenParamValueNotTerminated()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x15);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(0x01);
        out.write(PARAM_UNASSIGNED);
        out.write("wdstechnology.com".getBytes("US-ASCII"));

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertFalse(unit.decodeContentType(0));
    
public voidtestGeneralFormLengthQuoteExtensionMedia()


        String testType = "application/wibble";
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(testType.length() + 1); // Length as UINTVAR

        out.write(testType.getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(testType, mimeType);
        assertEquals(-1, unit.getValue32());
        assertEquals(21, unit.getDecodedDataLength());

    
public voidtestGeneralFormLengthQuoteExtensionMediaWithNiceLongMimeType()


        String testType =
                "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
                +"01234567890123456789012345678901234567890123456789012345678901234567890123456789";
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(0x81); // Length as UINTVAR (161 decimal, 0xA1), 2 bytes
        out.write(0x21);

        out.write(testType.getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(testType, mimeType);
        assertEquals(-1, unit.getValue32());
        assertEquals(164, unit.getDecodedDataLength());

    
public voidtestGeneralFormLengthQuoteWellKnownLongInteger()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(0x03); // Length as UINTVAR
        out.write(0x02); // long-integer length (2 octets)
        out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML >> 8);
        out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML & 0xFF);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals("application/oma-directory+xml", mimeType);
        assertEquals(LONG_MIME_TYPE_OMA_DIRECTORY_XML, unit.getValue32());
        assertEquals(5, unit.getDecodedDataLength());

    
public voidtestGeneralFormLengthQuoteWellKnownLongIntegerWithUnknownValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(0x03); // Length as UINTVAR
        out.write(0x02); // long-integer length (2 octets)
        out.write(LONG_MIME_TYPE_UNASSIGNED >> 8);
        out.write(LONG_MIME_TYPE_UNASSIGNED & 0xFF);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertNull(mimeType);
        assertEquals(LONG_MIME_TYPE_UNASSIGNED, unit.getValue32());
        assertEquals(5, unit.getDecodedDataLength());

    
public voidtestGeneralFormLengthQuoteWellKnownShortInteger()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(0x01); // Length as UINTVAR
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();
        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(3, unit.getDecodedDataLength());

    
public voidtestGeneralFormLengthQuoteWellKnownShortIntegerWithUnknownValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(WSP_LENGTH_QUOTE);
        out.write(0x01); // Length as UINTVAR
        out.write(SHORT_MIME_TYPE_UNASSIGNED | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();
        assertNull(mimeType);
        assertEquals(SHORT_MIME_TYPE_UNASSIGNED, unit.getValue32());
        assertEquals(3, unit.getDecodedDataLength());
    
public voidtestGeneralFormShortLengthExtensionMedia()


        String testType = "12345678901234567890123456789";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(testType.length() + 1);
        out.write(testType.getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();
        assertEquals(testType, mimeType);
        assertEquals(-1, unit.getValue32());
        assertEquals(31, unit.getDecodedDataLength());
    
public voidtestGeneralFormShortLengthWellKnownLongInteger()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(0x03); // header length
        out.write(0x02); // type length (2 octets)
        out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML >> 8);
        out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML & 0xFF);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals("application/oma-directory+xml", mimeType);
        assertEquals(LONG_MIME_TYPE_OMA_DIRECTORY_XML, unit.getValue32());
        assertEquals(4, unit.getDecodedDataLength());
    
public voidtestGeneralFormShortLengthWellKnownLongIntegerWithUnknownValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        out.write(0x03); // Value-length, short-length
        out.write(0x02); // long-integer length (2 octets)
        out.write(LONG_MIME_TYPE_UNASSIGNED >> 8);
        out.write(LONG_MIME_TYPE_UNASSIGNED & 0xFF);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertNull(mimeType);
        assertEquals(LONG_MIME_TYPE_UNASSIGNED, unit.getValue32());
        assertEquals(4, unit.getDecodedDataLength());

    
public voidtestGeneralFormShortLengthWellKnownShortInteger()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x01);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();
        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(2, unit.getDecodedDataLength());

    
public voidtestGeneralFormShortLengthWellKnownShortIntegerWithUnknownValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x01);
        out.write(SHORT_MIME_TYPE_UNASSIGNED | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();
        assertNull(mimeType);
        assertEquals(SHORT_MIME_TYPE_UNASSIGNED, unit.getValue32());
        assertEquals(2, unit.getDecodedDataLength());

    
public voidtestHasExpectedNumberOfLongMimeTypes()

        assertEquals(WSP_DEFINED_LONG_MIME_TYPE_COUNT, WELL_KNOWN_LONG_MIME_TYPES.size());
    
public voidtestHasExpectedNumberOfShortMimeTypes()


       
        assertEquals(WSP_DEFINED_SHORT_MIME_TYPE_COUNT, WELL_KNOWN_SHORT_MIME_TYPES.size());
    
public voidtestTypedParamTextQValue()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x04);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_Q);
        out.write(0x83); // Q value byte 1
        out.write(0x31); // Q value byte 2

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));
        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(0x3F, unit.getValue32());
        assertEquals(5, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("433", params.get("Q"));

    
public voidtestTypedParamUnassignedWellKnownLongIntegerTokenText()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x15);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(0x01); // Short-length of well-known parameter token
        out.write(PARAM_UNASSIGNED);
        out.write("wdstechnology.com".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());

        assertEquals(22, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("wdstechnology.com", params.get("unassigned/0x42"));
    
public voidtestTypedParamUnassignedWellKnownShortIntegerTokenText()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x14);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(PARAM_UNASSIGNED | WSP_SHORT_INTEGER_MASK);
        out.write("wdstechnology.com".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());

        assertEquals(21, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("wdstechnology.com", params.get("unassigned/0x42"));

    
public voidtestTypedParamWellKnownLongIntegerTokenText()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x15);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(0x01);
        out.write(TYPED_PARAM_DOMAIN);
        out.write("wdstechnology.com".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());

        assertEquals(22, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("wdstechnology.com", params.get("Domain"));

    
public voidtestTypedParamWellKnownShortIntegerCompactIntegerValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x3);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK);
        out.write(0x01 | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(0x3F, unit.getValue32());
        assertEquals(4, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("1", params.get("SEC"));

    
public voidtestTypedParamWellKnownShortIntegerCompactIntegerValue_0()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x3);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK);
        out.write(0x00 | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(0x3F, unit.getValue32());
        assertEquals(4, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("0", params.get("SEC"));
    
public voidtestTypedParamWellKnownShortIntegerMultipleParameters()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x0B);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK);
        out.write(0x01 | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_MAC | WSP_SHORT_INTEGER_MASK);
        out.write(WSP_QUOTE);
        out.write("imapc".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(12, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("1", params.get("SEC"));
        assertEquals("imapc", params.get("MAC"));
    
public voidtestTypedParamWellKnownShortIntegerNoValue()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x03); // Value-length, short-length
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK);
        out.write(PARAM_NO_VALUE);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());

        assertEquals(4, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals(null, params.get("Domain"));

    
public voidtestTypedParamWellKnownShortIntegerQuotedText()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x15);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK);
        out.write(WSP_QUOTE);
        out.write("wdstechnology.com".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(0x3F, unit.getValue32());
        assertEquals(22, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("wdstechnology.com", params.get("Domain"));

    
public voidtestTypedParamWellKnownShortIntegerTokenText()


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x14); // Value-length, short-length
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK);
        out.write("wdstechnology.com".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());

        assertEquals(out.toByteArray().length, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("wdstechnology.com", params.get("Domain"));

    
public voidtestUntypedParamIntegerValueLongInteger()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x0C);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);
        out.write(0x02); // Short Length
        out.write(0x42); // Long Integer byte 1
        out.write(0x69); // Long Integer byte 2

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(0x3F, unit.getValue32());
        assertEquals(13, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("17001", params.get("MYPARAM"));
    
public voidtestUntypedParamIntegerValueShortInteger()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x0A);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR); // EOS
        out.write(0x45 | WSP_SHORT_INTEGER_MASK);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));

        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(11, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("69", params.get("MYPARAM"));
    
public voidtestUntypedParamTextNoValue()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x0A);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);
        out.write(PARAM_NO_VALUE);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));
        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(11, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals(null, params.get("MYPARAM"));

    
public voidtestUntypedParamTextQuotedString()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x11);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);
        out.write(WSP_QUOTE);
        out.write("myvalue".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));
        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(19, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("myvalue", params.get("MYPARAM"));

    
public voidtestUntypedParamTextTokenText()

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        out.write(0x11);
        out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK);
        out.write("MYPARAM".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);
        out.write("myvalue".getBytes("US-ASCII"));
        out.write(WSP_STRING_TERMINATOR);

        WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
        assertTrue(unit.decodeContentType(0));
        String mimeType = unit.getValueString();

        assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType);
        assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32());
        assertEquals(18, unit.getDecodedDataLength());

        Map<String, String> params = unit.getContentParameters();
        assertEquals("myvalue", params.get("MYPARAM"));
    
public voidtestWellKnownLongIntegerMimeTypeValues()

        byte headerLength = 3;
        byte typeLength = 2;
        for (int value : Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.keySet()) {
            byte[] data = new byte[10];
            data[0] = headerLength;
            data[1] = typeLength;
            data[2] = (byte) (value >> 8);
            data[3] = (byte) (value & 0xFF);
            WspTypeDecoder unit = new WspTypeDecoder(data);
            assertTrue(unit.decodeContentType(0));
            String mimeType = unit.getValueString();
            int wellKnownValue = (int) unit.getValue32();
            assertEquals(Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.get(value), mimeType);
            assertEquals(value, wellKnownValue);
            assertEquals(4, unit.getDecodedDataLength());
        }
    
public voidtestWellKnownShortIntegerMimeTypeValues()


        for (int value : Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.keySet()) {
            WspTypeDecoder unit = new WspTypeDecoder(
                    HexDump.toByteArray((byte) (value | WSP_SHORT_INTEGER_MASK)));
            assertTrue(unit.decodeContentType(0));
            String mimeType = unit.getValueString();
            int wellKnownValue = (int) unit.getValue32();
            assertEquals(Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.get(value), mimeType);
            assertEquals(value, wellKnownValue);
            assertEquals(1, unit.getDecodedDataLength());
        }