@Test public void consume() throws IOException { setHttpResponseEntity("text/plain;charset="); mockStatic(IOUtils.class); when(IOUtils.toString(inputStreamMock, Consts.ISO_8859_1.name())).thenReturn("doc"); httpResponseConsumer .setHttpResponse(httpResponseMock) .setDestinationFile(null) .setResponseCharacterSet(null) .consume(result); assertEquals("doc", result.get(RETURN_RESULT)); }
public void consume(Map<String, String> result) throws IOException { if (httpResponse.getEntity() != null) { if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { Header contentType = httpResponse.getEntity().getContentType(); if (contentType != null) { String value = contentType.getValue(); NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE); for (NameValuePair nameValuePair : nameValuePairs) { if (nameValuePair.getName().equalsIgnoreCase("charset")) { responseCharacterSet = nameValuePair.getValue(); break; } } } if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { responseCharacterSet = Consts.ISO_8859_1.name(); } } consumeResponseContent(result); } }
HttpResponseConsumer { public void consume(Map<String, String> result) throws IOException { if (httpResponse.getEntity() != null) { if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { Header contentType = httpResponse.getEntity().getContentType(); if (contentType != null) { String value = contentType.getValue(); NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE); for (NameValuePair nameValuePair : nameValuePairs) { if (nameValuePair.getName().equalsIgnoreCase("charset")) { responseCharacterSet = nameValuePair.getValue(); break; } } } if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { responseCharacterSet = Consts.ISO_8859_1.name(); } } consumeResponseContent(result); } } }
HttpResponseConsumer { public void consume(Map<String, String> result) throws IOException { if (httpResponse.getEntity() != null) { if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { Header contentType = httpResponse.getEntity().getContentType(); if (contentType != null) { String value = contentType.getValue(); NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE); for (NameValuePair nameValuePair : nameValuePairs) { if (nameValuePair.getName().equalsIgnoreCase("charset")) { responseCharacterSet = nameValuePair.getValue(); break; } } } if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { responseCharacterSet = Consts.ISO_8859_1.name(); } } consumeResponseContent(result); } }  }
HttpResponseConsumer { public void consume(Map<String, String> result) throws IOException { if (httpResponse.getEntity() != null) { if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { Header contentType = httpResponse.getEntity().getContentType(); if (contentType != null) { String value = contentType.getValue(); NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE); for (NameValuePair nameValuePair : nameValuePairs) { if (nameValuePair.getName().equalsIgnoreCase("charset")) { responseCharacterSet = nameValuePair.getValue(); break; } } } if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { responseCharacterSet = Consts.ISO_8859_1.name(); } } consumeResponseContent(result); } }  HttpResponseConsumer setHttpResponse(HttpResponse httpResponse); HttpResponseConsumer setResponseCharacterSet(String responseCharacterSet); HttpResponseConsumer setDestinationFile(String destinationFile); void consume(Map<String, String> result); }
HttpResponseConsumer { public void consume(Map<String, String> result) throws IOException { if (httpResponse.getEntity() != null) { if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { Header contentType = httpResponse.getEntity().getContentType(); if (contentType != null) { String value = contentType.getValue(); NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE); for (NameValuePair nameValuePair : nameValuePairs) { if (nameValuePair.getName().equalsIgnoreCase("charset")) { responseCharacterSet = nameValuePair.getValue(); break; } } } if (responseCharacterSet == null || responseCharacterSet.isEmpty()) { responseCharacterSet = Consts.ISO_8859_1.name(); } } consumeResponseContent(result); } }  HttpResponseConsumer setHttpResponse(HttpResponse httpResponse); HttpResponseConsumer setResponseCharacterSet(String responseCharacterSet); HttpResponseConsumer setDestinationFile(String destinationFile); void consume(Map<String, String> result);  }