DefaultJGroupsHeaderMapper implements JGroupsHeaderMapper { public Map<String, Object> toHeaders(Message source) { HashMap<String, Object> map = new HashMap<String, Object>(); Address src = source.getSrc(); if (src != null) { map.put("src", src); } Address dest = source.getDest(); if (dest != null) { map.put("dest", dest); } map.put(OOB_HEADER, source.isFlagSet(Flag.OOB)); map.put(DONT_BUNDLE_HEADER, source.isFlagSet(Flag.DONT_BUNDLE)); map.put(NO_FC_HEADER, source.isFlagSet(Flag.NO_FC)); map.put(NO_RELAY_HEADER, source.isFlagSet(Flag.NO_RELAY)); map.put(NO_RELIABILITY_HEADER, source.isFlagSet(Flag.NO_RELIABILITY)); map.put(NO_TOTAL_ORDER_HEADER, source.isFlagSet(Flag.NO_TOTAL_ORDER)); map.put(RSVP_HEADER, source.isFlagSet(Flag.RSVP)); map.put(SCOPED_HEADER, source.isFlagSet(Flag.SCOPED)); return map; }  void fromHeaders(MessageHeaders headers, Message target); Map<String, Object> toHeaders(Message source);  }
@Test public void should_map_to_src_address() throws Exception { DefaultJGroupsHeaderMapper headerMapper = new DefaultJGroupsHeaderMapper(); IpAddress src = new IpAddress(Inet4Address.getByName("192.168.0.1"), 6666); Message source = new Message(null, src, null); Map<String, Object> headers = headerMapper.toHeaders(source); assertThat(headers).includes(entry("src", src)); }
@Test public void should_map_to_dest_address() throws Exception { DefaultJGroupsHeaderMapper headerMapper = new DefaultJGroupsHeaderMapper(); IpAddress dest = new IpAddress(Inet4Address.getByName("192.168.0.1"), 6666); Message source = new Message(dest, null, null); Map<String, Object> headers = headerMapper.toHeaders(source); assertThat(headers).includes(entry("dest", dest)); }