You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.xml 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <project name="excelant-tests" basedir="." xmlns:poi="antlib:org.apache.poi.ss.excelant">
  3. <path id="excelant.classpath">
  4. <pathelement location="build/classes"/>
  5. <pathelement location="build/ooxml-classes"/>
  6. <pathelement location="build/excelant-classes"/>
  7. <pathelement location="build/excelant-test-classes"/> <!-- test udf is in the test classes -->
  8. </path>
  9. <typedef resource="org/apache/poi/ss/excelant/antlib.xml"
  10. classpathref="excelant.classpath"
  11. uri="antlib:org.apache.poi.ss.excelant"/>
  12. <!-- Should fail because the fileName attribute is missing -->
  13. <target name="test-nofile">
  14. <poi:excelant>
  15. </poi:excelant>
  16. </target>
  17. <!-- Should fail because the specified file is invalid -->
  18. <target name="test-filenotfound">
  19. <poi:excelant fileName="invalid.xls">
  20. </poi:excelant>
  21. </target>
  22. <!-- basic evaluation test -->
  23. <target name="test-evaluate">
  24. <poi:excelant fileName="test-data/spreadsheet/excelant.xls">
  25. <poi:test showSuccessDetails="true">
  26. <poi:setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
  27. <poi:setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
  28. <poi:setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
  29. <poi:evaluate showDelta="true" cell="'MortgageCalculator'!$B$4"
  30. expectedValue="2285.576149" precision="1.0E-4" />
  31. </poi:test>
  32. </poi:excelant>
  33. </target>
  34. <target name="test-precision">
  35. <poi:excelant fileName="test-data/spreadsheet/excelant.xls">
  36. <poi:precision value="1.0E-4"/>
  37. <poi:test name="global-precision" showFailureDetail="true" showSuccessDetails="true">
  38. <poi:setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
  39. <poi:setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
  40. <poi:setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
  41. <poi:evaluate showDelta="true" cell="'MortgageCalculator'!$B$4"
  42. expectedValue="2285.576149"/>
  43. </poi:test>
  44. <poi:test name="custom-precision" showFailureDetail="true" showSuccessDetails="true">
  45. <poi:setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
  46. <poi:setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
  47. <poi:setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
  48. <poi:evaluate showDelta="true" cell="'MortgageCalculator'!$B$4"
  49. expectedValue="2285.576149" precision="1.0E-5"/>
  50. </poi:test>
  51. <poi:test name="tiny-precision" showFailureDetail="true" showSuccessDetails="true">
  52. <poi:setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
  53. <poi:setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
  54. <poi:setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
  55. <poi:evaluate showDelta="true" cell="'MortgageCalculator'!$B$4"
  56. expectedValue="2285.576149" precision="1.0E-10"/>
  57. </poi:test>
  58. </poi:excelant>
  59. </target>
  60. <!--
  61. By default ExcelAnt does not terminate execution if an error occurs
  62. -->
  63. <target name="test-passonerror">
  64. <poi:excelant fileName="test-data/spreadsheet/excelant.xls">
  65. <poi:test name="failonerror" showFailureDetail="true" showSuccessDetails="true">
  66. <poi:setDouble cell="'MortageCalculatorFunction'!$D$1" value="1"/>
  67. <poi:setDouble cell="'MortageCalculatorFunction'!$D$2" value="2"/>
  68. <poi:setFormula cell="'MortageCalculatorFunction'!$D$3" value ="SUM(D1:D2)"/>
  69. <poi:evaluate showDelta="true" cell="'MortageCalculatorFunction'!$D$3" expectedValue="2"/>
  70. </poi:test>
  71. </poi:excelant>
  72. </target>
  73. <!--
  74. failOnError="true" forces ExcelAnt tot terminate execution if an error occurs
  75. -->
  76. <target name="test-failonerror">
  77. <poi:excelant fileName="test-data/spreadsheet/excelant.xls" failOnError="true">
  78. <poi:test name="failonerror" showFailureDetail="true" showSuccessDetails="true">
  79. <poi:setDouble cell="'MortageCalculatorFunction'!$D$1" value="1"/>
  80. <poi:setDouble cell="'MortageCalculatorFunction'!$D$2" value="2"/>
  81. <poi:setFormula cell="'MortageCalculatorFunction'!$D$3" value ="SUM(D1:D2)"/>
  82. <poi:evaluate showDelta="true" cell="'MortageCalculatorFunction'!$D$3" expectedValue="2"/>
  83. </poi:test>
  84. </poi:excelant>
  85. </target>
  86. <!-- Evaluation of user-defined functions -->
  87. <target name="test-udf">
  88. <poi:excelant fileName="test-data/spreadsheet/excelant.xls">
  89. <poi:udf functionAlias="calculatePayment"
  90. className="org.apache.poi.ss.examples.formula.CalculateMortgage"/>
  91. <poi:test>
  92. <poi:setDouble cell="'MortageCalculatorFunction'!$B$1" value="240000"/>
  93. <poi:setDouble cell="'MortageCalculatorFunction'!$B$2" value ="0.11"/>
  94. <poi:setDouble cell="'MortageCalculatorFunction'!$B$3" value ="30"/>
  95. <poi:evaluate showDelta="true" cell="'MortageCalculatorFunction'!$B$4"
  96. expectedValue="2285.576149" precision="1.0E-4" />
  97. </poi:test>
  98. </poi:excelant>
  99. </target>
  100. </project>