Search in sources :

Example 76 with AssertionFailedError

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

the class TestCFRuleRecord method testReserializeRefNTokens.

/**
     * tRefN and tAreaN tokens must be preserved when re-serializing conditional format formulas
     */
@Test
public void testReserializeRefNTokens() {
    RecordInputStream is = TestcaseRecordInputStream.create(CFRuleRecord.sid, DATA_REFN);
    CFRuleRecord rr = new CFRuleRecord(is);
    Ptg[] ptgs = rr.getParsedExpression1();
    assertEquals(3, ptgs.length);
    if (ptgs[0] instanceof RefPtg) {
        throw new AssertionFailedError("Identified bug 45234");
    }
    assertEquals(RefNPtg.class, ptgs[0].getClass());
    RefNPtg refNPtg = (RefNPtg) ptgs[0];
    assertTrue(refNPtg.isColRelative());
    assertTrue(refNPtg.isRowRelative());
    byte[] data = rr.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) RefPtg(org.apache.poi.ss.formula.ptg.RefPtg) RefNPtg(org.apache.poi.ss.formula.ptg.RefNPtg) RefNPtg(org.apache.poi.ss.formula.ptg.RefNPtg) RefPtg(org.apache.poi.ss.formula.ptg.RefPtg) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Example 77 with AssertionFailedError

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

the class TestColumnInfoRecord method testZeroResevedBytes_bug48332.

/**
	 * Some applications skip the last reserved field when writing {@link ColumnInfoRecord}s
	 * The attached file was apparently created by "SoftArtisans OfficeWriter for Excel".
	 * Excel reads that file OK and assumes zero for the value of the reserved field.
	 */
public void testZeroResevedBytes_bug48332() {
    // Taken from bugzilla attachment 24661 (offset 0x1E73)
    byte[] inpData = HexRead.readFromString("7D 00 0A 00 00 00 00 00 D5 19 0F 00 02 00");
    byte[] outData = HexRead.readFromString("7D 00 0C 00 00 00 00 00 D5 19 0F 00 02 00 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(inpData);
    ColumnInfoRecord cir;
    try {
        cir = new ColumnInfoRecord(in);
    } catch (RuntimeException e) {
        if (e.getMessage().equals("Unusual record size remaining=(0)")) {
            throw new AssertionFailedError("Identified bug 48332");
        }
        throw e;
    }
    assertEquals(0, in.remaining());
    assertArrayEquals(outData, cir.serialize());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 78 with AssertionFailedError

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

the class TestViewFieldsRecord method testUnicodeFlag_bug46693.

public void testUnicodeFlag_bug46693() {
    byte[] data = HexRead.readFromString("01 00 01 00 01 00 04 00 05 00 00 6D 61 72 63 6F");
    RecordInputStream in = TestcaseRecordInputStream.create(ViewFieldsRecord.sid, data);
    ViewFieldsRecord rec = new ViewFieldsRecord(in);
    if (in.remaining() == 1) {
        throw new AssertionFailedError("Identified bug 46693b");
    }
    assertEquals(0, in.remaining());
    assertEquals(4 + data.length, rec.getRecordSize());
}
Also used : ViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ViewFieldsRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 79 with AssertionFailedError

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

the class TestSharedValueManager method testPartiallyOverlappingRanges.

/**
	 * This bug happened when there were two or more shared formula ranges that overlapped.  POI
	 * would sometimes associate formulas in the overlapping region with the wrong shared formula
	 */
public void testPartiallyOverlappingRanges() {
    Record[] records;
    int attempt = 1;
    do {
        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
        HSSFSheet sheet = wb.getSheetAt(0);
        RecordInspector.getRecords(sheet, 0);
        assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
        if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
            throw new AssertionFailedError("Identified bug - wrong shared formula record chosen" + " (attempt " + attempt + ")");
        }
        assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
        records = RecordInspector.getRecords(sheet, 0);
    } while (attempt++ < MAX_ATTEMPTS);
    int count = 0;
    for (Record record : records) {
        if (record instanceof SharedFormulaRecord) {
            count++;
        }
    }
    assertEquals(2, count);
}
Also used : SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) Record(org.apache.poi.hssf.record.Record) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 80 with AssertionFailedError

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

the class TestSeriesTextRecord method testReserializeLongTitle.

public void testReserializeLongTitle() {
    // Hex dump from bug 45784 attachment 22560 streamOffset=0x0CD1
    byte[] data = HexRead.readFromString("00 00, " + "82 " + "01 " + "50 00 6C 00 61 00 73 00 6D 00 61 00 20 00 4C 00 " + "65 00 76 00 65 00 6C 00 73 00 20 00 6F 00 66 00 " + "20 00 4C 00 2D 00 30 00 30 00 30 00 31 00 31 00 " + "31 00 32 00 32 00 32 00 2D 00 33 00 33 00 33 00 " + "58 00 34 00 34 00 34 00 20 00 69 00 6E 00 20 00 " + "53 00 44 00 20 00 72 00 61 00 74 00 0A 00 50 00 " + "4F 00 20 00 33 00 2E 00 30 00 20 00 6D 00 67 00 " + "2F 00 6B 00 67 00 20 00 28 00 35 00 2E 00 30 00 " + "20 00 6D 00 4C 00 2F 00 6B 00 67 00 29 00 20 00 " + "69 00 6E 00 20 00 4D 00 65 00 74 00 68 00 6F 00 " + "63 00 65 00 6C 00 0A 00 49 00 56 00 20 00 30 00 " + "2E 00 35 00 20 00 6D 00 67 00 2F 00 6B 00 67 00 " + "20 00 28 00 31 00 2E 00 30 00 20 00 6D 00 4C 00 " + "2F 00 6B 00 67 00 29 00 20 00 69 00 6E 00 20 00 " + "36 00 30 00 25 00 20 00 50 00 45 00 47 00 20 00 " + "32 00 30 00 30 00 0A 00 46 00 20 00 3D 00 61 00 " + "62 00 63 00");
    RecordInputStream in = TestcaseRecordInputStream.create(SeriesTextRecord.sid, data);
    SeriesTextRecord str;
    try {
        str = new SeriesTextRecord(in);
    } catch (RecordFormatException e) {
        if (e.getCause() instanceof IllegalArgumentException) {
            // "Bad requested string length (-126)"
            throw new AssertionFailedError("Identified bug 45784a");
        }
        throw e;
    }
    if (str.getRecordSize() < 0) {
        throw new AssertionFailedError("Identified bug 45784b");
    }
    byte[] ser;
    try {
        ser = str.serialize();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
}
Also used : RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream) RecordFormatException(org.apache.poi.hssf.record.RecordFormatException)

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