@Test public void networkResponseShouldNotBeParsedWithUnsupportedException() throws JsonProcessingException { String content = "{\"imageUrl\":\"http: HashMap<String, String> headers = new HashMap<String, String>(); headers.put(HTTP.CONTENT_TYPE, "text/html;charset=UTF-14"); NetworkResponse networkResponse = new NetworkResponse(content.getBytes(), headers); Jackson2Request<News> request = new Jackson2Request<News>(url, News.class, listener); Response<News> response = request.parseNetworkResponse(networkResponse); assertNull(response.result); assertThat(response.error, is(instanceOf(ParseError.class))); assertThat(response.error.getCause(), is(instanceOf(UnsupportedEncodingException.class))); }
@Override protected Response<T> parseNetworkResponse(NetworkResponse response) { String charset = HttpHeaderParser.parseCharset(response.headers); Reader reader = null; try { reader = new InputStreamReader(new ByteArrayInputStream(response.data), charset); T result = objectMapper.readValue(reader, getTargetClass()); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new VolleyError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } }
Jackson2Request extends AbstractConverterRequest<T> { @Override protected Response<T> parseNetworkResponse(NetworkResponse response) { String charset = HttpHeaderParser.parseCharset(response.headers); Reader reader = null; try { reader = new InputStreamReader(new ByteArrayInputStream(response.data), charset); T result = objectMapper.readValue(reader, getTargetClass()); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new VolleyError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } }
Jackson2Request extends AbstractConverterRequest<T> { @Override protected Response<T> parseNetworkResponse(NetworkResponse response) { String charset = HttpHeaderParser.parseCharset(response.headers); Reader reader = null; try { reader = new InputStreamReader(new ByteArrayInputStream(response.data), charset); T result = objectMapper.readValue(reader, getTargetClass()); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new VolleyError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } Jackson2Request(int method, String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener);  Jackson2Request(int method, String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener, ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener); }
Jackson2Request extends AbstractConverterRequest<T> { @Override protected Response<T> parseNetworkResponse(NetworkResponse response) { String charset = HttpHeaderParser.parseCharset(response.headers); Reader reader = null; try { reader = new InputStreamReader(new ByteArrayInputStream(response.data), charset); T result = objectMapper.readValue(reader, getTargetClass()); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new VolleyError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } Jackson2Request(int method, String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener);  Jackson2Request(int method, String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener, ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener);  }
Jackson2Request extends AbstractConverterRequest<T> { @Override protected Response<T> parseNetworkResponse(NetworkResponse response) { String charset = HttpHeaderParser.parseCharset(response.headers); Reader reader = null; try { reader = new InputStreamReader(new ByteArrayInputStream(response.data), charset); T result = objectMapper.readValue(reader, getTargetClass()); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new VolleyError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } Jackson2Request(int method, String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, ObjectMapper objectMapper, Listener<T> listener);  Jackson2Request(int method, String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener, ErrorListener errorListener);  Jackson2Request(String url, Class<T> clazz, Listener<T> listener);   }