Search in sources :

Example 71 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestFormulaParserEval method testEvaluateFormulaWithRowBeyond32768_Bug44539.

public void testEvaluateFormulaWithRowBeyond32768_Bug44539() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    wb.setSheetName(0, "Sheet1");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell(0);
    cell.setCellFormula("SUM(A32769:A32770)");
    // put some values in the cells to make the evaluation more interesting
    sheet.createRow(32768).createCell(0).setCellValue(31);
    sheet.createRow(32769).createCell(0).setCellValue(11);
    HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
    CellValue result;
    try {
        result = fe.evaluate(cell);
    } catch (FormulaParseException e) {
        if (!e.getMessage().equals("Found reference to named range \"A\", but that named range wasn't defined!")) {
            throw new AssertionFailedError("Identifed bug 44539");
        }
        throw e;
    }
    assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
    assertEquals(42.0, result.getNumberValue(), 0.0);
}
Also used : HSSFFormulaEvaluator(org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator) FormulaParseException(org.apache.poi.ss.formula.FormulaParseException) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) CellValue(org.apache.poi.ss.usermodel.CellValue) AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 72 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestSheet method testCloneMulBlank_bug46776.

@Test
public void testCloneMulBlank_bug46776() {
    Record[] recs = { InternalSheet.createBOF(), new DimensionsRecord(), new RowRecord(1), new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F }), new RowRecord(2), createWindow2Record(), EOFRecord.instance };
    InternalSheet sheet = createSheet(Arrays.asList(recs));
    InternalSheet sheet2;
    try {
        sheet2 = sheet.cloneSheet();
    } catch (RuntimeException e) {
        if (e.getMessage().equals("The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method")) {
            throw new AssertionFailedError("Identified bug 46776");
        }
        throw e;
    }
    RecordCollector rc = new RecordCollector();
    sheet2.visitContainedRecords(rc, 0);
    Record[] clonedRecs = rc.getRecords();
    // +2 for INDEX and DBCELL
    assertEquals(recs.length + 2, clonedRecs.length);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) RecordCollector(org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector) RowRecord(org.apache.poi.hssf.record.RowRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Example 73 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestOperandClassTransformer method testComplexIRR_bug45041.

public void testComplexIRR_bug45041() {
    String formula = "(1+IRR(SUMIF(A:A,ROW(INDIRECT(MIN(A:A)&\":\"&MAX(A:A))),B:B),0))^365-1";
    Ptg[] ptgs = parseFormula(formula);
    FuncVarPtg rowFunc = (FuncVarPtg) ptgs[10];
    FuncVarPtg sumifFunc = (FuncVarPtg) ptgs[12];
    assertEquals("ROW", rowFunc.getName());
    assertEquals("SUMIF", sumifFunc.getName());
    if (rowFunc.getPtgClass() == Ptg.CLASS_VALUE || sumifFunc.getPtgClass() == Ptg.CLASS_VALUE) {
        throw new AssertionFailedError("Identified bug 45041");
    }
    confirmTokenClass(ptgs, 1, Ptg.CLASS_REF);
    confirmTokenClass(ptgs, 2, Ptg.CLASS_REF);
    confirmFuncClass(ptgs, 3, "MIN", Ptg.CLASS_VALUE);
    confirmTokenClass(ptgs, 6, Ptg.CLASS_REF);
    confirmFuncClass(ptgs, 7, "MAX", Ptg.CLASS_VALUE);
    confirmFuncClass(ptgs, 9, "INDIRECT", Ptg.CLASS_REF);
    confirmFuncClass(ptgs, 10, "ROW", Ptg.CLASS_ARRAY);
    confirmTokenClass(ptgs, 11, Ptg.CLASS_REF);
    confirmFuncClass(ptgs, 12, "SUMIF", Ptg.CLASS_ARRAY);
    confirmFuncClass(ptgs, 14, "IRR", Ptg.CLASS_VALUE);
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) FuncVarPtg(org.apache.poi.ss.formula.ptg.FuncVarPtg) AbstractFunctionPtg(org.apache.poi.ss.formula.ptg.AbstractFunctionPtg) FuncVarPtg(org.apache.poi.ss.formula.ptg.FuncVarPtg) AssertionFailedError(junit.framework.AssertionFailedError)

Example 74 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestFormulaParserIf method confirmAttrData.

private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) {
    Ptg ptg = ptgs[i];
    if (!(ptg instanceof AttrPtg)) {
        throw new AssertionFailedError("Token[" + i + "] was not AttrPtg as expected");
    }
    AttrPtg attrPtg = (AttrPtg) ptg;
    assertEquals(expectedData, attrPtg.getData());
}
Also used : IntPtg(org.apache.poi.ss.formula.ptg.IntPtg) Ptg(org.apache.poi.ss.formula.ptg.Ptg) LessEqualPtg(org.apache.poi.ss.formula.ptg.LessEqualPtg) FuncVarPtg(org.apache.poi.ss.formula.ptg.FuncVarPtg) RefPtg(org.apache.poi.ss.formula.ptg.RefPtg) NotEqualPtg(org.apache.poi.ss.formula.ptg.NotEqualPtg) FuncPtg(org.apache.poi.ss.formula.ptg.FuncPtg) AttrPtg(org.apache.poi.ss.formula.ptg.AttrPtg) AddPtg(org.apache.poi.ss.formula.ptg.AddPtg) MultiplyPtg(org.apache.poi.ss.formula.ptg.MultiplyPtg) StringPtg(org.apache.poi.ss.formula.ptg.StringPtg) LessThanPtg(org.apache.poi.ss.formula.ptg.LessThanPtg) BoolPtg(org.apache.poi.ss.formula.ptg.BoolPtg) AttrPtg(org.apache.poi.ss.formula.ptg.AttrPtg) AssertionFailedError(junit.framework.AssertionFailedError)

Example 75 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestLinkTable method testMultipleExternSheetRecords_bug45698.

public void testMultipleExternSheetRecords_bug45698() {
    HSSFWorkbook wb;
    try {
        wb = HSSFTestDataSamples.openSampleWorkbook("ex45698-22488.xls");
    } catch (RuntimeException e) {
        if ("Extern sheet is part of LinkTable".equals(e.getMessage())) {
            throw new AssertionFailedError("Identified bug 45698");
        }
        throw e;
    }
    // some other sanity checks
    assertEquals(7, wb.getNumberOfSheets());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15