Methods Summary |
---|
public void | testConstrainedMediaExtensionMedia()
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 void | testConstrainedMediaExtensionMediaWithSpace()
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 void | testDecodeReturnsFalse_WhenOnlyAZeroBytePresent()
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(0x00);
WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray());
assertFalse(unit.decodeContentType(0));
|
public void | testDecodesReturnsFalse_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 void | testDecodesReturnsFalse_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 void | testGeneralFormLengthQuoteExtensionMedia()
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 void | testGeneralFormLengthQuoteExtensionMediaWithNiceLongMimeType()
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 void | testGeneralFormLengthQuoteWellKnownLongInteger()
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 void | testGeneralFormLengthQuoteWellKnownLongIntegerWithUnknownValue()
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 void | testGeneralFormLengthQuoteWellKnownShortInteger()
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 void | testGeneralFormLengthQuoteWellKnownShortIntegerWithUnknownValue()
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 void | testGeneralFormShortLengthExtensionMedia()
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 void | testGeneralFormShortLengthWellKnownLongInteger()
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 void | testGeneralFormShortLengthWellKnownLongIntegerWithUnknownValue()
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 void | testGeneralFormShortLengthWellKnownShortInteger()
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 void | testGeneralFormShortLengthWellKnownShortIntegerWithUnknownValue()
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 void | testHasExpectedNumberOfLongMimeTypes()
assertEquals(WSP_DEFINED_LONG_MIME_TYPE_COUNT, WELL_KNOWN_LONG_MIME_TYPES.size());
|
public void | testHasExpectedNumberOfShortMimeTypes()
assertEquals(WSP_DEFINED_SHORT_MIME_TYPE_COUNT, WELL_KNOWN_SHORT_MIME_TYPES.size());
|
public void | testTypedParamTextQValue()
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 void | testTypedParamUnassignedWellKnownLongIntegerTokenText()
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 void | testTypedParamUnassignedWellKnownShortIntegerTokenText()
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 void | testTypedParamWellKnownLongIntegerTokenText()
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 void | testTypedParamWellKnownShortIntegerCompactIntegerValue()
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 void | testTypedParamWellKnownShortIntegerCompactIntegerValue_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 void | testTypedParamWellKnownShortIntegerMultipleParameters()
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 void | testTypedParamWellKnownShortIntegerNoValue()
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 void | testTypedParamWellKnownShortIntegerQuotedText()
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 void | testTypedParamWellKnownShortIntegerTokenText()
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 void | testUntypedParamIntegerValueLongInteger()
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 void | testUntypedParamIntegerValueShortInteger()
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 void | testUntypedParamTextNoValue()
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 void | testUntypedParamTextQuotedString()
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 void | testUntypedParamTextTokenText()
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 void | testWellKnownLongIntegerMimeTypeValues()
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 void | testWellKnownShortIntegerMimeTypeValues()
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());
}
|