}
DissectionURLManager urlManager = new MyDissectionURLManager();
DocumentInformationImpl docInfo = new DocumentInformationImpl();
docInfo.setDocumentURL(new MarinerURL("common1.xml"));
Dissector dissector = new Dissector();
DissectedDocumentImpl dissected = (DissectedDocumentImpl)
dissector.createDissectedDocument(context, characteristics,
document, urlManager, docInfo);
// Check the characteristics of the dissected document.
NodeCounts expectedDocumentNodeCounts
= expectedDocumentStats.nodeCounts;
int dissectableAreaCount
= expectedDocumentNodeCounts.dissectableAreaCount;
assertEquals(failures,
"Incorrect number of dissectable areas,",
dissectableAreaCount,
dissected.getDissectableAreaCount());
// Check the node counts.
NodeCounts actualNodeCounts = null;
// Gather statistics by visiting all the nodes.
VisitingStatisticsGatherer visitor = new VisitingStatisticsGatherer();
document.visitDocument(visitor);
NodeCounts visitorStatistics = visitor.getStatistics().nodeCounts;
// Gather statistics by iterating over all the nodes.
IteratingStatisticsGatherer iterator = new IteratingStatisticsGatherer();
document.visitDocument(iterator);
NodeCounts iteratorStatistics = iterator.getStatistics().nodeCounts;
// Make sure that all the different methods of gathering statistics
// agree.
assertEquals("Discrepancy between statistics gatherers",
visitorStatistics, iteratorStatistics);
// Set the actualStatistics value so they can be output later.
actualNodeCounts = visitorStatistics;
// Check that the statistics match the expectation.
checkNodeCount(failures,
expectedDocumentStats.nodeCounts,
actualNodeCounts);
// Check the shared content usages.
checkSharedContentUsages(failures,
"Total Cost",
details,
expectedDocumentStats.getTotalContentUsages(),
dissected.getTotalContentUsages());
checkSharedContentUsages(failures,
"Fixed Cost",
details,
expectedDocumentStats.getFixedContentUsages(),
dissected.getFixedContentUsages());
// Check that the dissectable areas are correct.
for (int i = 0; i < dissectableAreaCount; i += 1) {
DissectableArea area = dissected.getDissectableArea(i);
DissectableAreaStats expectedDAStats
= expectedDocumentStats.getDissectableAreaStats(i);
checkDissectableArea(failures, details, context, area,
expectedDAStats);
}
OutputDocument output = createOutputDocument();
DissectedContentHandler outputHandler
= createDissectedContentHandler(output);
RequestedShards requestedShards = dissected.createRequestedShards();
dissector.serialize(context, dissected,
requestedShards, outputHandler);
int totalCost = dissected.getTotalCost();
int outputSize = output.getSize();
// Check output size is reasonable; we allow explicit output size to
// be greater than the total cost to handle WBDOM generating WML.