Package com.google.gwt.xml.client

Examples of com.google.gwt.xml.client.Document


   public void parse() throws Exception {
      // Arrange
      String xmlContent = convertXMLFileToString("/someXML.xml");

      // Act
      Document document = XMLParser.parse(xmlContent);

      // Assert
      Element documentElement = document.getDocumentElement();
      assertEquals("beans", documentElement.getTagName());

      Element beans = (Element) document.getFirstChild();
      assertEquals("beans", beans.getTagName());
      assertNull(beans.getNextSibling());
      assertNull(beans.getPreviousSibling());

      Element testBean = document.getElementById("testBean");
      NodeList beanList = document.getElementsByTagName("bean");

      assertEquals(2, beanList.getLength());
      assertEquals("testBean", beanList.item(0).getAttributes().getNamedItem("id").getNodeValue());
      assertEquals("bean", testBean.getTagName());
      assertEquals("bean", testBean.getNodeName());
View Full Code Here


   public void parseSimple() {
      // Arrange
      String simpleXML = "<tags><tag>value</tag></tags>";

      // Act
      Document doc = XMLParser.parse(simpleXML);

      // Assert
      NodeList tags = doc.getElementsByTagName("tag");
      assertEquals("<tag>value</tag>", tags.item(0).toString());
      Text text = (Text) tags.item(0).getChildNodes().item(0);
      assertEquals("value", text.getData());
      assertEquals("#text", tags.item(0).getFirstChild().getNodeName());
      assertEquals("<tags><tag>value</tag></tags>", doc.getDocumentElement().toString());

      assertEquals(doc.getDocumentElement(), tags.item(0).getOwnerDocument().getDocumentElement());
   }
View Full Code Here

   }

   @Test
   public void removeWhitespace() throws Exception {
      // Arrange
      Document document = XMLParser.createDocument();
      Element child = document.createElement("child");
      child.setNodeValue("     ");
      document.appendChild(child);
      Element child2 = document.createElement("child");
      child2.appendChild(document.createCDATASection("    "));
      document.appendChild(child2);

      // Pre-Assert : empty TextNode should exists
      assertEquals(1, child.getChildNodes().getLength());
      assertEquals(1, child2.getChildNodes().getLength());
View Full Code Here

public class XMLElementTest extends GwtTestTest {

   @Test
   public void elementToString() {
      // Arrange
      Document document = XMLParser.createDocument();
      Element e = document.createElement("ThisIsATest");
      e.appendChild(document.createTextNode("SomeTextNode"));

      // Act
      String toString = e.toString();

      // Assert
View Full Code Here

   }

   @Test
   public void emptyElementToString() {
      // Arrange
      Document document = XMLParser.createDocument();
      Element e = document.createElement("ThisIsATest");

      // Act
      String toString = e.toString();

      // Assert
View Full Code Here

   }

   @Test
   public void setAttribute() {
      // Arrange
      Document document = XMLParser.createDocument();
      Element element = document.createElement("elem");

      // Act
      element.setAttribute("myAttr", "myValue");

      // Assert
View Full Code Here

public class XMLDocumentTest extends GwtTestTest {

   @Test
   public void createCDATASection() {
      // Arrange
      Document document = XMLParser.createDocument();

      // Act
      CDATASection cdata = document.createCDATASection("my cdata Value");

      // Assert
      assertEquals("my cdata Value", cdata.getData());
      assertEquals(document.getDocumentElement(), cdata.getOwnerDocument().getDocumentElement());
   }
View Full Code Here

   }

   @Test
   public void createElement() {
      // Arrange
      Document document = XMLParser.createDocument();

      // Act
      Element element = document.createElement("elem");

      // Assert
      assertEquals("elem", element.getTagName());
      assertEquals(document.getDocumentElement(), element.getOwnerDocument().getDocumentElement());
   }
View Full Code Here

   }

   @Test
   public void createTextNode() {
      // Arrange
      Document document = XMLParser.createDocument();

      // Act
      Text text = document.createTextNode("my text");

      // Assert
      assertEquals("my text", text.getData());
      assertEquals(document.getDocumentElement(), text.getOwnerDocument().getDocumentElement());
   }
View Full Code Here

      assertEquals(document.getDocumentElement(), text.getOwnerDocument().getDocumentElement());
   }

   @Test
   public void documentToString() {
      Document document = XMLParser.createDocument();
      Element e = document.createElement("ThisIsATest");
      e.appendChild(document.createTextNode("SomeTextNode"));
      document.appendChild(e);

      assertEquals("<ThisIsATest>SomeTextNode</ThisIsATest>", document.toString());
   }
View Full Code Here

TOP

Related Classes of com.google.gwt.xml.client.Document

Copyright © 2018 www.massapicom. 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.