aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2014-05-29 09:15:33 +0000
committerDominik Stadler <centic@apache.org>2014-05-29 09:15:33 +0000
commit5901b661580f39687469477f2a3a057d9300adb1 (patch)
treeb54c7e6ba3e7192aa866e11ce400c757e60d9178
parentd6771ca02712a97f6581059e4828230c97ee924c (diff)
downloadpoi-5901b661580f39687469477f2a3a057d9300adb1.tar.gz
poi-5901b661580f39687469477f2a3a057d9300adb1.zip
Remove null-checks that can never be reached
add test for ExcelAnt setString git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1598225 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java22
-rw-r--r--src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java5
-rw-r--r--src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml10
3 files changed, 24 insertions, 13 deletions
diff --git a/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java b/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
index 34a379353c..e79a30bd1a 100644
--- a/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
+++ b/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
@@ -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 ;
}
diff --git a/src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java b/src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java
index 651a2319d5..732eead09d 100644
--- a/src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java
+++ b/src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java
@@ -73,4 +73,9 @@ public class TestBuildFile extends BuildFileTest {
executeTarget("test-udf");
assertLogContaining("1/1 tests passed");
}
+
+ public void testSetText() {
+ executeTarget("test-settext");
+ assertLogContaining("1/1 tests passed");
+ }
}
diff --git a/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml b/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml
index de0e616aec..6d938897f8 100644
--- a/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml
+++ b/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml
@@ -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>