diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-05-23 01:17:07 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-05-23 01:17:07 +0000 |
commit | a019fbf46b38f08991b7d46cd403150aa4fa2b4f (patch) | |
tree | cb19490c9e2070756aa878a8b574fc290d9cb9cf /poi-excelant/src | |
parent | fdacf6fcaab880f885de5cf7bf63a05f0af47e60 (diff) | |
download | poi-a019fbf46b38f08991b7d46cd403150aa4fa2b4f.tar.gz poi-a019fbf46b38f08991b7d46cd403150aa4fa2b4f.zip |
convert tabs to spaces
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1890128 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-excelant/src')
19 files changed, 790 insertions, 790 deletions
diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java index fe4109d945..249e86f5eb 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java @@ -32,105 +32,105 @@ import org.apache.tools.ant.Task; */ public class ExcelAntEvaluateCell extends Task { - private String cell ; - private double expectedValue ; - private double precision ; - private double globalPrecision ; - private boolean requiredToPass; - - - private ExcelAntEvaluationResult result ; - - private ExcelAntWorkbookUtil wbUtil ; - - private boolean showDelta; - - - public ExcelAntEvaluateCell() {} - - protected void setWorkbookUtil( ExcelAntWorkbookUtil wb ) { - wbUtil = wb ; - } - - public void setShowDelta( boolean value ) { - showDelta = value ; - } - - protected boolean showDelta() { - return showDelta ; - } - - public void setCell(String cell) { - this.cell = cell; - } - - public void setRequiredToPass( boolean val ) { - requiredToPass = val ; - } - - protected boolean requiredToPass() { - return requiredToPass ; - } - - public void setExpectedValue(double expectedValue) { - this.expectedValue = expectedValue; - } - - public void setPrecision(double precision) { - this.precision = precision; - } - - protected void setGlobalPrecision( double prec ) { - globalPrecision = prec ; - } - - protected String getCell() { - return cell; - } - - protected double getExpectedValue() { - return expectedValue; - } - - @SuppressWarnings("squid:S4275") - protected double getPrecision() { - // if there is a globalPrecision we will use it unless there is also - // precision set at the evaluate level, then we use that. If there - // is not a globalPrecision, we will use the local precision. - log( "test precision = " + precision + "\tglobal precision = " + globalPrecision, Project.MSG_VERBOSE ) ; - if( globalPrecision > 0 ) { - if( precision > 0 ) { - log( "Using evaluate precision of " + precision + " over the " + - "global precision of " + globalPrecision, Project.MSG_VERBOSE ) ; - return precision ; - } else { - log( "Using global precision of " + globalPrecision, Project.MSG_VERBOSE ) ; - return globalPrecision ; - } - } else { - log( "Using evaluate precision of " + precision, Project.MSG_VERBOSE ) ; - return precision ; - } - } - - @Override + private String cell ; + private double expectedValue ; + private double precision ; + private double globalPrecision ; + private boolean requiredToPass; + + + private ExcelAntEvaluationResult result ; + + private ExcelAntWorkbookUtil wbUtil ; + + private boolean showDelta; + + + public ExcelAntEvaluateCell() {} + + protected void setWorkbookUtil( ExcelAntWorkbookUtil wb ) { + wbUtil = wb ; + } + + public void setShowDelta( boolean value ) { + showDelta = value ; + } + + protected boolean showDelta() { + return showDelta ; + } + + public void setCell(String cell) { + this.cell = cell; + } + + public void setRequiredToPass( boolean val ) { + requiredToPass = val ; + } + + protected boolean requiredToPass() { + return requiredToPass ; + } + + public void setExpectedValue(double expectedValue) { + this.expectedValue = expectedValue; + } + + public void setPrecision(double precision) { + this.precision = precision; + } + + protected void setGlobalPrecision( double prec ) { + globalPrecision = prec ; + } + + protected String getCell() { + return cell; + } + + protected double getExpectedValue() { + return expectedValue; + } + + @SuppressWarnings("squid:S4275") + protected double getPrecision() { + // if there is a globalPrecision we will use it unless there is also + // precision set at the evaluate level, then we use that. If there + // is not a globalPrecision, we will use the local precision. + log( "test precision = " + precision + "\tglobal precision = " + globalPrecision, Project.MSG_VERBOSE ) ; + if( globalPrecision > 0 ) { + if( precision > 0 ) { + log( "Using evaluate precision of " + precision + " over the " + + "global precision of " + globalPrecision, Project.MSG_VERBOSE ) ; + return precision ; + } else { + log( "Using global precision of " + globalPrecision, Project.MSG_VERBOSE ) ; + return globalPrecision ; + } + } else { + log( "Using evaluate precision of " + precision, Project.MSG_VERBOSE ) ; + return precision ; + } + } + + @Override public void execute() throws BuildException { - result = wbUtil.evaluateCell(cell, expectedValue, getPrecision() ) ; + result = wbUtil.evaluateCell(cell, expectedValue, getPrecision() ) ; - StringBuilder sb = new StringBuilder() ; - sb.append( "evaluation of cell " ) ; - sb.append( cell ) ; - sb.append( " resulted in " ) ; - sb.append( result.getReturnValue() ) ; - if(showDelta) { - sb.append(" with a delta of ").append(result.getDelta()); - } + StringBuilder sb = new StringBuilder() ; + sb.append( "evaluation of cell " ) ; + sb.append( cell ) ; + sb.append( " resulted in " ) ; + sb.append( result.getReturnValue() ) ; + if(showDelta) { + sb.append(" with a delta of ").append(result.getDelta()); + } - log( sb.toString(), Project.MSG_DEBUG) ; + log( sb.toString(), Project.MSG_DEBUG) ; - } + } - public ExcelAntEvaluationResult getResult() { - return result ; - } + public ExcelAntEvaluationResult getResult() { + return result ; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java index f6fd1446af..bb2a01ea87 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java @@ -21,13 +21,13 @@ import org.apache.tools.ant.taskdefs.Typedef; public class ExcelAntPrecision extends Typedef { - private double value ; + private double value ; - public void setValue( double precision ) { - value = precision ; - } + public void setValue( double precision ) { + value = precision ; + } - public double getValue() { - return value ; - } + public double getValue() { + return value ; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java index 4908646289..5574e3c225 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java @@ -25,31 +25,31 @@ import org.apache.tools.ant.Project; * sheet cell using the cell id ('Sheet Name'!cellId). */ public class ExcelAntSetDoubleCell extends ExcelAntSet { - private double cellValue; - - public ExcelAntSetDoubleCell() {} - - /** - * Set the value of the specified cell as the double passed in. - * @param value The double-value that should be set when this task is executed. - */ - public void setValue( double value ) { - cellValue = value ; - } - - /** - * Return the cell value as a double. - * @return The double-value of the cell as populated via setValue(), null - * if the value was not set yet. - */ - public double getCellValue() { - return cellValue; - } - - @Override + private double cellValue; + + public ExcelAntSetDoubleCell() {} + + /** + * Set the value of the specified cell as the double passed in. + * @param value The double-value that should be set when this task is executed. + */ + public void setValue( double value ) { + cellValue = value ; + } + + /** + * Return the cell value as a double. + * @return The double-value of the cell as populated via setValue(), null + * if the value was not set yet. + */ + public double getCellValue() { + return cellValue; + } + + @Override public void execute() throws BuildException { - wbUtil.setDoubleValue(cellStr, cellValue ) ; + wbUtil.setDoubleValue(cellStr, cellValue ) ; - log( "set cell " + cellStr + " to value " + cellValue + " as double.", Project.MSG_DEBUG ) ; - } + log( "set cell " + cellStr + " to value " + cellValue + " as double.", Project.MSG_DEBUG ) ; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java index e6f2834627..a623ec94d0 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java @@ -27,23 +27,23 @@ import org.apache.tools.ant.Project; public class ExcelAntSetFormulaCell extends ExcelAntSet { - private String cellValue ; + private String cellValue ; - public ExcelAntSetFormulaCell() {} + public ExcelAntSetFormulaCell() {} - public void setValue( String value ) { - cellValue = value ; - } + public void setValue( String value ) { + cellValue = value ; + } - protected String getCellValue() { - return cellValue; - } + protected String getCellValue() { + return cellValue; + } - @Override + @Override public void execute() throws BuildException { - wbUtil.setFormulaValue( cellStr, cellValue ) ; + wbUtil.setFormulaValue( cellStr, cellValue ) ; - log( "set cell " + cellStr + " to formula " + cellValue, Project.MSG_DEBUG ) ; - } + log( "set cell " + cellStr + " to formula " + cellValue, Project.MSG_DEBUG ) ; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java index 41cae25966..28be165704 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java @@ -25,31 +25,31 @@ import org.apache.tools.ant.Project; * sheet cell using the cell id ('Sheet Name'!cellId). */ public class ExcelAntSetStringCell extends ExcelAntSet { - private String stringValue ; - - public ExcelAntSetStringCell() {} - - /** - * Set the value of the cell to the String passed in. - * @param value The string-value that should be set when this task is executed. - */ - public void setValue(String value ) { - stringValue = value ; - } - - /** - * Return the value that will be set into the cell. - * @return The string-value of the cell as populated via setValue(), null - * if the value was not set yet. - */ - public String getCellValue() { - return stringValue; - } - - @Override + private String stringValue ; + + public ExcelAntSetStringCell() {} + + /** + * Set the value of the cell to the String passed in. + * @param value The string-value that should be set when this task is executed. + */ + public void setValue(String value ) { + stringValue = value ; + } + + /** + * Return the value that will be set into the cell. + * @return The string-value of the cell as populated via setValue(), null + * if the value was not set yet. + */ + public String getCellValue() { + return stringValue; + } + + @Override public void execute() throws BuildException { - wbUtil.setStringValue(cellStr, stringValue ) ; + wbUtil.setStringValue(cellStr, stringValue ) ; - log( "set cell " + cellStr + " to value " + stringValue + " as String.", Project.MSG_DEBUG ) ; - } + log( "set cell " + cellStr + " to value " + stringValue + " as String.", Project.MSG_DEBUG ) ; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTask.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTask.java index 4fc7a80508..4fc0b09914 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTask.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTask.java @@ -35,104 +35,104 @@ public class ExcelAntTask extends Task { public static final String VERSION = "0.5.0" ; - private String excelFileName ; + private String excelFileName ; - private boolean failOnError; + private boolean failOnError; - private ExcelAntWorkbookUtil workbookUtil ; + private ExcelAntWorkbookUtil workbookUtil ; - private ExcelAntPrecision precision ; + private ExcelAntPrecision precision ; - private LinkedList<ExcelAntTest> tests ; - private LinkedList<ExcelAntUserDefinedFunction> functions ; + private LinkedList<ExcelAntTest> tests ; + private LinkedList<ExcelAntUserDefinedFunction> functions ; - public ExcelAntTask() { - tests = new LinkedList<>() ; - functions = new LinkedList<>() ; - } + public ExcelAntTask() { + tests = new LinkedList<>() ; + functions = new LinkedList<>() ; + } - public void addPrecision( ExcelAntPrecision prec ) { - precision = prec ; - } + public void addPrecision( ExcelAntPrecision prec ) { + precision = prec ; + } - public void setFailOnError( boolean value ) { - failOnError = value ; - } - public void setFileName( String fileName ) { - excelFileName = fileName ; - } + public void setFailOnError( boolean value ) { + failOnError = value ; + } + public void setFileName( String fileName ) { + excelFileName = fileName ; + } - public void addTest( ExcelAntTest testElement ) { - tests.add( testElement ) ; - } + public void addTest( ExcelAntTest testElement ) { + tests.add( testElement ) ; + } - public void addUdf( ExcelAntUserDefinedFunction def ) { - functions.add( def ) ; - } + public void addUdf( ExcelAntUserDefinedFunction def ) { + functions.add( def ) ; + } - @Override + @Override public void execute() throws BuildException { checkClassPath(); - int totalCount = 0 ; - int successCount = 0 ; - - StringBuilder versionBffr = new StringBuilder() ; - versionBffr.append( "ExcelAnt version " ) ; - versionBffr.append( VERSION ) ; - versionBffr.append( " Copyright 2011" ) ; - SimpleDateFormat sdf = new SimpleDateFormat( "yyyy", Locale.ROOT ) ; - double currYear = Double.parseDouble( sdf.format( new Date() ) ); - if( currYear > 2011 ) { - versionBffr.append( "-" ) ; - versionBffr.append( currYear ) ; - } - log( versionBffr.toString(), Project.MSG_INFO ) ; + int totalCount = 0 ; + int successCount = 0 ; + + StringBuilder versionBffr = new StringBuilder() ; + versionBffr.append( "ExcelAnt version " ) ; + versionBffr.append( VERSION ) ; + versionBffr.append( " Copyright 2011" ) ; + SimpleDateFormat sdf = new SimpleDateFormat( "yyyy", Locale.ROOT ) ; + double currYear = Double.parseDouble( sdf.format( new Date() ) ); + if( currYear > 2011 ) { + versionBffr.append( "-" ) ; + versionBffr.append( currYear ) ; + } + log( versionBffr.toString(), Project.MSG_INFO ) ; - log( "Using input file: " + excelFileName, Project.MSG_INFO ) ; + log( "Using input file: " + excelFileName, Project.MSG_INFO ) ; workbookUtil = ExcelAntWorkbookUtilFactory.getInstance(excelFileName); - for (ExcelAntTest test : tests) { - log("executing test: " + test.getName(), Project.MSG_DEBUG); - - if (workbookUtil == null) { - workbookUtil = ExcelAntWorkbookUtilFactory.getInstance(excelFileName); - } - - for (ExcelAntUserDefinedFunction eaUdf : functions) { - try { - workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName()); - } catch (Exception e) { - throw new BuildException(e.getMessage(), e); - } - } - test.setWorkbookUtil(workbookUtil); - - if (precision != null && precision.getValue() > 0) { - log("setting precision for the test " + test.getName(), Project.MSG_VERBOSE); - test.setPrecision(precision.getValue()); - } - - test.execute(); - - if (test.didTestPass()) { - successCount++; - } else { - if (failOnError) { - throw new BuildException("Test " + test.getName() + " failed."); - } - } - totalCount++; - - workbookUtil = null; - } - - if( !tests.isEmpty() ) { - log( successCount + "/" + totalCount + " tests passed.", Project.MSG_INFO ); - } + for (ExcelAntTest test : tests) { + log("executing test: " + test.getName(), Project.MSG_DEBUG); + + if (workbookUtil == null) { + workbookUtil = ExcelAntWorkbookUtilFactory.getInstance(excelFileName); + } + + for (ExcelAntUserDefinedFunction eaUdf : functions) { + try { + workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName()); + } catch (Exception e) { + throw new BuildException(e.getMessage(), e); + } + } + test.setWorkbookUtil(workbookUtil); + + if (precision != null && precision.getValue() > 0) { + log("setting precision for the test " + test.getName(), Project.MSG_VERBOSE); + test.setPrecision(precision.getValue()); + } + + test.execute(); + + if (test.didTestPass()) { + successCount++; + } else { + if (failOnError) { + throw new BuildException("Test " + test.getName() + " failed."); + } + } + totalCount++; + + workbookUtil = null; + } + + if( !tests.isEmpty() ) { + log( successCount + "/" + totalCount + " tests passed.", Project.MSG_INFO ); + } workbookUtil = null; - } + } /** diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTest.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTest.java index fe7819fc41..36696d03f8 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTest.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntTest.java @@ -34,173 +34,173 @@ import org.apache.tools.ant.Task; */ @SuppressWarnings("unused") public class ExcelAntTest extends Task{ - private LinkedList<ExcelAntEvaluateCell> evaluators; + private LinkedList<ExcelAntEvaluateCell> evaluators; - private LinkedList<Task> testTasks; + private LinkedList<Task> testTasks; - private String name; + private String name; - private double globalPrecision; + private double globalPrecision; - private boolean showSuccessDetails; + private boolean showSuccessDetails; - private boolean showFailureDetail; - LinkedList<String> failureMessages; + private boolean showFailureDetail; + LinkedList<String> failureMessages; - private ExcelAntWorkbookUtil workbookUtil; + private ExcelAntWorkbookUtil workbookUtil; - private boolean passed = true; + private boolean passed = true; - public ExcelAntTest() { - evaluators = new LinkedList<>(); - failureMessages = new LinkedList<>(); - testTasks = new LinkedList<>(); - } + public ExcelAntTest() { + evaluators = new LinkedList<>(); + failureMessages = new LinkedList<>(); + testTasks = new LinkedList<>(); + } - public void setPrecision( double precision ) { - globalPrecision = precision; - } + public void setPrecision( double precision ) { + globalPrecision = precision; + } - public void setWorkbookUtil( ExcelAntWorkbookUtil wbUtil ) { - workbookUtil = wbUtil; - } + public void setWorkbookUtil( ExcelAntWorkbookUtil wbUtil ) { + workbookUtil = wbUtil; + } - public void setShowFailureDetail( boolean value ) { - showFailureDetail = value; - } + public void setShowFailureDetail( boolean value ) { + showFailureDetail = value; + } - public void setName( String nm ) { - name = nm; - } + public void setName( String nm ) { + name = nm; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setShowSuccessDetails( boolean details ) { - showSuccessDetails = details; - } + public void setShowSuccessDetails( boolean details ) { + showSuccessDetails = details; + } - public boolean showSuccessDetails() { - return showSuccessDetails; - } + public boolean showSuccessDetails() { + return showSuccessDetails; + } - public void addSetDouble( ExcelAntSetDoubleCell setter ) { - addSetter( setter ); - } + public void addSetDouble( ExcelAntSetDoubleCell setter ) { + addSetter( setter ); + } - public void addSetString( ExcelAntSetStringCell setter ){ - addSetter( setter ); - } + public void addSetString( ExcelAntSetStringCell setter ){ + addSetter( setter ); + } - public void addSetFormula( ExcelAntSetFormulaCell setter ) { - addSetter( setter ); - } + public void addSetFormula( ExcelAntSetFormulaCell setter ) { + addSetter( setter ); + } - public void addHandler( ExcelAntHandlerTask handler ) { - testTasks.add( handler ); - } + public void addHandler( ExcelAntHandlerTask handler ) { + testTasks.add( handler ); + } - private void addSetter( ExcelAntSet setter ) { - testTasks.add( setter ); - } + private void addSetter( ExcelAntSet setter ) { + testTasks.add( setter ); + } - public void addEvaluate( ExcelAntEvaluateCell evaluator ) { - testTasks.add( evaluator ); - } + public void addEvaluate( ExcelAntEvaluateCell evaluator ) { + testTasks.add( evaluator ); + } - protected LinkedList<ExcelAntEvaluateCell> getEvaluators() { - return evaluators; - } + protected LinkedList<ExcelAntEvaluateCell> getEvaluators() { + return evaluators; + } - @Override + @Override public void execute() throws BuildException { - Iterator<Task> taskIt = testTasks.iterator(); - - int testCount = evaluators.size(); - int failureCount = 0; - - // roll over all sub task elements in one loop. This allows the - // ordering of the sub elements to be considered. - while( taskIt.hasNext() ) { - Task task = taskIt.next(); - - // log( task.getClass().getName(), Project.MSG_INFO ); - - if( task instanceof ExcelAntSet ) { - ExcelAntSet set = (ExcelAntSet) task; - set.setWorkbookUtil(workbookUtil); - set.execute(); - } - - if( task instanceof ExcelAntHandlerTask ) { - ExcelAntHandlerTask handler = (ExcelAntHandlerTask)task; - handler.setEAWorkbookUtil(workbookUtil ); - handler.execute(); - } - - if (task instanceof ExcelAntEvaluateCell ) { - ExcelAntEvaluateCell eval = (ExcelAntEvaluateCell)task; - eval.setWorkbookUtil( workbookUtil ); - - if( globalPrecision > 0 ) { - log( "setting globalPrecision to " + globalPrecision + " in the evaluator", Project.MSG_VERBOSE ); - eval.setGlobalPrecision( globalPrecision ); - } - - try { - eval.execute(); - ExcelAntEvaluationResult result = eval.getResult(); - - Supplier<String> details = () -> - result.getCellName() + ". It evaluated to " + - result.getReturnValue() + " when the value of " + - eval.getExpectedValue() + " with precision of " + - eval.getPrecision(); - - if( result.didTestPass() && !result.evaluationCompleteWithError()) { - if(showSuccessDetails) { - log("Succeeded when evaluating " + details.get(), Project.MSG_INFO ); - } - } else { - if(showFailureDetail) { - failureMessages.add( "\tFailed to evaluate cell " + details.get() + " was expected." ); - } - passed = false; - failureCount++; - - if(eval.requiredToPass()) { - throw new BuildException( "\tFailed to evaluate cell " + details.get() + " was expected." ); - } - } - } catch( NullPointerException npe ) { - // this means the cell reference in the test is bad. - log( "Cell assignment " + eval.getCell() + " in test " + getName() + - " appears to point to an empy cell. Please check the " + - " reference in the ant script.", Project.MSG_ERR ); - } - } - } - - if(!passed) { - log( "Test named " + name + " failed because " + failureCount + - " of " + testCount + " evaluations failed to " + - "evaluate correctly.", - Project.MSG_ERR ); - if(showFailureDetail && failureMessages.size() > 0 ) { - for (String failureMessage : failureMessages) { - log(failureMessage, Project.MSG_ERR); - } - } - } - } - - public boolean didTestPass() { - - return passed; - } + Iterator<Task> taskIt = testTasks.iterator(); + + int testCount = evaluators.size(); + int failureCount = 0; + + // roll over all sub task elements in one loop. This allows the + // ordering of the sub elements to be considered. + while( taskIt.hasNext() ) { + Task task = taskIt.next(); + + // log( task.getClass().getName(), Project.MSG_INFO ); + + if( task instanceof ExcelAntSet ) { + ExcelAntSet set = (ExcelAntSet) task; + set.setWorkbookUtil(workbookUtil); + set.execute(); + } + + if( task instanceof ExcelAntHandlerTask ) { + ExcelAntHandlerTask handler = (ExcelAntHandlerTask)task; + handler.setEAWorkbookUtil(workbookUtil ); + handler.execute(); + } + + if (task instanceof ExcelAntEvaluateCell ) { + ExcelAntEvaluateCell eval = (ExcelAntEvaluateCell)task; + eval.setWorkbookUtil( workbookUtil ); + + if( globalPrecision > 0 ) { + log( "setting globalPrecision to " + globalPrecision + " in the evaluator", Project.MSG_VERBOSE ); + eval.setGlobalPrecision( globalPrecision ); + } + + try { + eval.execute(); + ExcelAntEvaluationResult result = eval.getResult(); + + Supplier<String> details = () -> + result.getCellName() + ". It evaluated to " + + result.getReturnValue() + " when the value of " + + eval.getExpectedValue() + " with precision of " + + eval.getPrecision(); + + if( result.didTestPass() && !result.evaluationCompleteWithError()) { + if(showSuccessDetails) { + log("Succeeded when evaluating " + details.get(), Project.MSG_INFO ); + } + } else { + if(showFailureDetail) { + failureMessages.add( "\tFailed to evaluate cell " + details.get() + " was expected." ); + } + passed = false; + failureCount++; + + if(eval.requiredToPass()) { + throw new BuildException( "\tFailed to evaluate cell " + details.get() + " was expected." ); + } + } + } catch( NullPointerException npe ) { + // this means the cell reference in the test is bad. + log( "Cell assignment " + eval.getCell() + " in test " + getName() + + " appears to point to an empy cell. Please check the " + + " reference in the ant script.", Project.MSG_ERR ); + } + } + } + + if(!passed) { + log( "Test named " + name + " failed because " + failureCount + + " of " + testCount + " evaluations failed to " + + "evaluate correctly.", + Project.MSG_ERR ); + if(showFailureDetail && failureMessages.size() > 0 ) { + for (String failureMessage : failureMessages) { + log(failureMessage, Project.MSG_ERR); + } + } + } + } + + public boolean didTestPass() { + + return passed; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java index 6877da5054..cf12728a4d 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java @@ -26,33 +26,33 @@ import org.apache.tools.ant.taskdefs.Typedef; public class ExcelAntUserDefinedFunction extends Typedef { - private String functionAlias ; + private String functionAlias ; - private String className ; + private String className ; - public ExcelAntUserDefinedFunction() {} + public ExcelAntUserDefinedFunction() {} - protected String getFunctionAlias() { - return functionAlias; - } + protected String getFunctionAlias() { + return functionAlias; + } - public void setFunctionAlias(String functionAlias) { - this.functionAlias = functionAlias; - } + public void setFunctionAlias(String functionAlias) { + this.functionAlias = functionAlias; + } - protected String getClassName() { - // workaround for IBM JDK assigning the classname to the lowercase instance provided by Definer!?! - // I could not find out why that happens, the wrong assignment seems to be done somewhere deep inside Ant itself - // or even in IBM JDK as Oracle JDK does not have this problem. - if(className == null) { - return getClassname(); - } + protected String getClassName() { + // workaround for IBM JDK assigning the classname to the lowercase instance provided by Definer!?! + // I could not find out why that happens, the wrong assignment seems to be done somewhere deep inside Ant itself + // or even in IBM JDK as Oracle JDK does not have this problem. + if(className == null) { + return getClassname(); + } - return className; - } + return className; + } - public void setClassName(String className) { - this.className = className; - } + public void setClassName(String className) { + this.className = className; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java index e24952a9c5..4a8b04db0b 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java @@ -23,86 +23,86 @@ package org.apache.poi.ss.excelant.util; */ public class ExcelAntEvaluationResult { - /** - * This boolean flag is used to determine if the evaluation completed - * without error. This alone doesn't ensure that the evaluation was - * successful. - */ - private boolean evaluationCompletedWithError ; - - /** - * This boolean flag is used to determine if the result was within - * the specified precision. - */ - private boolean didPass ; - - /** - * This is the actual value returned from the evaluation. - */ - private double returnValue ; - - /** - * Any error message String values that need to be returned. - */ - private String errorMessage ; - - /** - * Stores the absolute value of the delta for this evaluation. - */ - private double actualDelta ; - - /** - * This stores the fully qualified cell name (sheetName!cellId). - */ - private String cellName ; - - - - public ExcelAntEvaluationResult(boolean completedWithError, - boolean passed, - double retValue, - String errMessage, - double delta, - String cellId) { - - evaluationCompletedWithError = completedWithError; - didPass = passed; - returnValue = retValue; - errorMessage = errMessage; - actualDelta = delta ; - cellName = cellId ; - } - - public double getReturnValue() { - return returnValue; - } - - public String getErrorMessage() { - return errorMessage; - } - - public boolean didTestPass() { - return didPass ; - } - - public boolean evaluationCompleteWithError() { - return evaluationCompletedWithError ; - } - - public double getDelta() { - return actualDelta ; - } - - public String getCellName() { - return cellName ; - } - - @Override - public String toString() { - return "ExcelAntEvaluationResult [evaluationCompletedWithError=" - + evaluationCompletedWithError + ", didPass=" + didPass - + ", returnValue=" + returnValue + ", errorMessage=" - + errorMessage + ", actualDelta=" + actualDelta + ", cellName=" - + cellName + "]"; - } + /** + * This boolean flag is used to determine if the evaluation completed + * without error. This alone doesn't ensure that the evaluation was + * successful. + */ + private boolean evaluationCompletedWithError ; + + /** + * This boolean flag is used to determine if the result was within + * the specified precision. + */ + private boolean didPass ; + + /** + * This is the actual value returned from the evaluation. + */ + private double returnValue ; + + /** + * Any error message String values that need to be returned. + */ + private String errorMessage ; + + /** + * Stores the absolute value of the delta for this evaluation. + */ + private double actualDelta ; + + /** + * This stores the fully qualified cell name (sheetName!cellId). + */ + private String cellName ; + + + + public ExcelAntEvaluationResult(boolean completedWithError, + boolean passed, + double retValue, + String errMessage, + double delta, + String cellId) { + + evaluationCompletedWithError = completedWithError; + didPass = passed; + returnValue = retValue; + errorMessage = errMessage; + actualDelta = delta ; + cellName = cellId ; + } + + public double getReturnValue() { + return returnValue; + } + + public String getErrorMessage() { + return errorMessage; + } + + public boolean didTestPass() { + return didPass ; + } + + public boolean evaluationCompleteWithError() { + return evaluationCompletedWithError ; + } + + public double getDelta() { + return actualDelta ; + } + + public String getCellName() { + return cellName ; + } + + @Override + public String toString() { + return "ExcelAntEvaluationResult [evaluationCompletedWithError=" + + evaluationCompletedWithError + ", didPass=" + didPass + + ", returnValue=" + returnValue + ", errorMessage=" + + errorMessage + ", actualDelta=" + actualDelta + ", cellName=" + + cellName + "]"; + } } diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java index 0bb0cb2ec2..55d8177949 100644 --- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java +++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java @@ -204,15 +204,15 @@ public class ExcelAntWorkbookUtil extends Typedef { * Returns the list of sheet names. */ public List<String> getSheets() { - ArrayList<String> sheets = new ArrayList<>(); + ArrayList<String> sheets = new ArrayList<>(); - int sheetCount = workbook.getNumberOfSheets(); + int sheetCount = workbook.getNumberOfSheets(); - for(int x=0; x<sheetCount; x++) { - sheets.add(workbook.getSheetName(x)); - } + for(int x=0; x<sheetCount; x++) { + sheets.add(workbook.getSheetName(x)); + } - return sheets; + return sheets; } /** @@ -305,8 +305,8 @@ public class ExcelAntWorkbookUtil extends Typedef { * Returns a Cell as a String value. */ public String getCellAsString(String cellName) { - Cell cell = getCell(cellName); - return cell.getStringCellValue(); + Cell cell = getCell(cellName); + return cell.getStringCellValue(); } @@ -314,8 +314,8 @@ public class ExcelAntWorkbookUtil extends Typedef { * Returns the value of the Cell as a double. */ public double getCellAsDouble(String cellName) { - Cell cell = getCell(cellName); - return cell.getNumericCellValue(); + Cell cell = getCell(cellName); + return cell.getNumericCellValue(); } /** * Returns a cell reference based on a String in standard Excel format @@ -335,13 +335,13 @@ public class ExcelAntWorkbookUtil extends Typedef { Row row = sheet.getRow(rowIdx); if(row == null) { - row = sheet.createRow(rowIdx); + row = sheet.createRow(rowIdx); } Cell cell = row.getCell(colIdx); if(cell == null) { - cell = row.createCell(colIdx); + cell = row.createCell(colIdx); } return cell; diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java index 48086fc22d..7e273ac2f6 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java @@ -17,18 +17,18 @@ package org.apache.poi.ss.excelant; public class ExcelAntUserDefinedFunctionTestHelper extends - ExcelAntUserDefinedFunction { + ExcelAntUserDefinedFunction { - @Override - protected String getFunctionAlias() { - // TODO Auto-generated method stub - return super.getFunctionAlias(); - } + @Override + protected String getFunctionAlias() { + // TODO Auto-generated method stub + return super.getFunctionAlias(); + } - @Override - protected String getClassName() { - // TODO Auto-generated method stub - return super.getClassName(); - } + @Override + protected String getClassName() { + // TODO Auto-generated method stub + return super.getClassName(); + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntPrecision.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntPrecision.java index 2902144fde..071280a4b9 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntPrecision.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntPrecision.java @@ -25,30 +25,30 @@ import org.junit.jupiter.api.Test; class TestExcelAntPrecision { - private ExcelAntPrecision fixture ; + private ExcelAntPrecision fixture ; @BeforeEach - void setUp() { - fixture = new ExcelAntPrecision() ; - } + void setUp() { + fixture = new ExcelAntPrecision() ; + } @AfterEach - void tearDown() { - fixture = null ; - } + void tearDown() { + fixture = null ; + } - @Test - void testVerifyPrecision() { + @Test + void testVerifyPrecision() { - double value = 1.0E-1 ; + double value = 1.0E-1 ; - fixture.setValue( value ) ; + fixture.setValue( value ) ; - double result = fixture.getValue() ; + double result = fixture.getValue() ; - assertTrue( result > 0 ) ; + assertTrue( result > 0 ) ; - assertEquals( value, result, 0.0 ) ; - } + assertEquals( value, result, 0.0 ) ; + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSet.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSet.java index 42f6cd256c..a81938e085 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSet.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSet.java @@ -28,42 +28,42 @@ import org.junit.jupiter.api.Test; class TestExcelAntSet { - // This is abstract in nature, so we'll use a - // concrete instance to test the set methods. - private ExcelAntSet fixture ; + // This is abstract in nature, so we'll use a + // concrete instance to test the set methods. + private ExcelAntSet fixture ; private static final String mortgageCalculatorFileName = TestBuildFile.getDataDir() + "/spreadsheet/mortgage-calculation.xls" ; @BeforeEach - void setUp() { - fixture = new ExcelAntSetDoubleCell() ; - } + void setUp() { + fixture = new ExcelAntSetDoubleCell() ; + } @AfterEach - void tearDown() { - fixture = null ; - } + void tearDown() { + fixture = null ; + } - @Test - void testSetter() { - String cell = "simpleCellRef!$F$1" ; + @Test + void testSetter() { + String cell = "simpleCellRef!$F$1" ; - fixture.setCell( cell ) ; + fixture.setCell( cell ) ; - String cellStr = fixture.getCell() ; + String cellStr = fixture.getCell() ; - assertNotNull( cellStr ) ; - assertEquals( cell, cellStr ) ; - } + assertNotNull( cellStr ) ; + assertEquals( cell, cellStr ) ; + } - @Test - void testSetWorkbookUtil() { - ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( - mortgageCalculatorFileName ) ; + @Test + void testSetWorkbookUtil() { + ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( + mortgageCalculatorFileName ) ; - assertNotNull( util ) ; + assertNotNull( util ) ; - fixture.setWorkbookUtil( util ) ; - } + fixture.setWorkbookUtil( util ) ; + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSetDoubleCell.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSetDoubleCell.java index 45c4f53635..e19016b6f7 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSetDoubleCell.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntSetDoubleCell.java @@ -27,44 +27,44 @@ import org.junit.jupiter.api.Test; class TestExcelAntSetDoubleCell { - private ExcelAntSetDoubleCell fixture ; + private ExcelAntSetDoubleCell fixture ; - private ExcelAntWorkbookUtil util ; + private ExcelAntWorkbookUtil util ; private static final String mortgageCalculatorFileName = TestBuildFile.getDataDir() + "/spreadsheet/mortgage-calculation.xls" ; @BeforeEach - void setUp() { - fixture = new ExcelAntSetDoubleCell() ; - util = ExcelAntWorkbookUtilFactory.getInstance(mortgageCalculatorFileName ) ; - fixture.setWorkbookUtil( util ) ; - } + void setUp() { + fixture = new ExcelAntSetDoubleCell() ; + util = ExcelAntWorkbookUtilFactory.getInstance(mortgageCalculatorFileName ) ; + fixture.setWorkbookUtil( util ) ; + } @AfterEach - void tearDown() { - fixture = null ; - } + void tearDown() { + fixture = null ; + } - @Test - void testSetDouble() { - String cellId = "'Sheet3'!$A$1" ; - double testValue = 1.1 ; + @Test + void testSetDouble() { + String cellId = "'Sheet3'!$A$1" ; + double testValue = 1.1 ; - fixture.setCell( cellId ) ; - fixture.setValue( testValue ) ; + fixture.setCell( cellId ) ; + fixture.setValue( testValue ) ; - double value = fixture.getCellValue() ; + double value = fixture.getCellValue() ; - assertTrue( value > 0 ) ; - assertEquals( testValue, value, 0.0 ) ; + assertTrue( value > 0 ) ; + assertEquals( testValue, value, 0.0 ) ; - fixture.execute() ; + fixture.execute() ; - double setValue = util.getCellAsDouble( cellId ) ; + double setValue = util.getCellAsDouble( cellId ) ; - assertEquals( setValue, testValue, 0.0 ) ; - } + assertEquals( setValue, testValue, 0.0 ) ; + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java index 52b580ac6f..7fa94327e0 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java @@ -24,34 +24,34 @@ import org.junit.jupiter.api.Test; class TestExcelAntUserDefinedFunction { - private ExcelAntUserDefinedFunctionTestHelper fixture ; + private ExcelAntUserDefinedFunctionTestHelper fixture ; - @BeforeEach - void setUp() { - fixture = new ExcelAntUserDefinedFunctionTestHelper() ; - } + @BeforeEach + void setUp() { + fixture = new ExcelAntUserDefinedFunctionTestHelper() ; + } - @Test - void testSetClassName() { - String className = "simple.class.name" ; + @Test + void testSetClassName() { + String className = "simple.class.name" ; - fixture.setClassName( className ) ; - String value = fixture.getClassName() ; + fixture.setClassName( className ) ; + String value = fixture.getClassName() ; - assertNotNull( value ) ; - assertEquals( className, value ) ; - } + assertNotNull( value ) ; + assertEquals( className, value ) ; + } - @Test - void testSetFunction() { - String functionAlias = "alias" ; + @Test + void testSetFunction() { + String functionAlias = "alias" ; - fixture.setFunctionAlias( functionAlias ) ; + fixture.setFunctionAlias( functionAlias ) ; - String alias = fixture.getFunctionAlias() ; + String alias = fixture.getFunctionAlias() ; - assertNotNull( alias ) ; - assertEquals( functionAlias, alias ) ; - } + assertNotNull( alias ) ; + assertEquals( functionAlias, alias ) ; + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilTestHelper.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilTestHelper.java index 862169b91e..e7d82dbdaf 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilTestHelper.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilTestHelper.java @@ -25,23 +25,23 @@ import org.apache.poi.ss.usermodel.Workbook; */ public class ExcelAntWorkbookUtilTestHelper extends ExcelAntWorkbookUtil { - public ExcelAntWorkbookUtilTestHelper(String fName) { - super(fName); - } - - public ExcelAntWorkbookUtilTestHelper(Workbook wb) { - super(wb); - } - - @Override - public UDFFinder getFunctions() { - return super.getFunctions(); - } - - @Override - public FormulaEvaluator getEvaluator(String excelFileName) { - return super.getEvaluator(excelFileName); - } + public ExcelAntWorkbookUtilTestHelper(String fName) { + super(fName); + } + + public ExcelAntWorkbookUtilTestHelper(Workbook wb) { + super(wb); + } + + @Override + public UDFFinder getFunctions() { + return super.getFunctions(); + } + + @Override + public FormulaEvaluator getEvaluator(String excelFileName) { + return super.getEvaluator(excelFileName); + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntEvaluationResult.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntEvaluationResult.java index dcb044a2eb..f79c21c8df 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntEvaluationResult.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntEvaluationResult.java @@ -24,9 +24,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class TestExcelAntEvaluationResult { - private ExcelAntEvaluationResult fixture; + private ExcelAntEvaluationResult fixture; - private boolean completedWithError; + private boolean completedWithError; private boolean passed; private double retValue = 1.1; private String errMessage = "error message"; @@ -34,43 +34,43 @@ class TestExcelAntEvaluationResult { private String cellId = "testCell!$F$1"; @BeforeEach - void setUp() { - fixture = new ExcelAntEvaluationResult(completedWithError, - passed, - retValue, - errMessage, - delta, - cellId); - } + void setUp() { + fixture = new ExcelAntEvaluationResult(completedWithError, + passed, + retValue, + errMessage, + delta, + cellId); + } @AfterEach - void tearDown() { - fixture = null; - } + void tearDown() { + fixture = null; + } @Test - void testCompletedWithErrorMessage() { - String errMsg = fixture.getErrorMessage(); - assertNotNull(errMsg); - assertEquals(errMsg, errMessage); - } + void testCompletedWithErrorMessage() { + String errMsg = fixture.getErrorMessage(); + assertNotNull(errMsg); + assertEquals(errMsg, errMessage); + } @Test - void testPassed() { - boolean passedValue = fixture.didTestPass(); - assertEquals(passedValue, passed); - } + void testPassed() { + boolean passedValue = fixture.didTestPass(); + assertEquals(passedValue, passed); + } @Test - void testDelta() { - double deltaValue = fixture.getDelta(); - assertEquals(deltaValue, delta, 0.0); - } + void testDelta() { + double deltaValue = fixture.getDelta(); + assertEquals(deltaValue, delta, 0.0); + } @Test - void testCellId() { - String cellIdValue = fixture.getCellName(); - assertNotNull(cellIdValue); - assertEquals(cellIdValue, cellId); - } + void testCellId() { + String cellIdValue = fixture.getCellName(); + assertNotNull(cellIdValue); + assertEquals(cellIdValue, cellId); + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java index 4f46084c6a..3bfe15e47a 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java @@ -45,54 +45,54 @@ class TestExcelAntWorkbookUtil { private static final String mortgageCalculatorFileName = TestBuildFile.getDataDir() + "/spreadsheet/excelant.xls" ; - private ExcelAntWorkbookUtilTestHelper fixture ; + private ExcelAntWorkbookUtilTestHelper fixture ; - @AfterEach - void tearDown() { - fixture = null ; - } + @AfterEach + void tearDown() { + fixture = null ; + } - @Test - void testStringConstructor() { - fixture = new ExcelAntWorkbookUtilTestHelper(mortgageCalculatorFileName); + @Test + void testStringConstructor() { + fixture = new ExcelAntWorkbookUtilTestHelper(mortgageCalculatorFileName); - assertNotNull(fixture); - } + assertNotNull(fixture); + } - @Test - void testLoadNotExistingFile() { - BuildException e = assertThrows(BuildException.class, () -> new ExcelAntWorkbookUtilTestHelper("notexistingFile")); - assertTrue(e.getMessage().contains("notexistingFile")); - } + @Test + void testLoadNotExistingFile() { + BuildException e = assertThrows(BuildException.class, () -> new ExcelAntWorkbookUtilTestHelper("notexistingFile")); + assertTrue(e.getMessage().contains("notexistingFile")); + } - @Test - void testWorkbookConstructor() throws IOException { + @Test + void testWorkbookConstructor() throws IOException { File workbookFile = new File(mortgageCalculatorFileName); FileInputStream fis = new FileInputStream(workbookFile); Workbook workbook = WorkbookFactory.create(fis); - fixture = new ExcelAntWorkbookUtilTestHelper(workbook); + fixture = new ExcelAntWorkbookUtilTestHelper(workbook); - assertNotNull(fixture); - } + assertNotNull(fixture); + } - @Test - void testAddFunction() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testAddFunction() { + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - assertNotNull(fixture); + assertNotNull(fixture); - fixture.addFunction("h2_ZFactor", new CalculateMortgageFunction()); + fixture.addFunction("h2_ZFactor", new CalculateMortgageFunction()); - UDFFinder functions = fixture.getFunctions(); + UDFFinder functions = fixture.getFunctions(); - assertNotNull(functions); - assertNotNull(functions.findFunction("h2_ZFactor")); - } + assertNotNull(functions); + assertNotNull(functions.findFunction("h2_ZFactor")); + } - @Test + @Test void testAddFunctionClassName() throws Exception { fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); @@ -107,7 +107,7 @@ class TestExcelAntWorkbookUtil { assertNotNull(functions.findFunction("h2_ZFactor")); } - @Test + @Test void testAddFunctionInvalidClassName() throws Exception { fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); @@ -122,45 +122,45 @@ class TestExcelAntWorkbookUtil { assertNull(functions.findFunction("h2_ZFactor")); } - @Test - void testGetWorkbook() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testGetWorkbook() { + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - assertNotNull(fixture); + assertNotNull(fixture); - Workbook workbook = fixture.getWorkbook(); + Workbook workbook = fixture.getWorkbook(); - assertNotNull(workbook); - } + assertNotNull(workbook); + } - @Test - void testFileName() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testFileName() { + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - assertNotNull(fixture); + assertNotNull(fixture); - String fileName = fixture.getFileName(); + String fileName = fixture.getFileName(); - assertNotNull(fileName); + assertNotNull(fileName); - assertEquals(mortgageCalculatorFileName, fileName); + assertEquals(mortgageCalculatorFileName, fileName); - } + } - @Test - void testGetEvaluator() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testGetEvaluator() { + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - FormulaEvaluator evaluator = fixture.getEvaluator( - mortgageCalculatorFileName); + FormulaEvaluator evaluator = fixture.getEvaluator( + mortgageCalculatorFileName); - assertNotNull(evaluator); - } + assertNotNull(evaluator); + } - @Test + @Test void testGetEvaluatorWithUDF() { fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); @@ -173,18 +173,18 @@ class TestExcelAntWorkbookUtil { assertNotNull(evaluator); } - @Test - void testGetEvaluatorXLSX() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testGetEvaluatorXLSX() { + fixture = new ExcelAntWorkbookUtilTestHelper( TestBuildFile.getDataDir() + "/spreadsheet/sample.xlsx"); - FormulaEvaluator evaluator = fixture.getEvaluator( + FormulaEvaluator evaluator = fixture.getEvaluator( TestBuildFile.getDataDir() + "/spreadsheet/sample.xlsx"); - assertNotNull(evaluator); - } + assertNotNull(evaluator); + } - @Test + @Test void testGetEvaluatorXLSXWithFunction() { fixture = new ExcelAntWorkbookUtilTestHelper( TestBuildFile.getDataDir() + "/spreadsheet/sample.xlsx"); @@ -197,30 +197,30 @@ class TestExcelAntWorkbookUtil { assertNotNull(evaluator); } - @Test - void testEvaluateCell() { - String cell = "'MortgageCalculator'!B4" ; - double expectedValue = 790.79 ; - double precision = 0.1 ; + @Test + void testEvaluateCell() { + String cell = "'MortgageCalculator'!B4" ; + double expectedValue = 790.79 ; + double precision = 0.1 ; - fixture = new ExcelAntWorkbookUtilTestHelper( + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - ExcelAntEvaluationResult result = fixture.evaluateCell(cell, - expectedValue, - precision); + ExcelAntEvaluationResult result = fixture.evaluateCell(cell, + expectedValue, + precision); - //System.out.println(result); - assertTrue( result.toString().contains("evaluationCompletedWithError=false"), "Had:" + result ); - assertTrue( result.toString().contains("returnValue=790.79"), "Had:" + result ); - assertTrue( result.toString().contains("cellName='MortgageCalculator'!B4"), "Had:" + result ); + //System.out.println(result); + assertTrue( result.toString().contains("evaluationCompletedWithError=false"), "Had:" + result ); + assertTrue( result.toString().contains("returnValue=790.79"), "Had:" + result ); + assertTrue( result.toString().contains("cellName='MortgageCalculator'!B4"), "Had:" + result ); assertFalse(result.toString().contains("#N/A")); - assertFalse(result.evaluationCompleteWithError()); - assertTrue(result.didTestPass()); - } + assertFalse(result.evaluationCompleteWithError()); + assertTrue(result.didTestPass()); + } - @Test + @Test void testEvaluateCellFailedPrecision() { String cell = "'MortgageCalculator'!B4" ; double expectedValue = 790.79 ; @@ -243,7 +243,7 @@ class TestExcelAntWorkbookUtil { assertFalse(result.didTestPass()); } - @Test + @Test void testEvaluateCellWithError() { String cell = "'ErrorCell'!A1" ; double expectedValue = 790.79 ; @@ -266,43 +266,43 @@ class TestExcelAntWorkbookUtil { assertFalse(result.didTestPass()); } - @Test - void testGetSheets() { - fixture = new ExcelAntWorkbookUtilTestHelper( + @Test + void testGetSheets() { + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - List<String> sheets = fixture.getSheets(); + List<String> sheets = fixture.getSheets(); - assertNotNull(sheets); - assertEquals(sheets.size(), 3); - } + assertNotNull(sheets); + assertEquals(sheets.size(), 3); + } - @Test - void testSetString() { - String cell = "'MortgageCalculator'!C14" ; - String cellValue = "testString" ; + @Test + void testSetString() { + String cell = "'MortgageCalculator'!C14" ; + String cellValue = "testString" ; - fixture = new ExcelAntWorkbookUtilTestHelper( + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - fixture.setStringValue(cell, cellValue); + fixture.setStringValue(cell, cellValue); - String value = fixture.getCellAsString(cell); + String value = fixture.getCellAsString(cell); - assertNotNull(value); - assertEquals(cellValue, value); - } + assertNotNull(value); + assertEquals(cellValue, value); + } - @Test + @Test void testSetNotExistingSheet() { String cell = "'NotexistingSheet'!C14" ; fixture = new ExcelAntWorkbookUtilTestHelper(mortgageCalculatorFileName); - BuildException e = assertThrows(BuildException.class, () -> fixture.setStringValue(cell, "some")); - assertTrue(e.getMessage().contains("NotexistingSheet")); + BuildException e = assertThrows(BuildException.class, () -> fixture.setStringValue(cell, "some")); + assertTrue(e.getMessage().contains("NotexistingSheet")); } - @Test + @Test void testSetFormula() { String cell = "'MortgageCalculator'!C14" ; String cellValue = "SUM(B14:B18)" ; @@ -317,7 +317,7 @@ class TestExcelAntWorkbookUtil { assertEquals(0.0, value, 0); } - @Test + @Test void testSetDoubleValue() { String cell = "'MortgageCalculator'!C14" ; double cellValue = 1.2; @@ -332,42 +332,42 @@ class TestExcelAntWorkbookUtil { assertEquals(cellValue, value, 0); } - @Test - void testSetDate() { - String cell = "'MortgageCalculator'!C14" ; - Date cellValue = new Date(); + @Test + void testSetDate() { + String cell = "'MortgageCalculator'!C14" ; + Date cellValue = new Date(); - fixture = new ExcelAntWorkbookUtilTestHelper( + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - fixture.setDateValue(cell, cellValue); + fixture.setDateValue(cell, cellValue); - double value = fixture.getCellAsDouble(cell); + double value = fixture.getCellAsDouble(cell); - assertEquals(DateUtil.getExcelDate(cellValue, false), value, 0); - } + assertEquals(DateUtil.getExcelDate(cellValue, false), value, 0); + } - @Test - void testGetNonexistingString() { - String cell = "'MortgageCalculator'!C33" ; + @Test + void testGetNonexistingString() { + String cell = "'MortgageCalculator'!C33" ; - fixture = new ExcelAntWorkbookUtilTestHelper( + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - String value = fixture.getCellAsString(cell); + String value = fixture.getCellAsString(cell); - assertEquals("", value); - } + assertEquals("", value); + } - @Test - void testGetNonexistingDouble() { - String cell = "'MortgageCalculator'!C33" ; + @Test + void testGetNonexistingDouble() { + String cell = "'MortgageCalculator'!C33" ; - fixture = new ExcelAntWorkbookUtilTestHelper( + fixture = new ExcelAntWorkbookUtilTestHelper( mortgageCalculatorFileName); - double value = fixture.getCellAsDouble(cell); + double value = fixture.getCellAsDouble(cell); - assertEquals(0.0, value, 0); - } + assertEquals(0.0, value, 0); + } } diff --git a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtilFactory.java b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtilFactory.java index 26e700fa8b..e7e7f3099c 100644 --- a/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtilFactory.java +++ b/poi-excelant/src/test/java/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtilFactory.java @@ -32,37 +32,37 @@ class TestExcelAntWorkbookUtilFactory { TestBuildFile.getDataDir() + "/spreadsheet/mortgage-calculation.xls" ; - /** - * Simple test to determine if the factory properly returns an non-null - * instance of the ExcelAntWorkbookUtil class. - */ + /** + * Simple test to determine if the factory properly returns an non-null + * instance of the ExcelAntWorkbookUtil class. + */ @Test - void testGetNewWorkbookUtilInstance() { - ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( - mortgageCalculatorWorkbookFile) ; + void testGetNewWorkbookUtilInstance() { + ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( + mortgageCalculatorWorkbookFile) ; - assertNotNull(util) ; - } + assertNotNull(util) ; + } - /** - * Test whether or not the factory will properly return the same reference - * to an ExcelAnt WorkbookUtil when two different Strings, that point to - * the same resource, are passed in. - */ + /** + * Test whether or not the factory will properly return the same reference + * to an ExcelAnt WorkbookUtil when two different Strings, that point to + * the same resource, are passed in. + */ @Test - void testVerifyEquivalence() { - String sameFileName = TestBuildFile.getDataDir() + "/spreadsheet/mortgage-calculation.xls" ; + void testVerifyEquivalence() { + String sameFileName = TestBuildFile.getDataDir() + "/spreadsheet/mortgage-calculation.xls" ; - ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( + ExcelAntWorkbookUtil util = ExcelAntWorkbookUtilFactory.getInstance( mortgageCalculatorWorkbookFile) ; - ExcelAntWorkbookUtil util2 = ExcelAntWorkbookUtilFactory.getInstance( - sameFileName) ; + ExcelAntWorkbookUtil util2 = ExcelAntWorkbookUtilFactory.getInstance( + sameFileName) ; - assertNotNull(util) ; - assertNotNull(util2) ; + assertNotNull(util) ; + assertNotNull(util2) ; - assertEquals(util, util2) ; - } + assertEquals(util, util2) ; + } } |