@SuppressWarnings("unchecked")
 @Test
 public void testNeedFilteringEnabledFiltering() {
   when(exchangeMock.getProperty(anyString(), anyObject(), any(Class.class))).thenReturn(true);
   jaxbDataFormat.setFilterNonXmlChars(true);
   jaxbDataFormat.needFiltering(exchangeMock);
   verify(exchangeMock).getProperty(Exchange.FILTER_NON_XML_CHARS, true, Boolean.class);
 }
  @Test
  public void testMarshalFilteringEnabled() throws XMLStreamException, JAXBException {
    doCallRealMethod()
        .when(jaxbDataFormatMock)
        .marshal(any(Exchange.class), anyObject(), any(OutputStream.class), any(Marshaller.class));
    when(jaxbDataFormatMock.needFiltering(exchangeMock)).thenReturn(true);

    Object graph = new Object();
    OutputStream stream = new ByteArrayOutputStream();

    jaxbDataFormatMock.marshal(exchangeMock, graph, stream, marshallerMock);
    verify(marshallerMock).marshal(same(graph), isA(FilteringXmlStreamWriter.class));
  }
  @Test
  public void testUnmarshalFilteringEnabled() throws IOException, JAXBException {
    doCallRealMethod()
        .when(jaxbDataFormatMock)
        .unmarshal(any(Exchange.class), any(InputStream.class));

    when(jaxbDataFormatMock.getContext()).thenReturn(jaxbContextMock);
    when(jaxbContextMock.createUnmarshaller()).thenReturn(unmarshallerMock);

    when(jaxbDataFormatMock.needFiltering(exchangeMock)).thenReturn(true);

    InputStream stream = new ByteArrayInputStream(new byte[] {});

    jaxbDataFormatMock.unmarshal(exchangeMock, stream);
    verify(unmarshallerMock).unmarshal(any(NonXmlFilterReader.class));
  }
  @SuppressWarnings("unchecked")
  @Test
  public void testNeedFilteringFalsePropagates() {
    // tests combinations of data format option and exchange property
    when(exchangeMock.getProperty(anyString(), anyObject(), any(Class.class))).thenReturn(false);

    assertFalse("Not expecting filtering here", jaxbDataFormat.needFiltering(exchangeMock));
  }
  @SuppressWarnings("unchecked")
  @Test
  public void testNeedFilteringDisabledFiltering() {
    // tests combinations of data format option and exchange property
    when(exchangeMock.getProperty(anyString(), anyObject(), any(Class.class))).thenReturn(false);

    jaxbDataFormat.needFiltering(exchangeMock);
    verify(exchangeMock).getProperty(Exchange.FILTER_NON_XML_CHARS, false, Boolean.class);
  }