Search in sources :

Example 81 with AssertionFailedError

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

the class TestSheetPropertiesRecord method testLoad.

public void testLoad() {
    RecordInputStream in = TestcaseRecordInputStream.create(0x1044, data);
    SheetPropertiesRecord record = new SheetPropertiesRecord(in);
    if (in.remaining() == 1) {
        throw new AssertionFailedError("Identified bug 44693c");
    }
    assertEquals(0, in.remaining());
    assertEquals(10, record.getFlags());
    assertEquals(false, record.isChartTypeManuallyFormatted());
    assertEquals(true, record.isPlotVisibleOnly());
    assertEquals(false, record.isDoNotSizeWithWindow());
    assertEquals(true, record.isDefaultPlotDimensions());
    assertEquals(false, record.isAutoPlotArea());
    assertEquals(0, record.getEmpty());
    assertEquals(8, record.getRecordSize());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 82 with AssertionFailedError

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

the class TestExtendedPivotTableViewFieldsRecord method testSubNameNotPresent_bug46693.

public void testSubNameNotPresent_bug46693() {
    // This data came from attachment 23347 of bug 46693 at offset 0xAA43
    byte[] data = HexRead.readFromString(// BIFF header
    "00 01 14 00" + "1E 14 00 0A FF FF FF FF 00 00 FF FF 00 00 00 00 00 00 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
        rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
        if (e.getMessage().equals("Expected to find a ContinueRecord in order to read remaining 65535 of 65535 chars")) {
            throw new AssertionFailedError("Identified bug 46693a");
        }
        throw e;
    }
    assertEquals(data.length, rec.getRecordSize());
}
Also used : RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) ExtendedPivotTableViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 83 with AssertionFailedError

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

the class TestExtendedPivotTableViewFieldsRecord method testOlderFormat_bug46918.

public void testOlderFormat_bug46918() {
    // There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
    // They all had the following hex encoding:
    byte[] data = HexRead.readFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
        rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
        if (e.getMessage().equals("Not enough data (0) to read requested (2) bytes")) {
            throw new AssertionFailedError("Identified bug 46918");
        }
        throw e;
    }
    byte[] expReserData = HexRead.readFromString("1E 14 00 0A FF FF FF FF 00 00" + "FF FF 00 00 00 00 00 00 00 00");
    TestcaseRecordInputStream.confirmRecordEncoding(ExtendedPivotTableViewFieldsRecord.sid, expReserData, rec.serialize());
}
Also used : RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) ExtendedPivotTableViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 84 with AssertionFailedError

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

the class TestEvaluationCache method testBlankCellChangedToValueCell_bug46053.

/**
	 * Make sure that when blank cells are changed to value/formula cells, any dependent formulas
	 * have their cached results cleared.
	 */
public void testBlankCellChangedToValueCell_bug46053() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cellA1 = row.createCell(0);
    HSSFCell cellB1 = row.createCell(1);
    HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
    cellA1.setCellFormula("B1+2.2");
    cellB1.setCellValue(1.5);
    fe.notifyUpdateCell(cellA1);
    fe.notifyUpdateCell(cellB1);
    CellValue cv;
    cv = fe.evaluate(cellA1);
    assertEquals(3.7, cv.getNumberValue(), 0.0);
    cellB1.setCellType(CellType.BLANK);
    fe.notifyUpdateCell(cellB1);
    // B1 was used to evaluate A1
    cv = fe.evaluate(cellA1);
    assertEquals(2.2, cv.getNumberValue(), 0.0);
    // changing B1, so A1 cached result should be cleared
    cellB1.setCellValue(0.4);
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1);
    if (cv.getNumberValue() == 2.2) {
        // looks like left-over cached result from before change to B1
        throw new AssertionFailedError("Identified bug 46053");
    }
    assertEquals(2.6, cv.getNumberValue(), 0.0);
}
Also used : HSSFFormulaEvaluator(org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 85 with AssertionFailedError

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

the class TestParseMissingBuiltInFuncs method confirmFunc.

private static void confirmFunc(String formula, int expPtgArraySize, boolean isVarArgFunc, int funcIx) throws IOException {
    Ptg[] ptgs = parse(formula);
    // func is last RPN token in all these formulas
    Ptg ptgF = ptgs[ptgs.length - 1];
    // Check critical things in the Ptg array encoding.
    if (!(ptgF instanceof AbstractFunctionPtg)) {
        throw new RuntimeException("function token missing");
    }
    AbstractFunctionPtg func = (AbstractFunctionPtg) ptgF;
    if (func.getFunctionIndex() == 255) {
        throw new AssertionFailedError("Failed to recognise built-in function in formula '" + formula + "'");
    }
    assertEquals(expPtgArraySize, ptgs.length);
    assertEquals(funcIx, func.getFunctionIndex());
    Class<? extends AbstractFunctionPtg> expCls = isVarArgFunc ? FuncVarPtg.class : FuncPtg.class;
    assertEquals(expCls, ptgF.getClass());
    // check that parsed Ptg array converts back to formula text OK
    HSSFWorkbook book = new HSSFWorkbook();
    String reRenderedFormula = HSSFFormulaParser.toFormulaString(book, ptgs);
    assertEquals(formula, reRenderedFormula);
    book.close();
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) FuncVarPtg(org.apache.poi.ss.formula.ptg.FuncVarPtg) FuncPtg(org.apache.poi.ss.formula.ptg.FuncPtg) AbstractFunctionPtg(org.apache.poi.ss.formula.ptg.AbstractFunctionPtg) AbstractFunctionPtg(org.apache.poi.ss.formula.ptg.AbstractFunctionPtg) 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