@Test public void networkResponseShouldNotBeParsedWithAddtionalTag() throws JsonProcessingException { String content = "<news>\n" + " <imageUrl>http: " <title>Volley extention has released</title>\n" + " <summary>Good news</summary>\n" + "</news>"; NetworkResponse networkResponse = new NetworkResponse(content.getBytes()); SimpleXmlRequest<News> request = new SimpleXmlRequest<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(ElementException.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 = persister.read(getTargetClass(), reader); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (XmlPullParserException e) { return Response.error(new ParseError(e)); } catch (ElementException e) { return Response.error(new ParseError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } }
SimpleXmlRequest 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 = persister.read(getTargetClass(), reader); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (XmlPullParserException e) { return Response.error(new ParseError(e)); } catch (ElementException e) { return Response.error(new ParseError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } }
SimpleXmlRequest 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 = persister.read(getTargetClass(), reader); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (XmlPullParserException e) { return Response.error(new ParseError(e)); } catch (ElementException e) { return Response.error(new ParseError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener, 
			ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz,
			Listener<T> listener, ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz, Persister persister,
			Listener<T> listener, ErrorListener errorListener); }
SimpleXmlRequest 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 = persister.read(getTargetClass(), reader); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (XmlPullParserException e) { return Response.error(new ParseError(e)); } catch (ElementException e) { return Response.error(new ParseError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener, 
			ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz,
			Listener<T> listener, ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz, Persister persister,
			Listener<T> listener, ErrorListener errorListener);  }
SimpleXmlRequest 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 = persister.read(getTargetClass(), reader); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (XmlPullParserException e) { return Response.error(new ParseError(e)); } catch (ElementException e) { return Response.error(new ParseError(e)); } catch (Exception e) { return Response.error(new VolleyError(e)); } finally { IoUtils.closeQuietly(reader); } } SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener);  SimpleXmlRequest(String url, Class<T> clazz, Listener<T> listener,
			ErrorListener errorListener);  SimpleXmlRequest(String url, Class<T> clazz, Persister persister, Listener<T> listener, 
			ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz,
			Listener<T> listener, ErrorListener errorListener);  SimpleXmlRequest(int method, String url, Class<T> clazz, Persister persister,
			Listener<T> listener, ErrorListener errorListener);   }