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.

TestBuildFile.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package org.apache.poi.ss.excelant;
  19. /**
  20. * JUnit test for the ExcelAnt tasks.
  21. * Leverages Ant's test framework.
  22. *
  23. * @see <a href="http://svn.apache.org/repos/asf/ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java">
  24. * http://svn.apache.org/repos/asf/ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java</a>
  25. */
  26. public class TestBuildFile extends BuildFileTest {
  27. public void setUp() {
  28. configureProject("src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml");
  29. }
  30. public void testMissingFilename() {
  31. expectSpecificBuildException("test-nofile", "required argument not specified",
  32. "fileName attribute must be set!");
  33. }
  34. public void testFileNotFound() {
  35. expectSpecificBuildException("test-filenotfound", "required argument not specified",
  36. "Cannot load file invalid.xls. Make sure the path and file permissions are correct.");
  37. }
  38. public void testEvaluate() {
  39. executeTarget("test-evaluate");
  40. assertLogContaining("Using input file: test-data/spreadsheet/excelant.xls");
  41. assertLogContaining("Succeeded when evaluating 'MortgageCalculator'!$B$4.");
  42. }
  43. public void testPrecision() {
  44. executeTarget("test-precision");
  45. assertLogContaining("Using input file: test-data/spreadsheet/excelant.xls");
  46. assertLogContaining("Succeeded when evaluating 'MortgageCalculator'!$B$4. " +
  47. "It evaluated to 2285.5761494145563 when the value of 2285.576149 with precision of 1.0E-4");
  48. assertLogContaining("Succeeded when evaluating 'MortgageCalculator'!$B$4. " +
  49. "It evaluated to 2285.5761494145563 when the value of 2285.576149 with precision of 1.0E-5");
  50. assertLogContaining("Failed to evaluate cell 'MortgageCalculator'!$B$4. " +
  51. "It evaluated to 2285.5761494145563 when the value of 2285.576149 with precision of 1.0E-10 was expected.");
  52. assertLogContaining("2/3 tests passed");
  53. }
  54. public void testPassOnError() {
  55. executeTarget("test-passonerror");
  56. }
  57. public void testFailOnError() {
  58. expectBuildException("test-failonerror", "fail on error");
  59. }
  60. public void testUdf() {
  61. executeTarget("test-udf");
  62. assertLogContaining("1/1 tests passed");
  63. }
  64. }