use of org.apache.poi.hssf.usermodel.SanityChecker.CheckRecord in project poi by apache.
the class TestSanityChecker method testCheckRecordOrder.
@Test
public void testCheckRecordOrder() {
final SanityChecker c = new SanityChecker();
List<Record> records = new ArrayList<Record>();
records.add(new BOFRecord());
records.add(INTERFACEHDR);
records.add(createBoundSheetRec());
records.add(EOFRecord.instance);
CheckRecord[] check = { new CheckRecord(BOFRecord.class, '1'), new CheckRecord(InterfaceHdrRecord.class, '0'), new CheckRecord(BoundSheetRecord.class, 'M'), new CheckRecord(NameRecord.class, '*'), new CheckRecord(EOFRecord.class, '1') };
// check pass
c.checkRecordOrder(records, check);
records.add(2, createBoundSheetRec());
c.checkRecordOrder(records, check);
// optional record missing
records.remove(1);
c.checkRecordOrder(records, check);
records.add(3, new NameRecord());
// optional multiple record occurs more than one time
records.add(3, new NameRecord());
c.checkRecordOrder(records, check);
// check fail
confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
confirmBadRecordOrder(check, new Record[] { new BOFRecord(), INTERFACEHDR, createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), new NameRecord(), EOFRecord.instance, new NameRecord() });
confirmBadRecordOrder(check, new Record[] { INTERFACEHDR, createBoundSheetRec(), EOFRecord.instance });
confirmBadRecordOrder(check, new Record[] { new BOFRecord(), INTERFACEHDR, EOFRecord.instance });
confirmBadRecordOrder(check, new Record[] { INTERFACEHDR, createBoundSheetRec(), new BOFRecord(), EOFRecord.instance });
confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
}
Aggregations