Exemplo n.º 1
0
public class PublicIdTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.PUBLIC_ID)).matches("PUBLIC \"foo\"");
  }
}
Exemplo n.º 2
0
public class CDStartTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.CD_START)).matches("<![CDATA[").notMatches("<![cdata[");
  }
}
Exemplo n.º 3
0
public class EqTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.EQ))
        .matches("=")
        .matches("  =")
        .matches("=  ")
        .matches("   =    ");
  }
}
Exemplo n.º 4
0
public class CharRefTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.CHAR_REF))
        .matches("&#0;")
        .matches("&#123;")
        .matches("&#xF0bc;")
        .notMatches("&#AB;");
  }
}
Exemplo n.º 5
0
public class PITest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.PI))
        .matches("<?foo?>")
        .matches("<?foo bar?>")
        .matches("<?foo bar baz ?>")
        .notMatches("<??>")
        .notMatches("<?xml?>");
  }
}
Exemplo n.º 6
0
public class NameTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.NAME))
        .matches("foo")
        .matches("foo42")
        .matches(":")
        .matches("F")
        .matches("_")
        .matches("h")
        .matches("\u00D0")
        .matches("\u00D9")
        .notMatches("\u00D7")
        .notMatches("-")
        .notMatches("\u200E")
        .notMatches("foo?")
        .notMatches("foo ");
  }
}
Exemplo n.º 7
0
public class ElementDeclTest {

  Grammar g = XmlGrammar.createGrammarBuilder().build();

  @Test
  public void ok() {
    assertThat(g.rule(XmlGrammar.ELEMENT_DECL))
        .matches("<!ELEMENT br EMPTY>")
        .matches("<!ELEMENT p (#PCDATA|emph)* >")
        .matches("<!ELEMENT container ANY>")
        .matches("<!ELEMENT spec (front, body, back?)>")
        .matches("<!ELEMENT div1 (head, (p | list | note)*, div2*)>")
        .matches("<!ELEMENT p (#PCDATA|a|ul|b|i|em)*>")
        .matches("<!ELEMENT b (#PCDATA)>");
  }

  // TEST - FIXME: "Name does not match %, looks like a PEReference, email sent to xml-editors"
  public void w3() {
    assertThat(g.rule(XmlGrammar.ELEMENT_DECL))
        .matches("<!ELEMENT %name.para; %content.para; >")
        .matches("<!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*>")
        .matches("<!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >");
  }
}