blob: 2596ecefe53df246ea4456ac2ebb7a671557bf3c [file] [log] [blame]
Narayan Kamathf7482572013-12-18 15:19:17 +00001/**
2 * Copyright (C) 2013 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 com.android.internal.util;
18
19import java.io.ByteArrayInputStream;
20import java.io.ByteArrayOutputStream;
21import java.io.InputStream;
22import java.util.HashMap;
23import java.util.Map;
24import junit.framework.TestCase;
25
26public class XmlUtilsTest extends TestCase {
27
28 // https://code.google.com/p/android/issues/detail?id=63717
29 public void testMapWithNullKeys() throws Exception {
30 ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
31 Map<String, Object> map = new HashMap<String, Object>();
32 map.put(null, "nullValue");
33 map.put("foo", "fooValue");
34 XmlUtils.writeMapXml(map, baos);
35
36 InputStream mapInput = new ByteArrayInputStream(baos.toByteArray());
37 HashMap<String, ?> deserialized = XmlUtils.readMapXml(mapInput);
38 assertEquals("nullValue", deserialized.get(null));
39 assertEquals("fooValue", deserialized.get("foo"));
40 }
41}