コード例 #1
0
  @Test
  public void testSen() throws Exception {
    TexQueryGenerator t = new TexQueryGenerator();
    final String withoutTexvc =
        "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" id=\"p1.m1\" class=\"ltx_Math\" alttext=\"\\sen\" display=\"inline\">\n"
            + "  <mtext>\\sen</mtext>\n"
            + "</math>";
    final String withTexv =
        "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" id=\"p1.m1\" class=\"ltx_Math\" alttext=\"\\sen\" display=\"inline\">\n"
            + "  <sin/>\n"
            + "</math>";
    List<NameValuePair> p = t.getParams();
    p.remove(new BasicNameValuePair("preload", "texvc"));
    t.setParams(p);

    try {
      t.request("\\sen");
    } catch (final IOException expected) {
      assertEquals("2", t.getOb().get("status_code"));
      assertEquals(withoutTexvc, t.getOb().get("result"));
      assertEquals(
          "Tex request to MathML conversion server produced failed response.",
          expected.getMessage());
    }

    t = new TexQueryGenerator();
    assertEquals(withTexv, t.request("\\sen"));
  }
コード例 #2
0
 @Test
 public void testEmpty() throws Exception {
   TexQueryGenerator t = new TexQueryGenerator();
   List<NameValuePair> p = t.getParams();
   p.clear();
   t.setParams(p);
   try {
     t.request("");
   } catch (final IOException expected) {
     assertEquals(3, t.getOb().get("status_code"));
     assertEquals("", t.getOb().get("result"));
     assertEquals(
         "Tex request to MathML conversion server produced failed response.",
         expected.getMessage());
   }
   p.add(new BasicNameValuePair("destroy", "LaTeXML"));
   t.setParams(p);
   try {
     t.request("");
   } catch (final IOException expected) {
     assertEquals(
         "Tex request to MathML conversion server produced failed response.",
         expected.getMessage());
     assertEquals(3, t.getOb().get("status_code"));
     assertEquals("", t.getOb().get("result"));
   }
 }
コード例 #3
0
 @Test
 public void testQuery() throws Exception {
   final TexQueryGenerator t = new TexQueryGenerator();
   final String mml =
       "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" id=\"p1.m1\" class=\"ltx_Math\" alttext=\"E=mc^{2}\" display=\"inline\">\n"
           + "  <apply>\n"
           + "    <eq/>\n"
           + "    <ci>E</ci>\n"
           + "    <apply>\n"
           + "      <times/>\n"
           + "      <ci>m</ci>\n"
           + "      <apply>\n"
           + "        <csymbol cd=\"ambiguous\">superscript</csymbol>\n"
           + "        <ci>c</ci>\n"
           + "        <cn type=\"integer\">2</cn>\n"
           + "      </apply>\n"
           + "    </apply>\n"
           + "  </apply>\n"
           + "</math>";
   assertEquals(mml, t.request("E=mc^2"));
   assertEquals(0, t.getOb().get("status_code"));
   assertEquals("No obvious problems", t.getOb().get("status"));
 }