### Question:
KeyValueParser { public static Map<String,String> parseMap(String line) { Map<String,String> result = new LinkedHashMap<String,String>(); QuotedStringTokenizer tokenizer = new QuotedStringTokenizer(line, null, true, ",", false); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim(); int index = token.indexOf("="); if (index < 0) { String unquotedKey = tokenizer.unquoteToken(token); result.put(unquotedKey, null); } else if (index < (token.length()-1)) { String unquotedKey = tokenizer.unquoteToken(token.substring(0, index).trim()); String unquotedVal = tokenizer.unquoteToken(token.substring(index+1).trim()); result.put(unquotedKey, unquotedVal); } else { assert index == token.length() -1; String unquotedKey = tokenizer.unquoteToken(token.substring(0, index).trim()); result.put(unquotedKey, ""); } } return result; }  static String toLine(Map<String, String> parts); static String toLine(Collection<String> parts); static List<String> parseList(String line); @Deprecated // use parseMap static Map<String,String> parse(String line); static Map<String,String> parseMap(String line);  }### Answer:
@Test public void testTrimsWhiteSpaceOutsideOfQuotes() throws Exception { assertOrderedMapsEqual(KeyValueParser.parseMap("a=x"), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=x "), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap(" a=x"), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a =x"), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a= x"), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a = x"), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=\"x\""), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=\"x\" "), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap(" a=\"x\""), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a =\"x\""), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a= \"x\""), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a = \"x\""), ImmutableMap.of("a", "x")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=x,b=y"), ImmutableMap.of("a", "x", "b", "y")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=x, b=y"), ImmutableMap.of("a", "x", "b", "y")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=x,\tb=y"), ImmutableMap.of("a", "x", "b", "y")); assertOrderedMapsEqual(KeyValueParser.parseMap("a=x ,b=y"), ImmutableMap.of("a", "x", "b", "y")); }
@Test public void testPreservesWhiteSpaceInsideQuotes() throws Exception { assertOrderedMapsEqual(KeyValueParser.parseMap("a=\" x \""), ImmutableMap.of("a", " x ")); }