@Test public void testWriteShouldContentToWriter() throws IOException { doReturn(OUTPUT_FILE).when(underTest).getOutputFileName(MESSAGE_ID, true); given(bufferedWriterFactory.createBufferedWriter(OUTPUT_FILE, OUTPUT_BUFFER_SIZE)).willReturn(bufferedWriter); given(response.getWilmaMessageLoggerId()).willReturn(MESSAGE_ID); given(response.getWilmaMessageId()).willReturn(MESSAGE_ID); given(response.getBody()).willReturn(BODY); underTest.write(response, true); verify(bufferedWriter).append(WilmaHttpRequest.WILMA_LOGGER_ID + ":" + MESSAGE_ID); verify(bufferedWriter).append("{" + HEADERS + "=" + HEADERS + "}\n+{" + EXTRA_HEADERS + "=" + EXTRA_HEADERS + "}\n-[" + EXTRA_HEADERS_REMOVE + "]"); verify(bufferedWriter).append(BODY); }
@Override public boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed) { boolean successful = false; String outputFile = INITIAL_FILENAME; try { String messageLoggerId = response.getWilmaMessageLoggerId(); String messageId = response.getWilmaMessageId(); outputFile = getOutputFileName(messageLoggerId, bodyDecompressed); BufferedWriter writer = bufferedWriterFactory.createBufferedWriter(outputFile, OUTPUT_BUFFER_SIZE); if (writer != null) { writeWilmaLoggerId(writer, messageId); String headers = prepareHeadersInfo(response); writeHeaders(writer, headers); int statusCode = response.getStatusCode(); writeStatusCode(statusCode, writer); String body = response.getBody(); writeBody(writer, body); writer.close(); successful = true; } } catch (IOException e) { logger.error("Could not write message to file:" + outputFile + "!", e); } return successful; }
WilmaHttpResponseWriter extends WilmaHttpEntityWriter<WilmaHttpResponse> { @Override public boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed) { boolean successful = false; String outputFile = INITIAL_FILENAME; try { String messageLoggerId = response.getWilmaMessageLoggerId(); String messageId = response.getWilmaMessageId(); outputFile = getOutputFileName(messageLoggerId, bodyDecompressed); BufferedWriter writer = bufferedWriterFactory.createBufferedWriter(outputFile, OUTPUT_BUFFER_SIZE); if (writer != null) { writeWilmaLoggerId(writer, messageId); String headers = prepareHeadersInfo(response); writeHeaders(writer, headers); int statusCode = response.getStatusCode(); writeStatusCode(statusCode, writer); String body = response.getBody(); writeBody(writer, body); writer.close(); successful = true; } } catch (IOException e) { logger.error("Could not write message to file:" + outputFile + "!", e); } return successful; } }
WilmaHttpResponseWriter extends WilmaHttpEntityWriter<WilmaHttpResponse> { @Override public boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed) { boolean successful = false; String outputFile = INITIAL_FILENAME; try { String messageLoggerId = response.getWilmaMessageLoggerId(); String messageId = response.getWilmaMessageId(); outputFile = getOutputFileName(messageLoggerId, bodyDecompressed); BufferedWriter writer = bufferedWriterFactory.createBufferedWriter(outputFile, OUTPUT_BUFFER_SIZE); if (writer != null) { writeWilmaLoggerId(writer, messageId); String headers = prepareHeadersInfo(response); writeHeaders(writer, headers); int statusCode = response.getStatusCode(); writeStatusCode(statusCode, writer); String body = response.getBody(); writeBody(writer, body); writer.close(); successful = true; } } catch (IOException e) { logger.error("Could not write message to file:" + outputFile + "!", e); } return successful; }  }
WilmaHttpResponseWriter extends WilmaHttpEntityWriter<WilmaHttpResponse> { @Override public boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed) { boolean successful = false; String outputFile = INITIAL_FILENAME; try { String messageLoggerId = response.getWilmaMessageLoggerId(); String messageId = response.getWilmaMessageId(); outputFile = getOutputFileName(messageLoggerId, bodyDecompressed); BufferedWriter writer = bufferedWriterFactory.createBufferedWriter(outputFile, OUTPUT_BUFFER_SIZE); if (writer != null) { writeWilmaLoggerId(writer, messageId); String headers = prepareHeadersInfo(response); writeHeaders(writer, headers); int statusCode = response.getStatusCode(); writeStatusCode(statusCode, writer); String body = response.getBody(); writeBody(writer, body); writer.close(); successful = true; } } catch (IOException e) { logger.error("Could not write message to file:" + outputFile + "!", e); } return successful; }  @Override boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed); }
WilmaHttpResponseWriter extends WilmaHttpEntityWriter<WilmaHttpResponse> { @Override public boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed) { boolean successful = false; String outputFile = INITIAL_FILENAME; try { String messageLoggerId = response.getWilmaMessageLoggerId(); String messageId = response.getWilmaMessageId(); outputFile = getOutputFileName(messageLoggerId, bodyDecompressed); BufferedWriter writer = bufferedWriterFactory.createBufferedWriter(outputFile, OUTPUT_BUFFER_SIZE); if (writer != null) { writeWilmaLoggerId(writer, messageId); String headers = prepareHeadersInfo(response); writeHeaders(writer, headers); int statusCode = response.getStatusCode(); writeStatusCode(statusCode, writer); String body = response.getBody(); writeBody(writer, body); writer.close(); successful = true; } } catch (IOException e) { logger.error("Could not write message to file:" + outputFile + "!", e); } return successful; }  @Override boolean write(final WilmaHttpResponse response, final boolean bodyDecompressed);  }