@Test public void specialCharactersShouldBeParsedBackIntoContextMap() { final String header = "%C3%B6+%C3%BC%C3%A4%C3%9F=%C3%96+%C3%9C%C3%84%C3%9F%E2%82%AC,%21%22%C2%A7%24%25%26%40%2F%28+%29%3D%3F=%5E%C2%B0%2B*%27%23-.%2C%3B%3A_%3C%3E+%C2%B4%C2%B4%60%60"; final Map<String, String> context = UNIT.parse(header); assertThat(context, hasEntry("!\"§$%&@/( )=?", "^°+*'#-.,;:_<> ´´``")); assertThat(context, hasEntry("ö üäß", "Ö ÜÄß€")); }
Map<String, String> parse(String serialized) { final StringTokenizer pairTokenizer = new StringTokenizer(serialized.trim(), ","); final Map<String, String> context = new HashMap<>(); while (pairTokenizer.hasMoreTokens()) { final String pairStr = pairTokenizer.nextToken(); final String[] keyValuePair = pairStr.split("="); if (keyValuePair.length != 2) { continue; } try { final String key = URLDecoder.decode(keyValuePair[0], ENCODING_CHARSET); final String value = URLDecoder.decode(keyValuePair[1], ENCODING_CHARSET); context.put(key, value); } catch (UnsupportedEncodingException e) { LOGGER.error("Charset not found", e); } } return context; }
HttpHeaderTransport { Map<String, String> parse(String serialized) { final StringTokenizer pairTokenizer = new StringTokenizer(serialized.trim(), ","); final Map<String, String> context = new HashMap<>(); while (pairTokenizer.hasMoreTokens()) { final String pairStr = pairTokenizer.nextToken(); final String[] keyValuePair = pairStr.split("="); if (keyValuePair.length != 2) { continue; } try { final String key = URLDecoder.decode(keyValuePair[0], ENCODING_CHARSET); final String value = URLDecoder.decode(keyValuePair[1], ENCODING_CHARSET); context.put(key, value); } catch (UnsupportedEncodingException e) { LOGGER.error("Charset not found", e); } } return context; } }
HttpHeaderTransport { Map<String, String> parse(String serialized) { final StringTokenizer pairTokenizer = new StringTokenizer(serialized.trim(), ","); final Map<String, String> context = new HashMap<>(); while (pairTokenizer.hasMoreTokens()) { final String pairStr = pairTokenizer.nextToken(); final String[] keyValuePair = pairStr.split("="); if (keyValuePair.length != 2) { continue; } try { final String key = URLDecoder.decode(keyValuePair[0], ENCODING_CHARSET); final String value = URLDecoder.decode(keyValuePair[1], ENCODING_CHARSET); context.put(key, value); } catch (UnsupportedEncodingException e) { LOGGER.error("Charset not found", e); } } return context; }  }
HttpHeaderTransport { Map<String, String> parse(String serialized) { final StringTokenizer pairTokenizer = new StringTokenizer(serialized.trim(), ","); final Map<String, String> context = new HashMap<>(); while (pairTokenizer.hasMoreTokens()) { final String pairStr = pairTokenizer.nextToken(); final String[] keyValuePair = pairStr.split("="); if (keyValuePair.length != 2) { continue; } try { final String key = URLDecoder.decode(keyValuePair[0], ENCODING_CHARSET); final String value = URLDecoder.decode(keyValuePair[1], ENCODING_CHARSET); context.put(key, value); } catch (UnsupportedEncodingException e) { LOGGER.error("Charset not found", e); } } return context; }  Map<String, String> parse(List<String> serializedElements); String render(Map<String, String> context); }
HttpHeaderTransport { Map<String, String> parse(String serialized) { final StringTokenizer pairTokenizer = new StringTokenizer(serialized.trim(), ","); final Map<String, String> context = new HashMap<>(); while (pairTokenizer.hasMoreTokens()) { final String pairStr = pairTokenizer.nextToken(); final String[] keyValuePair = pairStr.split("="); if (keyValuePair.length != 2) { continue; } try { final String key = URLDecoder.decode(keyValuePair[0], ENCODING_CHARSET); final String value = URLDecoder.decode(keyValuePair[1], ENCODING_CHARSET); context.put(key, value); } catch (UnsupportedEncodingException e) { LOGGER.error("Charset not found", e); } } return context; }  Map<String, String> parse(List<String> serializedElements); String render(Map<String, String> context); static final String ENCODING_CHARSET; }