]> source.dussan.org Git - poi.git/commitdiff
Remove null-checks that can never be reached
authorDominik Stadler <centic@apache.org>
Thu, 29 May 2014 09:15:33 +0000 (09:15 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 29 May 2014 09:15:33 +0000 (09:15 +0000)
add test for ExcelAnt setString

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1598225 13f79535-47bb-0310-9956-ffa450edef68

src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java
src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml

index 34a379353c20ff4b3cfa9b8d26c60b0cec1d70e7..e79a30bd1aafb337b2eff812259bfe930fe8cfb7 100644 (file)
@@ -105,7 +105,7 @@ public class ExcelAntTask extends Task {
                                                    Project.MSG_ERR ) ;
                        return ;
                }
-               if( tests != null && tests.size() > 0 ) {
+               if( tests.size() > 0 ) {
                        
                        Iterator<ExcelAntTest> testsIt = tests.iterator() ;
                        while( testsIt.hasNext() ) {
@@ -115,15 +115,13 @@ public class ExcelAntTask extends Task {
                
                                workbookUtil = ExcelAntWorkbookUtilFactory.getInstance( excelFileName ) ;
                                
-                               if( functions != null ) {
-                                       Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
-                                       while( functionsIt.hasNext() ) {
-                                               ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
-                                               try {
-                                                       workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName() ) ;
-                                               } catch ( Exception e) {
-                                                       throw new BuildException( e.getMessage(), e ); 
-                                               }
+                               Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
+                               while( functionsIt.hasNext() ) {
+                                       ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
+                                       try {
+                                               workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName() ) ;
+                                       } catch ( Exception e) {
+                                               throw new BuildException( e.getMessage(), e ); 
                                        }
                                }
                                test.setWorkbookUtil( workbookUtil ) ;
@@ -158,16 +156,14 @@ public class ExcelAntTask extends Task {
                                      getLocation());
         }
 
-               Workbook workbook;
                File workbookFile = new File( excelFileName ) ;
         try {
             FileInputStream fis = new FileInputStream( workbookFile ) ;
-            workbook = WorkbookFactory.create( fis ) ;
+            return WorkbookFactory.create( fis ) ;
         } catch (Exception e) {
             throw new BuildException("Cannot load file " + excelFileName
                     + ". Make sure the path and file permissions are correct.", e, getLocation());
         }
-               return workbook ;
        }
 
 
index 651a2319d524858612eaae36687f0e317306b915..732eead09d3b92fc9e6fe1ffb825f00e66b53a41 100644 (file)
@@ -73,4 +73,9 @@ public class TestBuildFile extends BuildFileTest {
         executeTarget("test-udf");\r
         assertLogContaining("1/1 tests passed");\r
     }\r
+    \r
+    public void testSetText() {\r
+        executeTarget("test-settext");\r
+        assertLogContaining("1/1 tests passed");\r
+    }\r
 }\r
index de0e616aecc8c755c2d38f56cfb0b632a0a909d6..6d938897f87057737886e299994b58a79fd2b630 100644 (file)
@@ -135,4 +135,14 @@ under the License.
          </poi:excelant>
       </target>
 
+    <!-- basic evaluation test -->
+    <target name="test-settext">
+        <poi:excelant fileName="${data.dir.name}/spreadsheet/excelant.xls">
+            <poi:test showSuccessDetails="true">
+                <poi:setString cell="'MortgageCalculator'!$B$1" value="sometext"/>
+               <!-- How can we evaluate text? -->
+            </poi:test>
+         </poi:excelant>
+      </target>
+
 </project>