1c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville/* 2c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Copyright (C) 2010 The Android Open Source Project 3c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 4c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Licensed under the Apache License, Version 2.0 (the "License"); 5c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * you may not use this file except in compliance with the License. 6c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * You may obtain a copy of the License at 7c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 8c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * http://www.apache.org/licenses/LICENSE-2.0 9c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 10c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Unless required by applicable law or agreed to in writing, software 11c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * distributed under the License is distributed on an "AS IS" BASIS, 12c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * See the License for the specific language governing permissions and 14c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * limitations under the License. 15c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 16c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 17c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savillepackage com.android.internal.telephony; 18c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 19c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.WspTypeDecoder; 20c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.util.HexDump; 21c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 22c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.io.ByteArrayOutputStream; 23c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.util.HashMap; 24c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.util.Map; 25c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 26c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport junit.framework.TestCase; 27c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 28c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savillepublic class Wap230WspContentTypeTest extends TestCase { 29c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 30c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public static final Map<Integer, String> WELL_KNOWN_SHORT_MIME_TYPES 31c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = new HashMap<Integer, String>(); 32c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public static final Map<Integer, String> WELL_KNOWN_LONG_MIME_TYPES 33c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = new HashMap<Integer, String>(); 34c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public static final Map<Integer, String> WELL_KNOWN_PARAMETERS 35c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = new HashMap<Integer, String>(); 36c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 37c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static { 38c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x00, "*/*"); 39c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x01, "text/*"); 40c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x02, "text/html"); 41c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x03, "text/plain"); 42c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x04, "text/x-hdml"); 43c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x05, "text/x-ttml"); 44c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x06, "text/x-vCalendar"); 45c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x07, "text/x-vCard"); 46c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x08, "text/vnd.wap.wml"); 47c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x09, "text/vnd.wap.wmlscript"); 48c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0A, "text/vnd.wap.wta-event"); 49c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0B, "multipart/*"); 50c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0C, "multipart/mixed"); 51c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0D, "multipart/form-data"); 52c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0E, "multipart/byterantes"); 53c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x0F, "multipart/alternative"); 54c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x10, "application/*"); 55c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x11, "application/java-vm"); 56c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x12, "application/x-www-form-urlencoded"); 57c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x13, "application/x-hdmlc"); 58c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x14, "application/vnd.wap.wmlc"); 59c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x15, "application/vnd.wap.wmlscriptc"); 60c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x16, "application/vnd.wap.wta-eventc"); 61c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x17, "application/vnd.wap.uaprof"); 62c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x18, "application/vnd.wap.wtls-ca-certificate"); 63c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x19, "application/vnd.wap.wtls-user-certificate"); 64c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1A, "application/x-x509-ca-cert"); 65c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1B, "application/x-x509-user-cert"); 66c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1C, "image/*"); 67c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1D, "image/gif"); 68c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1E, "image/jpeg"); 69c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x1F, "image/tiff"); 70c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x20, "image/png"); 71c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x21, "image/vnd.wap.wbmp"); 72c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x22, "application/vnd.wap.multipart.*"); 73c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x23, "application/vnd.wap.multipart.mixed"); 74c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x24, "application/vnd.wap.multipart.form-data"); 75c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x25, "application/vnd.wap.multipart.byteranges"); 76c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x26, "application/vnd.wap.multipart.alternative"); 77c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x27, "application/xml"); 78c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x28, "text/xml"); 79c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x29, "application/vnd.wap.wbxml"); 80c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2A, "application/x-x968-cross-cert"); 81c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2B, "application/x-x968-ca-cert"); 82c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2C, "application/x-x968-user-cert"); 83c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2D, "text/vnd.wap.si"); 84c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2E, "application/vnd.wap.sic"); 85c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x2F, "text/vnd.wap.sl"); 86c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x30, "application/vnd.wap.slc"); 87c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x31, "text/vnd.wap.co"); 88c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x32, "application/vnd.wap.coc"); 89c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x33, "application/vnd.wap.multipart.related"); 90c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x34, "application/vnd.wap.sia"); 91c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x35, "text/vnd.wap.connectivity-xml"); 92c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x36, "application/vnd.wap.connectivity-wbxml"); 93c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x37, "application/pkcs7-mime"); 94c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x38, "application/vnd.wap.hashed-certificate"); 95c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x39, "application/vnd.wap.signed-certificate"); 96c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3A, "application/vnd.wap.cert-response"); 97c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3B, "application/xhtml+xml"); 98c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3C, "application/wml+xml"); 99c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3D, "text/css"); 100c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3E, "application/vnd.wap.mms-message"); 101c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x3F, "application/vnd.wap.rollover-certificate"); 102c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x40, "application/vnd.wap.locc+wbxml"); 103c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x41, "application/vnd.wap.loc+xml"); 104c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x42, "application/vnd.syncml.dm+wbxml"); 105c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x43, "application/vnd.syncml.dm+xml"); 106c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x44, "application/vnd.syncml.notification"); 107c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x45, "application/vnd.wap.xhtml+xml"); 108c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x46, "application/vnd.wv.csp.cir"); 109c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x47, "application/vnd.oma.dd+xml"); 110c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x48, "application/vnd.oma.drm.message"); 111c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x49, "application/vnd.oma.drm.content"); 112c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4A, "application/vnd.oma.drm.rights+xml"); 113c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4B, "application/vnd.oma.drm.rights+wbxml"); 114c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4C, "application/vnd.wv.csp+xml"); 115c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4D, "application/vnd.wv.csp+wbxml"); 116c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4E, "application/vnd.syncml.ds.notification"); 117c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x4F, "audio/*"); 118c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x50, "video/*"); 119c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x51, "application/vnd.oma.dd2+xml"); 120c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x52, "application/mikey"); 121c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x53, "application/vnd.oma.dcd"); 122c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_SHORT_MIME_TYPES.put(0x54, "application/vnd.oma.dcdc"); 123c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 124c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0201, "application/vnd.uplanet.cacheop-wbxml"); 125c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0202, "application/vnd.uplanet.signal"); 126c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0203, "application/vnd.uplanet.alert-wbxml"); 127c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0204, "application/vnd.uplanet.list-wbxml"); 128c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0205, "application/vnd.uplanet.listcmd-wbxml"); 129c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0206, "application/vnd.uplanet.channel-wbxml"); 130c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0207, "application/vnd.uplanet.provisioning-status-uri"); 131c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0208, "x-wap.multipart/vnd.uplanet.header-set"); 132c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0209, "application/vnd.uplanet.bearer-choice-wbxml"); 133c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x020A, "application/vnd.phonecom.mmc-wbxml"); 134c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x020B, "application/vnd.nokia.syncset+wbxml"); 135c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x020C, "image/x-up-wpng"); 136c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0300, "application/iota.mmc-wbxml"); 137c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0301, "application/iota.mmc-xml"); 138c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0302, "application/vnd.syncml+xml"); 139c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0303, "application/vnd.syncml+wbxml"); 140c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0304, "text/vnd.wap.emn+xml"); 141c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0305, "text/calendar"); 142c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0306, "application/vnd.omads-email+xml"); 143c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0307, "application/vnd.omads-file+xml"); 144c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0308, "application/vnd.omads-folder+xml"); 145c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0309, "text/directory;profile=vCard"); 146c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030A, "application/vnd.wap.emn+wbxml"); 147c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030B, "application/vnd.nokia.ipdc-purchase-response"); 148c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030C, "application/vnd.motorola.screen3+xml"); 149c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030D, "application/vnd.motorola.screen3+gzip"); 150c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030E, "application/vnd.cmcc.setting+wbxml"); 151c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x030F, "application/vnd.cmcc.bombing+wbxml"); 152c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0310, "application/vnd.docomo.pf"); 153c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0311, "application/vnd.docomo.ub"); 154c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0312, "application/vnd.omaloc-supl-init"); 155c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0313, "application/vnd.oma.group-usage-list+xml"); 156c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0314, "application/oma-directory+xml"); 157c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0315, "application/vnd.docomo.pf2"); 158c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0316, "application/vnd.oma.drm.roap-trigger+wbxml"); 159c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0317, "application/vnd.sbm.mid2"); 160c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0318, "application/vnd.wmf.bootstrap"); 161c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x0319, "application/vnc.cmcc.dcd+xml"); 162c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x031A, "application/vnd.sbm.cid"); 163c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_LONG_MIME_TYPES.put(0x031B, "application/vnd.oma.bcast.provisioningtrigger"); 164c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 165c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x00, "Q"); 166c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x01, "Charset"); 167c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x02, "Level"); 168c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x03, "Type"); 169c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x07, "Differences"); 170c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x08, "Padding"); 171c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x09, "Type"); 172c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x0E, "Max-Age"); 173c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x10, "Secure"); 174c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x11, "SEC"); 175c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x12, "MAC"); 176c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x13, "Creation-date"); 177c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x14, "Modification-date"); 178c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x15, "Read-date"); 179c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x16, "Size"); 180c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x17, "Name"); 181c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x18, "Filename"); 182c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x19, "Start"); 183c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x1A, "Start-info"); 184c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x1B, "Comment"); 185c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x1C, "Domain"); 186c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WELL_KNOWN_PARAMETERS.put(0x1D, "Path"); 187c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 188c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 189c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 190c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville final int WSP_DEFINED_SHORT_MIME_TYPE_COUNT = 85; 191c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville final int WSP_DEFINED_LONG_MIME_TYPE_COUNT = 85; 192c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 193c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte WSP_STRING_TERMINATOR = 0x00; 194c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte WSP_SHORT_INTEGER_MASK = (byte) 0x80; 195c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte WSP_LENGTH_QUOTE = 0x1F; 196c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte WSP_QUOTE = 0x22; 197c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 198c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final short LONG_MIME_TYPE_OMA_DIRECTORY_XML = 0x0314; 199c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final short LONG_MIME_TYPE_UNASSIGNED = 0x052C; 200c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 201c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE = 0x3F; 202c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte SHORT_MIME_TYPE_UNASSIGNED = 0x60; 203c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 204c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final String STRING_MIME_TYPE_ROLLOVER_CERTIFICATE 205c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = "application/vnd.wap.rollover-certificate"; 206c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 207c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte TYPED_PARAM_Q = 0x00; 208c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte TYPED_PARAM_DOMAIN = 0x1C; 209c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte PARAM_UNASSIGNED = 0x42; 210c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte PARAM_NO_VALUE = 0x00; 211c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte TYPED_PARAM_SEC = 0x11; 212c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private static final byte TYPED_PARAM_MAC = 0x12; 213c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 214c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testHasExpectedNumberOfShortMimeTypes() { 215c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(WSP_DEFINED_SHORT_MIME_TYPE_COUNT, WELL_KNOWN_SHORT_MIME_TYPES.size()); 216c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 217c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 218c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testHasExpectedNumberOfLongMimeTypes() { 219c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(WSP_DEFINED_LONG_MIME_TYPE_COUNT, WELL_KNOWN_LONG_MIME_TYPES.size()); 220c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 221c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 222c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testWellKnownShortIntegerMimeTypeValues() { 223c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 224c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville for (int value : Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.keySet()) { 225c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder( 226c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville HexDump.toByteArray((byte) (value | WSP_SHORT_INTEGER_MASK))); 227c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 228c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 229c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int wellKnownValue = (int) unit.getValue32(); 230c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.get(value), mimeType); 231c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(value, wellKnownValue); 232c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(1, unit.getDecodedDataLength()); 233c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 234c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 235c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 236c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testWellKnownLongIntegerMimeTypeValues() { 237c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville byte headerLength = 3; 238c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville byte typeLength = 2; 239c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville for (int value : Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.keySet()) { 240c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville byte[] data = new byte[10]; 241c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data[0] = headerLength; 242c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data[1] = typeLength; 243c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data[2] = (byte) (value >> 8); 244c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data[3] = (byte) (value & 0xFF); 245c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(data); 246c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 247c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 248c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int wellKnownValue = (int) unit.getValue32(); 249c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(Wap230WspContentTypeTest.WELL_KNOWN_SHORT_MIME_TYPES.get(value), mimeType); 250c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(value, wellKnownValue); 251c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(4, unit.getDecodedDataLength()); 252c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 253c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 254c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 255c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testDecodeReturnsFalse_WhenOnlyAZeroBytePresent() { 256c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 257c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 258c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x00); 259c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 260c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertFalse(unit.decodeContentType(0)); 261c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 262c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 263c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testConstrainedMediaExtensionMedia() throws Exception { 264c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 265c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String testType = "application/wibble"; 266c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 267c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.getBytes("US-ASCII")); 268c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 269c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 270c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 271c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 272c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 273c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(testType, mimeType); 274c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(-1, unit.getValue32()); 275c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(19, unit.getDecodedDataLength()); 276c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 277c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 278c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormShortLengthExtensionMedia() throws Exception { 279c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 280c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String testType = "12345678901234567890123456789"; 281c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 282c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.length() + 1); 283c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.getBytes("US-ASCII")); 284c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 285c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 286c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 287c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 288c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 289c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 290c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(testType, mimeType); 291c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(-1, unit.getValue32()); 292c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(31, unit.getDecodedDataLength()); 293c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 294c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 295c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormShortLengthWellKnownShortInteger() { 296c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 297c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 298c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); 299c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 300c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 301c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 302c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 303c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 304c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 305c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 306c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 307c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(2, unit.getDecodedDataLength()); 308c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 309c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 310c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 311c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormShortLengthWellKnownShortIntegerWithUnknownValue() { 312c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 313c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 314c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); 315c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_UNASSIGNED | WSP_SHORT_INTEGER_MASK); 316c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 317c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 318c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 319c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 320c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 321c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertNull(mimeType); 322c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_UNASSIGNED, unit.getValue32()); 323c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(2, unit.getDecodedDataLength()); 324c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 325c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 326c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 327c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormShortLengthWellKnownLongInteger() { 328c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 329c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 330c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 331c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x03); // header length 332c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x02); // type length (2 octets) 333c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML >> 8); 334c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML & 0xFF); 335c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 336c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 337c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 338c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 339c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 340c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 341c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("application/oma-directory+xml", mimeType); 342c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(LONG_MIME_TYPE_OMA_DIRECTORY_XML, unit.getValue32()); 343c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(4, unit.getDecodedDataLength()); 344c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 345c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 346c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormShortLengthWellKnownLongIntegerWithUnknownValue() { 347c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 348c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 349c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 350c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x03); // Value-length, short-length 351c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x02); // long-integer length (2 octets) 352c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_UNASSIGNED >> 8); 353c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_UNASSIGNED & 0xFF); 354c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 355c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 356c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 357c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 358c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 359c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 360c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertNull(mimeType); 361c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(LONG_MIME_TYPE_UNASSIGNED, unit.getValue32()); 362c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(4, unit.getDecodedDataLength()); 363c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 364c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 365c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 366c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteWellKnownShortInteger() { 367c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 368c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 369c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 370c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 371c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); // Length as UINTVAR 372c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 373c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 374c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 375c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 376c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 377c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 378c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 379c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 380c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(3, unit.getDecodedDataLength()); 381c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 382c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 383c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 384c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteWellKnownShortIntegerWithUnknownValue() { 385c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 386c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 387c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 388c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 389c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); // Length as UINTVAR 390c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_UNASSIGNED | WSP_SHORT_INTEGER_MASK); 391c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 392c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 393c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 394c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 395c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 396c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertNull(mimeType); 397c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_UNASSIGNED, unit.getValue32()); 398c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(3, unit.getDecodedDataLength()); 399c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 400c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 401c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteWellKnownLongInteger() { 402c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 403c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 404c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 405c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 406c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x03); // Length as UINTVAR 407c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x02); // long-integer length (2 octets) 408c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML >> 8); 409c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_OMA_DIRECTORY_XML & 0xFF); 410c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 411c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 412c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 413c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 414c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 415c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 416c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("application/oma-directory+xml", mimeType); 417c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(LONG_MIME_TYPE_OMA_DIRECTORY_XML, unit.getValue32()); 418c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(5, unit.getDecodedDataLength()); 419c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 420c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 421c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 422c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteWellKnownLongIntegerWithUnknownValue() { 423c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 424c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 425c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 426c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 427c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x03); // Length as UINTVAR 428c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x02); // long-integer length (2 octets) 429c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_UNASSIGNED >> 8); 430c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(LONG_MIME_TYPE_UNASSIGNED & 0xFF); 431c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 432c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 433c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 434c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 435c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 436c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 437c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertNull(mimeType); 438c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(LONG_MIME_TYPE_UNASSIGNED, unit.getValue32()); 439c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(5, unit.getDecodedDataLength()); 440c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 441c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 442c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 443c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteExtensionMedia() throws Exception { 444c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 445c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String testType = "application/wibble"; 446c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 447c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 448c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 449c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.length() + 1); // Length as UINTVAR 450c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 451c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.getBytes("US-ASCII")); 452c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 453c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 454c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 455c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 456c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 457c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 458c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 459c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(testType, mimeType); 460c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(-1, unit.getValue32()); 461c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(21, unit.getDecodedDataLength()); 462c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 463c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 464c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 465c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testGeneralFormLengthQuoteExtensionMediaWithNiceLongMimeType() throws Exception { 466c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 467c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String testType = 468c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville "01234567890123456789012345678901234567890123456789012345678901234567890123456789" 469c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville +"01234567890123456789012345678901234567890123456789012345678901234567890123456789"; 470c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 471c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 472c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_LENGTH_QUOTE); 473c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x81); // Length as UINTVAR (161 decimal, 0xA1), 2 bytes 474c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x21); 475c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 476c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.getBytes("US-ASCII")); 477c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 478c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 479c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 480c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 481c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 482c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 483c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 484c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(testType, mimeType); 485c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(-1, unit.getValue32()); 486c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(164, unit.getDecodedDataLength()); 487c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 488c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 489c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 490c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testConstrainedMediaExtensionMediaWithSpace() throws Exception { 491c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 492c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String testType = " application/wibble"; 493c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 494c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(testType.getBytes("US-ASCII")); 495c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 496c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 497c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 498c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 499c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 500c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 501c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 502c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(testType, mimeType); 503c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(-1, unit.getValue32()); 504c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(20, unit.getDecodedDataLength()); 505c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 506c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 507c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 508c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownShortIntegerNoValue() { 509c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 510c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 511c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x03); // Value-length, short-length 512c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 513c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK); 514c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(PARAM_NO_VALUE); 515c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 516c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 517c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 518c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 519c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 520c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 521c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 522c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 523c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 524c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(4, unit.getDecodedDataLength()); 525c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 526c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 527c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(null, params.get("Domain")); 528c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 529c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 530c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 531c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownShortIntegerTokenText() throws Exception { 532c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 533c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 534c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x14); // Value-length, short-length 535c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 536c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK); 537c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 538c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 539c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 540c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 541c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 542c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 543c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 544c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 545c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 546c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 547c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 548c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(out.toByteArray().length, unit.getDecodedDataLength()); 549c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 550c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 551c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("wdstechnology.com", params.get("Domain")); 552c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 553c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 554c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 555c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownLongIntegerTokenText() throws Exception { 556c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 557c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 558c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x15); 559c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 560c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); 561c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_DOMAIN); 562c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 563c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 564c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 565c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 566c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 567c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 568c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 569c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 570c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 571c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 572c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 573c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(22, unit.getDecodedDataLength()); 574c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 575c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 576c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("wdstechnology.com", params.get("Domain")); 577c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 578c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 579c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 580c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownShortIntegerQuotedText() throws Exception { 581c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 582c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 583c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x15); 584c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 585c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_DOMAIN | WSP_SHORT_INTEGER_MASK); 586c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_QUOTE); 587c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 588c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 589c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 590c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 591c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 592c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 593c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 594c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 595c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 596c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(0x3F, unit.getValue32()); 597c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(22, unit.getDecodedDataLength()); 598c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 599c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 600c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("wdstechnology.com", params.get("Domain")); 601c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 602c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 603c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 604c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownShortIntegerCompactIntegerValue() { 605c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 606c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 607c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x3); 608c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 609c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK); 610c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01 | WSP_SHORT_INTEGER_MASK); 611c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 612c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 613c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 614c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 615c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 616c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 617c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 618c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(0x3F, unit.getValue32()); 619c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(4, unit.getDecodedDataLength()); 620c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 621c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 622c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("1", params.get("SEC")); 623c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 624c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 625c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 6260fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig public void testTypedParamWellKnownShortIntegerCompactIntegerValue_0() { 6270fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig ByteArrayOutputStream out = new ByteArrayOutputStream(); 6280fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig out.write(0x3); 6290fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 6300fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK); 6310fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig out.write(0x00 | WSP_SHORT_INTEGER_MASK); 6320fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig 6330fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 6340fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig assertTrue(unit.decodeContentType(0)); 6350fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig 6360fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig String mimeType = unit.getValueString(); 6370fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig 6380fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 6390fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig assertEquals(0x3F, unit.getValue32()); 6400fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig assertEquals(4, unit.getDecodedDataLength()); 6410fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig 6420fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig Map<String, String> params = unit.getContentParameters(); 6430fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig assertEquals("0", params.get("SEC")); 6440fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig } 6450fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig 646c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamWellKnownShortIntegerMultipleParameters() throws Exception { 647c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 648c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 649c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x0B); 650c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 651c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_SEC | WSP_SHORT_INTEGER_MASK); 652c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01 | WSP_SHORT_INTEGER_MASK); 653c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_MAC | WSP_SHORT_INTEGER_MASK); 654c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_QUOTE); 655c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("imapc".getBytes("US-ASCII")); 656c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 657c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 658c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 659c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 660c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 661c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 662c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 663c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 664c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 665c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(12, unit.getDecodedDataLength()); 666c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 667c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 668c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("1", params.get("SEC")); 669c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("imapc", params.get("MAC")); 670c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 671c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 672c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testUntypedParamIntegerValueShortInteger() throws Exception { 673c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 674c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x0A); 675c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 676c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 677c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); // EOS 678c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x45 | WSP_SHORT_INTEGER_MASK); 679c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 680c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 681c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 682c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 683c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 684c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 685c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 686c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 687c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(11, unit.getDecodedDataLength()); 688c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 689c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 690c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("69", params.get("MYPARAM")); 691c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 692c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 693c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testUntypedParamIntegerValueLongInteger() throws Exception { 694c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 695c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x0C); 696c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 697c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 698c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 699c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x02); // Short Length 700c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x42); // Long Integer byte 1 701c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x69); // Long Integer byte 2 702c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 703c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 704c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 705c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 706c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 707c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 708c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 709c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(0x3F, unit.getValue32()); 710c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(13, unit.getDecodedDataLength()); 711c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 712c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 713c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("17001", params.get("MYPARAM")); 714c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 715c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 716c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testUntypedParamTextNoValue() throws Exception { 717c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 718c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x0A); 719c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 720c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 721c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 722c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(PARAM_NO_VALUE); 723c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 724c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 725c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 726c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 727c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 728c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 729c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 730c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(11, unit.getDecodedDataLength()); 731c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 732c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 733c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(null, params.get("MYPARAM")); 734c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 735c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 736c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 737c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testUntypedParamTextTokenText() throws Exception { 738c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 739c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x11); 740c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 741c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 742c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 743c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("myvalue".getBytes("US-ASCII")); 744c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 745c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 746c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 747c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 748c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 749c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 750c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 751c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 752c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(18, unit.getDecodedDataLength()); 753c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 754c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 755c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("myvalue", params.get("MYPARAM")); 756c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 757c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 758c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testUntypedParamTextQuotedString() throws Exception { 759c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 760c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x11); 761c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 762c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 763c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 764c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_QUOTE); 765c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("myvalue".getBytes("US-ASCII")); 766c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 767c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 768c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 769c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 770c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 771c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 772c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 773c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 774c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(19, unit.getDecodedDataLength()); 775c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 776c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 777c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("myvalue", params.get("MYPARAM")); 778c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 779c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 780c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 781c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testDecodesReturnsFalse_ForParamWithMissingValue() throws Exception { 782c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 783c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x09); 784c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 785c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("MYPARAM".getBytes("US-ASCII")); 786c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 787c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 788c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 789c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertFalse(unit.decodeContentType(0)); 790c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 791c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 792c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamTextQValue() { 793c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 794c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x04); 795c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 796c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(TYPED_PARAM_Q); 797c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x83); // Q value byte 1 798c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x31); // Q value byte 2 799c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 800c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 801c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 802c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 803c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 804c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 805c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(0x3F, unit.getValue32()); 806c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(5, unit.getDecodedDataLength()); 807c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 808c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 809c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("433", params.get("Q")); 810c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 811c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 812c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 813c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamUnassignedWellKnownShortIntegerTokenText() throws Exception { 814c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 815c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 816c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x14); 817c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 818c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(PARAM_UNASSIGNED | WSP_SHORT_INTEGER_MASK); 819c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 820c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 821c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 822c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 823c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 824c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 825c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 826c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 827c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 828c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 829c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 830c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(21, unit.getDecodedDataLength()); 831c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 832c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 833c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("wdstechnology.com", params.get("unassigned/0x42")); 834c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 835c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 836c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 837c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testTypedParamUnassignedWellKnownLongIntegerTokenText() throws Exception { 838c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 839c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 840c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x15); 841c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 842c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); // Short-length of well-known parameter token 843c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(PARAM_UNASSIGNED); 844c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 845c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(WSP_STRING_TERMINATOR); 846c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 847c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 848c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertTrue(unit.decodeContentType(0)); 849c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 850c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String mimeType = unit.getValueString(); 851c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 852c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(STRING_MIME_TYPE_ROLLOVER_CERTIFICATE, mimeType); 853c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE, unit.getValue32()); 854c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 855c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals(22, unit.getDecodedDataLength()); 856c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 857c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Map<String, String> params = unit.getContentParameters(); 858c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertEquals("wdstechnology.com", params.get("unassigned/0x42")); 859c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 860c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 861c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void testDecodesReturnsFalse_WhenParamValueNotTerminated() throws Exception { 862c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 863c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ByteArrayOutputStream out = new ByteArrayOutputStream(); 864c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x15); 865c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(SHORT_MIME_TYPE_ROLLOVER_CERTIFICATE | WSP_SHORT_INTEGER_MASK); 866c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(0x01); 867c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write(PARAM_UNASSIGNED); 868c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville out.write("wdstechnology.com".getBytes("US-ASCII")); 869c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 870c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville WspTypeDecoder unit = new WspTypeDecoder(out.toByteArray()); 871c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville assertFalse(unit.decodeContentType(0)); 872c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 8730fcf2097e7e217319b625d5dfc24aded06c02227Johan Redestig} 874