@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)); }