### Question:
LoggingOutInterceptor extends AbstractLoggingInterceptor { public void handleMessage(Message message) { final OutputStream os = message.getContent(OutputStream.class); final Writer iowriter = message.getContent(Writer.class); if (os == null && iowriter == null) { return; } Logger logger = getMessageLogger(message); if (logger != null && (logger.isLoggable(Level.INFO) || writer != null)) { boolean hasLogged = message.containsKey(LOG_SETUP); if (!hasLogged) { message.put(LOG_SETUP, Boolean.TRUE); if (os != null) { final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os); if (threshold > 0) { newOut.setThreshold(threshold); } if (limit > 0) { newOut.setCacheLimit(limit); } message.setContent(OutputStream.class, newOut); newOut.registerCallback(new LoggingCallback(logger, message, os)); } else { message.setContent(Writer.class, new LogWriter(logger, message, iowriter)); } } } } LoggingOutInterceptor(String phase);  LoggingOutInterceptor();  LoggingOutInterceptor(int lim);  LoggingOutInterceptor(PrintWriter w); void handleMessage(Message message);  }### Answer:
@Test public void testFormattingOverrideLogWriter() throws Exception { LoggingOutInterceptor p = new CustomFormatLoggingOutInterceptor(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); p.setPrintWriter(new PrintWriter(baos)); StringWriter sw = new StringWriter(); sw.append("<today/>"); Endpoint endpoint = control.createMock(Endpoint.class); EndpointInfo endpointInfo = control.createMock(EndpointInfo.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes(); control.replay(); Message message = new MessageImpl(); message.setExchange(new ExchangeImpl()); message.put(Message.CONTENT_TYPE, "application/xml"); message.setContent(Writer.class, sw); p.handleMessage(message); Writer w = message.getContent(Writer.class); w.close(); String str = baos.toString(); assertTrue(str.contains("<tomorrow/>")); }