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
This commit is contained in:
parent
f928ce1d34
commit
1d12d8b2aa
@ -105,7 +105,7 @@ public class ExcelAntTask extends Task {
|
|||||||
Project.MSG_ERR ) ;
|
Project.MSG_ERR ) ;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if( tests != null && tests.size() > 0 ) {
|
if( tests.size() > 0 ) {
|
||||||
|
|
||||||
Iterator<ExcelAntTest> testsIt = tests.iterator() ;
|
Iterator<ExcelAntTest> testsIt = tests.iterator() ;
|
||||||
while( testsIt.hasNext() ) {
|
while( testsIt.hasNext() ) {
|
||||||
@ -115,7 +115,6 @@ public class ExcelAntTask extends Task {
|
|||||||
|
|
||||||
workbookUtil = ExcelAntWorkbookUtilFactory.getInstance( excelFileName ) ;
|
workbookUtil = ExcelAntWorkbookUtilFactory.getInstance( excelFileName ) ;
|
||||||
|
|
||||||
if( functions != null ) {
|
|
||||||
Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
|
Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
|
||||||
while( functionsIt.hasNext() ) {
|
while( functionsIt.hasNext() ) {
|
||||||
ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
|
ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
|
||||||
@ -125,7 +124,6 @@ public class ExcelAntTask extends Task {
|
|||||||
throw new BuildException( e.getMessage(), e );
|
throw new BuildException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
test.setWorkbookUtil( workbookUtil ) ;
|
test.setWorkbookUtil( workbookUtil ) ;
|
||||||
|
|
||||||
if( precision != null && precision.getValue() > 0 ) {
|
if( precision != null && precision.getValue() > 0 ) {
|
||||||
@ -158,16 +156,14 @@ public class ExcelAntTask extends Task {
|
|||||||
getLocation());
|
getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
Workbook workbook;
|
|
||||||
File workbookFile = new File( excelFileName ) ;
|
File workbookFile = new File( excelFileName ) ;
|
||||||
try {
|
try {
|
||||||
FileInputStream fis = new FileInputStream( workbookFile ) ;
|
FileInputStream fis = new FileInputStream( workbookFile ) ;
|
||||||
workbook = WorkbookFactory.create( fis ) ;
|
return WorkbookFactory.create( fis ) ;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException("Cannot load file " + excelFileName
|
throw new BuildException("Cannot load file " + excelFileName
|
||||||
+ ". Make sure the path and file permissions are correct.", e, getLocation());
|
+ ". Make sure the path and file permissions are correct.", e, getLocation());
|
||||||
}
|
}
|
||||||
return workbook ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,4 +73,9 @@ public class TestBuildFile extends BuildFileTest {
|
|||||||
executeTarget("test-udf");
|
executeTarget("test-udf");
|
||||||
assertLogContaining("1/1 tests passed");
|
assertLogContaining("1/1 tests passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSetText() {
|
||||||
|
executeTarget("test-settext");
|
||||||
|
assertLogContaining("1/1 tests passed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,4 +135,14 @@ under the License.
|
|||||||
</poi:excelant>
|
</poi:excelant>
|
||||||
</target>
|
</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>
|
</project>
|
||||||
|
Loading…
Reference in New Issue
Block a user