public void testMapCreationNullClass() { try { CollectionUtil.mapWithKeysAndValues(null, (String[]) null, (String[]) null); fail(); } catch (IllegalArgumentException ex) { // expected } }
public void testCaseInsensitiveMapCreation() { List strings = Arrays.asList(new String[] {"foo"}); Map m = CollectionUtil.mapWithKeysAndValues( CaseInsensitiveMap.class, strings.iterator(), strings.iterator()); assertEquals("foo", m.get("foo")); assertEquals("foo", m.get("Foo")); assertEquals("foo", m.get("FOO")); }
public void testMapCreationWithoutElements() { Map m = CollectionUtil.mapWithKeysAndValues(HashMap.class, (List) null, (List) null); assertTrue(m.isEmpty()); }
static { synchronized (HttpConstants.class) { String[] strings = new String[] { HEADER_ACCEPT, HEADER_ACCEPT_CHARSET, HEADER_ACCEPT_ENCODING, HEADER_ACCEPT_LANGUAGE, HEADER_AUTHORIZATION, HEADER_CACHE_CONTROL, HEADER_CONNECTION, HEADER_COOKIE, HEADER_DATE, HEADER_EXPECT, HEADER_FROM, HEADER_HOST, HEADER_IF_MATCH, HEADER_IF_MODIFIED_SINCE, HEADER_IF_NONE_MATCH, HEADER_IF_RANGE, HEADER_IF_UNMODIFIED_SINCE, HEADER_MAX_FORWARDS, HEADER_PRAGMA, HEADER_PROXY_AUTHORIZATION, HEADER_RANGE, HEADER_REFERER, HEADER_TE, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, HEADER_UPGRADE, HEADER_USER_AGENT, HEADER_VIA, HEADER_WARNING }; REQUEST_HEADER_NAMES = Collections.unmodifiableMap( CollectionUtil.mapWithKeysAndValues(CaseInsensitiveMap.class, strings, strings)); strings = new String[] { HEADER_ACCEPT_RANGES, HEADER_AGE, HEADER_ALLOW, HEADER_CACHE_CONTROL, HEADER_CONNECTION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LANGUAGE, HEADER_COOKIE_SET, HEADER_CONTENT_LOCATION, HEADER_CONTENT_MD5, HEADER_CONTENT_RANGE, HEADER_DATE, HEADER_ETAG, HEADER_EXPIRES, HEADER_LAST_MODIFIED, HEADER_LOCATION, HEADER_PRAGMA, HEADER_PROXY_AUTHENTICATE, HEADER_RETRY_AFTER, HEADER_SERVER, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, HEADER_UPGRADE, HEADER_VARY, HEADER_VIA, HEADER_WARNING, HEADER_WWW_AUTHENTICATE }; RESPONSE_HEADER_NAMES = Collections.unmodifiableMap( CollectionUtil.mapWithKeysAndValues(CaseInsensitiveMap.class, strings, strings)); strings = new String[] { HEADER_ALLOW, HEADER_CACHE_CONTROL, HEADER_CONNECTION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LANGUAGE, HEADER_CONTENT_LENGTH, HEADER_CONTENT_LOCATION, HEADER_CONTENT_MD5, HEADER_CONTENT_RANGE, HEADER_CONTENT_TYPE, HEADER_DATE, HEADER_EXPIRES, HEADER_KEEP_ALIVE, HEADER_LAST_MODIFIED, HEADER_PRAGMA, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, HEADER_UPGRADE, HEADER_VIA, HEADER_WARNING }; Map allHeaders = CollectionUtil.mapWithKeysAndValues(CaseInsensitiveMap.class, strings, strings); allHeaders.putAll(REQUEST_HEADER_NAMES); allHeaders.putAll(RESPONSE_HEADER_NAMES); ALL_HEADER_NAMES = Collections.unmodifiableMap(allHeaders); } }