Examples of GsonXmlBuilder


Examples of com.stanfy.gsonxml.GsonXmlBuilder

    assertEquals(1, places.places.size());
  }

  @Test
  public void emptyRootList() {
    List<String> empty = new GsonXmlBuilder()
      .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
      .setRootArrayPrimitive(true)
      .create()
      .fromXml("<root></root>", new TypeToken<List<String>>() { }.getType());

    assertTrue(empty.isEmpty());

    empty = new GsonXmlBuilder()
      .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
      .setSameNameLists(false)
      .create()
      .fromXml("<root></root>", new TypeToken<List<String>>() { }.getType());
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    List<Place> places2;
  }

  @Test
  public void twoListsAsSameNamesFirstEmpty() {
    final TwoListPlacesContainer places = new GsonXmlBuilder()
        .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
        .setSameNameLists(true)
        .create()
        .fromXml("<root> <p1></p1> <p1 id=\"2\" /> <p2></p2> </root>", TwoListPlacesContainer.class);
    assertEquals(2, places.places1.size());
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    assertEquals(2, places.places1.get(1).id);
  }

  @Test
  public void twoListsAsSameNamesFirstNotEmpty() {
    final TwoListPlacesContainer places = new GsonXmlBuilder()
        .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
        .setSameNameLists(true)
        .create()
        .fromXml("<root> <p1 id=\"2\" /> <p1></p1> <p2></p2> <p2 id=\"3\"></p2> </root>", TwoListPlacesContainer.class);
    assertEquals(2, places.places1.size());
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    assertEquals(3, places.places2.get(1).id);
  }

  @Test
  public void twoListsAsGroupElement() {
    final TwoListPlacesContainer places = new GsonXmlBuilder()
        .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
        .create()
        .fromXml("<root> <p1><item/><item id=\"2\" /></p1> <p2><item/></p2> </root>", TwoListPlacesContainer.class);
    assertEquals(2, places.places1.size());
    assertEquals(2, places.places1.get(1).id);
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    final Rss feed = createGsonXml().fromXml(new InputStreamReader(RssTest.class.getResourceAsStream("rss-response.xml"), "UTF-8"), Rss.class);
    assertEquals(20, feed.channel.items.size());
  }

  private GsonXml createGsonXml() {
    return new GsonXmlBuilder()
        .wrap(
            new GsonBuilder().setDateFormat("EEE, dd MMM yyyy HH:mm:ss Z")
         )
        .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
        .setSameNameLists(true)
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

  static GsonXml createGson() {
    return createGson(false);
  }
  static GsonXml createGson(final boolean namespaces) {
    return new GsonXmlBuilder().setXmlParserCreator(PARSER_CREATOR).setTreatNamespaces(namespaces).create();
  }
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

  }


  @Test
  public void shouldHandleNestedSameNameLists() {
    GsonXml gsonXml = new GsonXmlBuilder().setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR).setSameNameLists(true).create();
    One res = gsonXml.fromXml(TEST_XML_NESTED_SAME_NAME_LIST, One.class);
    assertThat(res).isNotNull();
    assertThat(res.date).isEqualTo(1);

    assertThat(res.twos).isNotEmpty();
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    List<TwoPrimitive> twos;
  }

  @Test
  public void shouldHandlePrimitiveNestedSameNameLists() {
    GsonXml gsonXml = new GsonXmlBuilder().setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR).setPrimitiveArrays(true).setSameNameLists(true).create();
    OnePrimitive res = gsonXml.fromXml(TEST_XML_NESTED_PRIMITIVE_SAME_NAME_LIST, OnePrimitive.class);
    assertThat(res).isNotNull();
    assertThat(res.date).isEqualTo(2);

    assertThat(res.twos).isNotEmpty();
View Full Code Here

Examples of com.stanfy.gsonxml.GsonXmlBuilder

    List<Entry> entries;
  }

  @Test
  public void soTest() {
    final Feed feed = new GsonXmlBuilder()
        .setXmlParserCreator(SimpleXmlReaderTest.PARSER_CREATOR)
        .setSameNameLists(true)
        .create()
        .fromXml(XML, Feed.class);
    assertEquals("newest questions tagged android - Stack Overflow", feed.title.text);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.