### Question:
HttpContextMapper extends BaseRegexContextMapper<HttpBindingData> { @Override @SuppressWarnings("unchecked") public void mapTo(Context context, HttpBindingData target) throws Exception { Map<String, List<String>> httpHeaders = target.getHeaders(); for (Property property : context.getProperties()) { String name = property.getName(); Object value = property.getValue(); if ((value != null) && (matches(name) || property.hasLabel(EndpointLabel.HTTP.label()))) { if (HTTP_RESPONSE_STATUS.equalsIgnoreCase(name) && (target instanceof HttpResponseBindingData)) { HttpResponseBindingData response = (HttpResponseBindingData)target; if (value instanceof String) { response.setStatus(Integer.parseInt((String) value)); } else if (value instanceof Integer) { response.setStatus((Integer) value); } } else { if (value instanceof List) { List<String> vals = new ArrayList<String>(); List valueList = (List)value; for (Object obj : valueList) { if (obj instanceof String) { vals.add((String) obj); } else { vals.add(obj.toString()); } } httpHeaders.put(name, vals); } else if (value instanceof String) { List<String> list = new ArrayList<String>(); list.add(String.valueOf(value)); httpHeaders.put(name, list); } } } } }  @Override void mapFrom(HttpBindingData source, Context context); @Override @SuppressWarnings("unchecked") void mapTo(Context context, HttpBindingData target); static final String HTTP_RESPONSE_STATUS; }### Answer:
@Test public void mapStrings() throws Exception { _context.setProperty("foo", "boo"); HttpContextMapper hcm = new HttpContextMapper(); HttpRequestBindingData bindingData = new HttpRequestBindingData(); hcm.mapTo(_context, bindingData); Map<String, List<String>> headers = bindingData.getHeaders(); Iterator it = headers.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); ArrayList list = (ArrayList) pairs.getValue(); for (int i = 0; i < list.size(); i++) { assertTrue(list.get(i) instanceof String); } it.remove(); } }
@Test public void mapObjects() throws Exception { ArrayList obj = new ArrayList(); obj.add(new Integer(3)); _context.setProperty("foo", obj); HttpContextMapper hcm = new HttpContextMapper(); HttpRequestBindingData bindingData = new HttpRequestBindingData(); hcm.mapTo(_context, bindingData); Map<String, List<String>> headers = bindingData.getHeaders(); Iterator it = headers.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); ArrayList list = (ArrayList) pairs.getValue(); for (int i = 0; i < list.size(); i++) { assertTrue(list.get(i) instanceof String); } it.remove(); } }