Author: centic
Date: Sat Nov  2 20:58:22 2013
New Revision: 1538281

URL: http://svn.apache.org/r1538281
Log:
Add slightly more coverage for ExcelAntWorkbookUtil

Modified:
    
poi/trunk/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java

Modified: 
poi/trunk/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java?rev=1538281&r1=1538280&r2=1538281&view=diff
==============================================================================
--- 
poi/trunk/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java
 (original)
+++ 
poi/trunk/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java
 Sat Nov  2 20:58:22 2013
@@ -18,15 +18,16 @@ package org.apache.poi.ss.excelant.util;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 
 import junit.framework.TestCase;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.examples.formula.CalculateMortgageFunction;
 import org.apache.poi.ss.formula.udf.UDFFinder;
+import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -39,6 +40,7 @@ public class TestExcelAntWorkbookUtil ex
        private ExcelAntWorkbookUtilTestHelper fixture ;
                
        
+       @Override
        public void tearDown() {
                fixture = null ;
        }
@@ -48,9 +50,18 @@ public class TestExcelAntWorkbookUtil ex
                                                                  
mortgageCalculatorFileName ) ;
                
                assertNotNull( fixture ) ;
-               
        }
 
+       public void testLoadNotExistingFile() {
+               try {
+                       assertNotNull(new ExcelAntWorkbookUtilTestHelper( 
+                                                                 
"notexistingFile" ));
+                       fail("Should catch exception here");
+               } catch (BuildException e) {
+                       assertTrue(e.getMessage().contains("notexistingFile")); 
                
+               }
+       }
+       
        public void testWorkbookConstructor() throws InvalidFormatException, 
IOException {
         File workbookFile = new File(mortgageCalculatorFileName);
         FileInputStream fis = new FileInputStream(workbookFile);
@@ -112,6 +123,16 @@ public class TestExcelAntWorkbookUtil ex
                
        }
 
+       public void testGetEvaluatorXLSX() {
+               fixture = new ExcelAntWorkbookUtilTestHelper( 
+                "test-data/spreadsheet/sample.xlsx") ;
+               
+               FormulaEvaluator evaluator = fixture.getEvaluator( 
+                               "test-data/spreadsheet/sample.xlsx" ) ;
+               
+               assertNotNull( evaluator ) ;
+       }
+
        public void testEvaluateCell() {
                String cell = "'MortgageCalculator'!B4" ;
                double expectedValue = 790.79 ;
@@ -155,4 +176,43 @@ public class TestExcelAntWorkbookUtil ex
                assertEquals( cellValue, value ) ;
                
        }
+       
+       public void testSetDate() {
+               String cell = "'MortgageCalculator'!C14" ;
+               Date cellValue = new Date();
+               
+               fixture = new ExcelAntWorkbookUtilTestHelper( 
+                mortgageCalculatorFileName ) ;
+               
+               fixture.setDateValue( cell, cellValue ) ;
+               
+               double value = fixture.getCellAsDouble( cell ) ;
+               
+               assertNotNull( value ) ;
+               
+               assertEquals( DateUtil.getExcelDate(cellValue, false), value ) ;
+               
+       }
+
+       public void testGetNonexistingString() {
+               String cell = "'MortgageCalculator'!C33" ;
+               
+               fixture = new ExcelAntWorkbookUtilTestHelper( 
+                mortgageCalculatorFileName ) ;
+               
+               String value = fixture.getCellAsString( cell ) ;
+               
+               assertEquals( "", value ) ;
+       }
+
+       public void testGetNonexistingDouble() {
+               String cell = "'MortgageCalculator'!C33" ;
+               
+               fixture = new ExcelAntWorkbookUtilTestHelper( 
+                mortgageCalculatorFileName ) ;
+               
+               double value = fixture.getCellAsDouble( cell ) ;
+               
+               assertEquals( 0.0, value ) ;
+       }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to