Example #1
0
  @Test
  public void readDocument() {
    QDomDocument doc = new QDomDocument("mydocument");
    QFile file = new QFile("classpath:generator/typesystem_core.txt");
    if (!file.open(OpenModeFlag.ReadOnly)) return;
    Result res = doc.setContent(file);
    if (!res.success) {
      file.close();
      assertTrue("Failed to open file", false);
      return;
    }

    QDomNodeList list = doc.elementsByTagName("access");

    boolean found = false;

    for (int i = 0; i < list.size(); i++) {
      QDomElement element = list.at(i).toElement();

      found = found || "private".equals(element.attribute("modifier"));
    }

    assertTrue(found);

    file.close();
  }
Example #2
0
  @Test
  public void makeDocument() {
    QDomDocument doc = new QDomDocument("MyML");
    QDomElement root = doc.createElement("MyML");
    doc.appendChild(root);

    QDomElement tag = doc.createElement("Greeting");
    root.appendChild(tag);

    QDomText t = doc.createTextNode("Hello World");
    tag.appendChild(t);

    QDomComment c = doc.createComment("comment");
    root.appendChild(c);

    compare(
        "<!DOCTYPE MyML>\n"
            + "<MyML>\n"
            + "<Greeting>Hello World</Greeting>\n"
            + "<!--comment-->\n"
            + "</MyML>\n",
        doc.toString());
  }