mirror of https://github.com/apache/poi.git
Fix inconsistent indents
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690790 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
768acdd838
commit
f5ce1eb174
|
@ -43,91 +43,89 @@ import org.apache.poi.util.LittleEndian;
|
||||||
* class works correctly.
|
* class works correctly.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public final class TestCFRecordsAggregate extends TestCase
|
public final class TestCFRecordsAggregate extends TestCase {
|
||||||
{
|
public void testCFRecordsAggregate() {
|
||||||
public void testCFRecordsAggregate()
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
{
|
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
||||||
HSSFSheet sheet = workbook.createSheet();
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
|
|
||||||
List<Record> recs = new ArrayList<Record>();
|
List<Record> recs = new ArrayList<Record>();
|
||||||
CFHeaderBase header = new CFHeaderRecord();
|
CFHeaderBase header = new CFHeaderRecord();
|
||||||
CFRuleBase rule1 = CFRuleRecord.create(sheet, "7");
|
CFRuleBase rule1 = CFRuleRecord.create(sheet, "7");
|
||||||
CFRuleBase rule2 = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5");
|
CFRuleBase rule2 = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5");
|
||||||
CFRuleBase rule3 = CFRuleRecord.create(sheet, ComparisonOperator.GE, "100", null);
|
CFRuleBase rule3 = CFRuleRecord.create(sheet, ComparisonOperator.GE, "100", null);
|
||||||
header.setNumberOfConditionalFormats(3);
|
header.setNumberOfConditionalFormats(3);
|
||||||
CellRangeAddress[] cellRanges = {
|
CellRangeAddress[] cellRanges = {
|
||||||
new CellRangeAddress(0,1,0,0),
|
new CellRangeAddress(0,1,0,0),
|
||||||
new CellRangeAddress(0,1,2,2),
|
new CellRangeAddress(0,1,2,2),
|
||||||
};
|
};
|
||||||
header.setCellRanges(cellRanges);
|
header.setCellRanges(cellRanges);
|
||||||
recs.add(header);
|
recs.add(header);
|
||||||
recs.add(rule1);
|
recs.add(rule1);
|
||||||
recs.add(rule2);
|
recs.add(rule2);
|
||||||
recs.add(rule3);
|
recs.add(rule3);
|
||||||
CFRecordsAggregate record;
|
CFRecordsAggregate record;
|
||||||
record = CFRecordsAggregate.createCFAggregate(new RecordStream(recs, 0));
|
record = CFRecordsAggregate.createCFAggregate(new RecordStream(recs, 0));
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
byte [] serializedRecord = new byte[record.getRecordSize()];
|
byte [] serializedRecord = new byte[record.getRecordSize()];
|
||||||
record.serialize(0, serializedRecord);
|
record.serialize(0, serializedRecord);
|
||||||
InputStream in = new ByteArrayInputStream(serializedRecord);
|
InputStream in = new ByteArrayInputStream(serializedRecord);
|
||||||
|
|
||||||
//Parse
|
//Parse
|
||||||
recs = RecordFactory.createRecords(in);
|
recs = RecordFactory.createRecords(in);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertNotNull(recs);
|
assertNotNull(recs);
|
||||||
assertEquals(4, recs.size());
|
assertEquals(4, recs.size());
|
||||||
|
|
||||||
header = (CFHeaderRecord)recs.get(0);
|
header = (CFHeaderRecord)recs.get(0);
|
||||||
rule1 = (CFRuleRecord)recs.get(1);
|
rule1 = (CFRuleRecord)recs.get(1);
|
||||||
rule2 = (CFRuleRecord)recs.get(2);
|
rule2 = (CFRuleRecord)recs.get(2);
|
||||||
rule3 = (CFRuleRecord)recs.get(3);
|
rule3 = (CFRuleRecord)recs.get(3);
|
||||||
cellRanges = header.getCellRanges();
|
cellRanges = header.getCellRanges();
|
||||||
|
|
||||||
assertEquals(2, cellRanges.length);
|
assertEquals(2, cellRanges.length);
|
||||||
assertEquals(3, header.getNumberOfConditionalFormats());
|
assertEquals(3, header.getNumberOfConditionalFormats());
|
||||||
|
|
||||||
record = CFRecordsAggregate.createCFAggregate(new RecordStream(recs, 0));
|
record = CFRecordsAggregate.createCFAggregate(new RecordStream(recs, 0));
|
||||||
|
|
||||||
record = record.cloneCFAggregate();
|
record = record.cloneCFAggregate();
|
||||||
|
|
||||||
assertNotNull(record.getHeader());
|
assertNotNull(record.getHeader());
|
||||||
assertEquals(3,record.getNumberOfRules());
|
assertEquals(3,record.getNumberOfRules());
|
||||||
|
|
||||||
header = record.getHeader();
|
header = record.getHeader();
|
||||||
rule1 = record.getRule(0);
|
rule1 = record.getRule(0);
|
||||||
rule2 = record.getRule(1);
|
rule2 = record.getRule(1);
|
||||||
rule3 = record.getRule(2);
|
rule3 = record.getRule(2);
|
||||||
cellRanges = header.getCellRanges();
|
cellRanges = header.getCellRanges();
|
||||||
|
|
||||||
assertEquals(2, cellRanges.length);
|
assertEquals(2, cellRanges.length);
|
||||||
assertEquals(3, header.getNumberOfConditionalFormats());
|
assertEquals(3, header.getNumberOfConditionalFormats());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure that the CF Header record is properly updated with the number of rules
|
* Make sure that the CF Header record is properly updated with the number of rules
|
||||||
*/
|
*/
|
||||||
public void testNRules() {
|
public void testNRules() {
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
HSSFSheet sheet = workbook.createSheet();
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
CellRangeAddress[] cellRanges = {
|
CellRangeAddress[] cellRanges = {
|
||||||
new CellRangeAddress(0,1,0,0),
|
new CellRangeAddress(0,1,0,0),
|
||||||
new CellRangeAddress(0,1,2,2),
|
new CellRangeAddress(0,1,2,2),
|
||||||
};
|
};
|
||||||
CFRuleRecord[] rules = {
|
CFRuleRecord[] rules = {
|
||||||
CFRuleRecord.create(sheet, "7"),
|
CFRuleRecord.create(sheet, "7"),
|
||||||
CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5"),
|
CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5"),
|
||||||
};
|
};
|
||||||
CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);
|
CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);
|
||||||
byte[] serializedRecord = new byte[agg.getRecordSize()];
|
byte[] serializedRecord = new byte[agg.getRecordSize()];
|
||||||
agg.serialize(0, serializedRecord);
|
agg.serialize(0, serializedRecord);
|
||||||
|
|
||||||
int nRules = LittleEndian.getUShort(serializedRecord, 4);
|
int nRules = LittleEndian.getUShort(serializedRecord, 4);
|
||||||
if (nRules == 0) {
|
if (nRules == 0) {
|
||||||
throw new AssertionFailedError("Identified bug 45682 b");
|
throw new AssertionFailedError("Identified bug 45682 b");
|
||||||
}
|
}
|
||||||
assertEquals(rules.length, nRules);
|
assertEquals(rules.length, nRules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue