/**
 *
 */
package com.stanfy.serverapi.response.handler;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLConnection;

import com.google.gson.GsonXml;
import com.google.gson.GsonXmlBuilder;
import com.stanfy.app.beans.EnroscarBean;
import com.stanfy.serverapi.response.ModelTypeToken;


/**
 * Content handler that uses {@link GsonXml}.
 * @author Roman Mazur (Stanfy - http://stanfy.com)
 */
@EnroscarBean(XmlGsonContentHandler.BEAN_NAME)
public class XmlGsonContentHandler extends BaseContentHandler {

  /** Response handler. */
  public static final String BEAN_NAME = "XmlGsonContentHandler";

  /** GsonXml instance. */
  private GsonXml gsonXml;

  protected GsonXml createGsonXml() {
    return new GsonXmlBuilder().setDateFormat(DEFAULT_DATE_FORMAT).create();
  }

  @Override
  protected Object getContent(final URLConnection connection, final InputStream source, final ModelTypeToken modelType) throws IOException {
    if (gsonXml == null) {
      throw new IllegalStateException("Gson object is not created");
    }
    return gsonXml.fromXml(new InputStreamReader(source, getCharset()), getModelType(modelType));
  }

  @Override
  public void onInititializationFinished() {
    super.onInititializationFinished();
    this.gsonXml = createGsonXml();
  }

}

@@ -174,16 +174,144 @@
 ction;%0A%0A
+import org.xmlpull.v1.XmlPullParser;%0Aimport org.xmlpull.v1.XmlPullParserException;%0Aimport org.xmlpull.v1.XmlPullParserFactory;%0A%0A
 import c
@@ -334,16 +334,16 @@
 sonXml;%0A
-
 import c
@@ -415,16 +415,60 @@
 arBean;%0A
+import com.stanfy.gsonxml.XmlParserCreator;%0A
 import c
@@ -826,16 +826,368 @@
 dler%22;%0A%0A
+  /** Parser factory. */%0A  protected static final XmlParserCreator PARSER_FACTORY = new XmlParserCreator() %7B%0A    @Override%0A    public XmlPullParser createParser() %7B%0A      try %7B%0A        return XmlPullParserFactory.newInstance().newPullParser();%0A      %7D catch (final XmlPullParserException e) %7B%0A        throw new RuntimeException(e);%0A      %7D%0A    %7D%0A  %7D;%0A%0A
   /** Gs
@@ -1267,24 +1267,24 @@
 GsonXml() %7B%0A
-
     return n
@@ -1303,16 +1303,52 @@
 ilder().
+setXmlParserCreator(PARSER_FACTORY).
 setDateF

Use XmlPullParserFactory since it's implemented by robolectric.