Package com.singularsys.exttests
Class MathMLTest
- java.lang.Object
-
- com.singularsys.exttests.MathMLTest
-
public class MathMLTest extends java.lang.Object
General testing suite for mathml parser builder.- Author:
- Richard Morris
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
PRINT_ALL
Prints detail information about tests carried outstatic boolean
RUN_KNOWN_FAILURES
Some tests depend on existence of a local style-sheet, set to null to disable testsstatic boolean
RUN_NETWORK_TESTS
Whether to run slow tests which need network access
-
Constructor Summary
Constructors Constructor Description MathMLTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertEqNodes(java.lang.String s, Node expected, Node actual)
void
biDirectionalTest(java.lang.String eqn, Node node, java.lang.String xml)
void
biDirectionalTest(java.lang.String eqn, java.lang.String xml)
boolean
compareRecursive(Node node1, Node node2)
java.lang.String
docToString(org.w3c.dom.Document doc, javax.xml.transform.Transformer t)
java.lang.String
fixLineEndings(java.lang.String s)
void
jepToXmlTest(java.lang.String eqn, Node node, java.lang.String xml)
void
jepToXmlTest(java.lang.String eqn, java.lang.String xml)
java.lang.String
removeEmptySpace(java.lang.String s)
void
setUp()
static void
setUpBeforeClass()
void
simpleBuilderTest(java.lang.String eqn, Node node, java.lang.String xml, javax.xml.transform.Transformer t)
void
testCN()
Test <cn> numbers elements.void
testCNbase8XJ()
void
testCNbaseXJ()
void
testCNcomplex()
void
testCNcomplexPolarXJ()
void
testCNconstantPi()
Support for Entities is currently broken.void
testCNe_notation()
void
testCNinteger()
void
testCNrationalXJ()
void
testCNrealXJ()
void
testDeclare()
Tests a declare elementvoid
testDeclareVector()
Tests parsing of <vector> element.void
testExponent()
void
testFunctionsExists()
Tests that every jep function will be converted to mathml.void
testInfinity()
void
testList()
Converts "[1,[2,3]]" to/from nested <list> elements.void
testLog()
void
testLog2()
void
testMath()
void
testMathDTD()
Tests using the MathML 2.0 DTD.void
testMathNS()
Convert to/from mathml with a namespace (xmlns) attribute specified.void
testMathNSP()
Convert to/from mathml with a namespace (xmlns) attribute specified and a '"m" prefix for MathML elements.void
testMatrix()
Tests >matrix< element.void
testMinus()
void
testMultipleDeclerations()
Tests conversion of multiple <declare> elements.void
testNaN()
void
testNegInfinityJX()
void
testNegInfinityXJ()
void
testOperatorsExists()
Tests that every jep operator will be converted to mathml.void
testPi()
void
testQuadratic()
Conversions of "x^2+4*x+4==0"void
testQuadraticRoot()
Converts "x==(-b-sqrt(b^2.0-4.0*a*c))/(2.0*a)" to-from mathml.void
testQuadraticToPresentation()
This test is only run if LOCAL_STYLESHEETS_DIR is not null and the mmlctop2_0.xsl style sheet from http://www.orcca.on.ca/MathML/software/mmlctop2_0.zip stylesheet is installed there.void
testRelnXJ()
Tests parsing of deprecated <reln> element.void
testRoot()
"sqrt(x)" is converted to from <apply><root/><ci>x</ci></apply>void
testSelector()
Tests a selector element for array indexingvoid
testSemantics()
Tests parsing of mathml inside a <semantics> element.void
testSetXJ()
Tests parsing of >set< element.void
testSin()
void
testSqrt()
void
testUminus()
void
testVector()
Tests >vector< element.void
testXHTML()
Parses mathml embedded in an xhtml document.void
testXHTML2()
Parses mathml embedded in an xhtml document.void
xmlToJepTest(java.lang.String eqn, Node expected, java.lang.String xml)
void
xmlToJepTest(java.lang.String eqn, java.lang.String xml)
-
-
-
Field Detail
-
PRINT_ALL
public static final boolean PRINT_ALL
Prints detail information about tests carried out- See Also:
- Constant Field Values
-
RUN_NETWORK_TESTS
public static final boolean RUN_NETWORK_TESTS
Whether to run slow tests which need network access- See Also:
- Constant Field Values
-
RUN_KNOWN_FAILURES
public static final boolean RUN_KNOWN_FAILURES
Some tests depend on existence of a local style-sheet, set to null to disable tests- See Also:
- Constant Field Values
-
-
Method Detail
-
setUpBeforeClass
public static void setUpBeforeClass() throws java.lang.Exception
- Throws:
java.lang.Exception
-
setUp
public void setUp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
fixLineEndings
public java.lang.String fixLineEndings(java.lang.String s)
-
removeEmptySpace
public java.lang.String removeEmptySpace(java.lang.String s)
-
docToString
public java.lang.String docToString(org.w3c.dom.Document doc, javax.xml.transform.Transformer t) throws javax.xml.transform.TransformerException
- Throws:
javax.xml.transform.TransformerException
-
simpleBuilderTest
public void simpleBuilderTest(java.lang.String eqn, Node node, java.lang.String xml, javax.xml.transform.Transformer t) throws javax.xml.transform.TransformerException, JepException
- Throws:
javax.xml.transform.TransformerException
JepException
-
jepToXmlTest
public void jepToXmlTest(java.lang.String eqn, Node node, java.lang.String xml) throws javax.xml.transform.TransformerException, JepException
- Throws:
javax.xml.transform.TransformerException
JepException
-
jepToXmlTest
public void jepToXmlTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.transform.TransformerException, JepException
- Throws:
javax.xml.transform.TransformerException
JepException
-
xmlToJepTest
public void xmlToJepTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, ParseException
- Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
ParseException
-
xmlToJepTest
public void xmlToJepTest(java.lang.String eqn, Node expected, java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
- Parameters:
eqn
-- Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
-
biDirectionalTest
public void biDirectionalTest(java.lang.String eqn, java.lang.String xml) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, JepException
- Throws:
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
JepException
-
biDirectionalTest
public void biDirectionalTest(java.lang.String eqn, Node node, java.lang.String xml) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, JepException
- Throws:
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
JepException
-
testCN
public final void testCN() throws java.lang.Exception
Test <cn> numbers elements.- Throws:
java.lang.Exception
-
testCNbaseXJ
public final void testCNbaseXJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNbase8XJ
public final void testCNbase8XJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNrealXJ
public final void testCNrealXJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNe_notation
public final void testCNe_notation() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNinteger
public final void testCNinteger() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNrationalXJ
public final void testCNrationalXJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNcomplex
public final void testCNcomplex() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNcomplexPolarXJ
public final void testCNcomplexPolarXJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCNconstantPi
public final void testCNconstantPi() throws java.lang.Exception
Support for Entities is currently broken.- Throws:
java.lang.Exception
-
testNaN
public final void testNaN() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testInfinity
public final void testInfinity() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testNegInfinityJX
public final void testNegInfinityJX() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testNegInfinityXJ
public final void testNegInfinityXJ() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testPi
public final void testPi() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testUminus
public final void testUminus() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testMinus
public final void testMinus() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testLog
public final void testLog() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testLog2
public final void testLog2() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testSin
public final void testSin() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testSqrt
public final void testSqrt() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testQuadratic
public final void testQuadratic() throws java.lang.Exception
Conversions of "x^2+4*x+4==0"- Throws:
java.lang.Exception
-
testQuadraticToPresentation
public final void testQuadraticToPresentation() throws java.lang.Exception
This test is only run if LOCAL_STYLESHEETS_DIR is not null and the mmlctop2_0.xsl style sheet from http://www.orcca.on.ca/MathML/software/mmlctop2_0.zip stylesheet is installed there.- Throws:
java.lang.Exception
-
testQuadraticRoot
public final void testQuadraticRoot() throws java.lang.Exception
Converts "x==(-b-sqrt(b^2.0-4.0*a*c))/(2.0*a)" to-from mathml. Note no ± equivalent in jep, jep will parse 4*a*c as (4*a)*c.- Throws:
java.lang.Exception
-
testRoot
public final void testRoot() throws java.lang.Exception
"sqrt(x)" is converted to from <apply><root/><ci>x</ci></apply>- Throws:
java.lang.Exception
-
testMatrix
public final void testMatrix() throws java.lang.Exception
Tests >matrix< element.- Throws:
java.lang.Exception
-
testVector
public final void testVector() throws java.lang.Exception
Tests >vector< element.- Throws:
java.lang.Exception
-
testList
public final void testList() throws java.lang.Exception
Converts "[1,[2,3]]" to/from nested <list> elements.- Throws:
java.lang.Exception
-
testSetXJ
public final void testSetXJ() throws java.lang.Exception
Tests parsing of >set< element.- Throws:
java.lang.Exception
-
testSelector
public final void testSelector() throws java.lang.Exception
Tests a selector element for array indexing- Throws:
java.lang.Exception
-
testDeclare
public final void testDeclare() throws java.lang.Exception
Tests a declare element- Throws:
java.lang.Exception
-
testDeclareVector
public final void testDeclareVector() throws java.lang.Exception
Tests parsing of <vector> element. Reverse fails as it misses the type="vector" attribute of the declare tag.- Throws:
java.lang.Exception
-
testRelnXJ
public final void testRelnXJ() throws java.lang.Exception
Tests parsing of deprecated <reln> element. In reverse relations are children of apply elements as per v2.0 .- Throws:
java.lang.Exception
-
testXHTML
public final void testXHTML() throws java.lang.Exception
Parses mathml embedded in an xhtml document.- Throws:
java.lang.Exception
-
testXHTML2
public final void testXHTML2() throws java.lang.Exception
Parses mathml embedded in an xhtml document.- Throws:
java.lang.Exception
-
testMath
public final void testMath() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testMathNS
public final void testMathNS() throws java.lang.Exception
Convert to/from mathml with a namespace (xmlns) attribute specified.- Throws:
java.lang.Exception
-
testMathNSP
public final void testMathNSP() throws java.lang.Exception
Convert to/from mathml with a namespace (xmlns) attribute specified and a '"m" prefix for MathML elements.- Throws:
java.lang.Exception
-
testSemantics
public final void testSemantics() throws java.lang.Exception
Tests parsing of mathml inside a <semantics> element.- Throws:
java.lang.Exception
-
testExponent
public final void testExponent() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testMultipleDeclerations
public final void testMultipleDeclerations() throws java.lang.Exception
Tests conversion of multiple <declare> elements.- Throws:
java.lang.Exception
-
testMathDTD
public final void testMathDTD() throws java.lang.Exception
Tests using the MathML 2.0 DTD. This needs to download the mathml dtd to run the parsing part which is only run if RUN_NETWORK_TESTS is true.- Throws:
java.lang.Exception
-
testFunctionsExists
public final void testFunctionsExists() throws java.lang.Exception
Tests that every jep function will be converted to mathml. If RUN_KNOWN_FAILURES is true it will fail otherwise prints list of unknown functions.- Throws:
java.lang.Exception
-
testOperatorsExists
public final void testOperatorsExists() throws java.lang.Exception
Tests that every jep operator will be converted to mathml. If RUN_KNOWN_FAILURES is true it will fail otherwise prints list of unknown operators.- Throws:
java.lang.Exception
-
-