1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package libcore.java.net; 18 19import java.net.CookieManager; 20import java.net.CookieStore; 21import java.net.InMemoryCookieStore; 22import java.net.URI; 23import java.util.ArrayList; 24import java.util.HashMap; 25import java.util.List; 26import java.util.Map; 27 28public class CookiesTest extends AbstractCookiesTest { 29 @Override 30 public CookieStore createCookieStore() { 31 return new InMemoryCookieStore(24 /* VERSION_CODES.N : android N */); 32 } 33 34 // http://b/26456024 35 public void testCookiesWithLeadingPeriod() throws Exception { 36 CookieManager cm = new CookieManager(createCookieStore(), null); 37 Map<String, List<String>> responseHeaders = new HashMap<>(); 38 List<String> list = new ArrayList<String>(); 39 list.add("coulomb_sess=81c112d7dabac869ffa821aa8f672df2"); 40 responseHeaders.put("Set-Cookie", list); 41 42 URI uri = new URI("http://chargepoint.com"); 43 cm.put(uri, responseHeaders); 44 45 Map<String, List<String>> cookies = cm.get( 46 new URI("https://webservices.chargepoint.com/backend.php/mobileapi/"), 47 responseHeaders); 48 49 assertEquals(1, cookies.size()); 50 List<String> cookieList = cookies.values().iterator().next(); 51 assertEquals("coulomb_sess=81c112d7dabac869ffa821aa8f672df2", cookieList.get(0)); 52 } 53} 54