whitespace

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765741 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-10-20 02:24:50 +00:00
parent ab6dd76f6a
commit 0821c1e4b2

View File

@ -44,76 +44,76 @@ import org.junit.Test;
* @author Nick Burch (nick at torchbox dot com) * @author Nick Burch (nick at torchbox dot com)
*/ */
public final class TestReWriteSanity { public final class TestReWriteSanity {
// HSLFSlideShow primed on the test data // HSLFSlideShow primed on the test data
private HSLFSlideShowImpl ss; private HSLFSlideShowImpl ss;
// POIFS primed on the test data // POIFS primed on the test data
private POIFSFileSystem pfs; private POIFSFileSystem pfs;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShowImpl(pfs); ss = new HSLFSlideShowImpl(pfs);
}
@After
public void tearDown() throws Exception {
pfs.close();
ss.close();
} }
@After
public void tearDown() throws Exception {
pfs.close();
ss.close();
}
@Test @Test
public void testUserEditAtomsRight() throws Exception { public void testUserEditAtomsRight() throws Exception {
// Write out to a byte array // Write out to a byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ss.write(baos); ss.write(baos);
// Build an input stream of it // Build an input stream of it
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
// Create a new one from that // Create a new one from that
HSLFSlideShowImpl wss = new HSLFSlideShowImpl(bais); HSLFSlideShowImpl wss = new HSLFSlideShowImpl(bais);
// Find the location of the PersistPtrIncrementalBlocks and // Find the location of the PersistPtrIncrementalBlocks and
// UserEditAtoms // UserEditAtoms
Record[] r = wss.getRecords(); Record[] r = wss.getRecords();
Map<Integer,Record> pp = new HashMap<Integer,Record>(); Map<Integer,Record> pp = new HashMap<Integer,Record>();
Map<Integer,Object> ue = new HashMap<Integer,Object>(); Map<Integer,Object> ue = new HashMap<Integer,Object>();
ue.put(Integer.valueOf(0),Integer.valueOf(0)); // Will show 0 if first ue.put(Integer.valueOf(0),Integer.valueOf(0)); // Will show 0 if first
int pos = 0; int pos = 0;
int lastUEPos = -1; int lastUEPos = -1;
for (final Record rec : r) { for (final Record rec : r) {
if(rec instanceof PersistPtrHolder) { if(rec instanceof PersistPtrHolder) {
pp.put(Integer.valueOf(pos), rec); pp.put(Integer.valueOf(pos), rec);
} }
if(rec instanceof UserEditAtom) { if(rec instanceof UserEditAtom) {
ue.put(Integer.valueOf(pos), rec); ue.put(Integer.valueOf(pos), rec);
lastUEPos = pos; lastUEPos = pos;
} }
ByteArrayOutputStream bc = new ByteArrayOutputStream(); ByteArrayOutputStream bc = new ByteArrayOutputStream();
rec.writeOut(bc); rec.writeOut(bc);
pos += bc.size(); pos += bc.size();
} }
// Check that the UserEditAtom's point to right stuff // Check that the UserEditAtom's point to right stuff
for (final Record rec : r) { for (final Record rec : r) {
if(rec instanceof UserEditAtom) { if(rec instanceof UserEditAtom) {
UserEditAtom uea = (UserEditAtom)rec; UserEditAtom uea = (UserEditAtom)rec;
int luPos = uea.getLastUserEditAtomOffset(); int luPos = uea.getLastUserEditAtomOffset();
int ppPos = uea.getPersistPointersOffset(); int ppPos = uea.getPersistPointersOffset();
assertContains(ue, Integer.valueOf(luPos)); assertContains(ue, Integer.valueOf(luPos));
assertContains(pp, Integer.valueOf(ppPos)); assertContains(pp, Integer.valueOf(ppPos));
} }
} }
// Check that the CurrentUserAtom points to the right UserEditAtom // Check that the CurrentUserAtom points to the right UserEditAtom
CurrentUserAtom cua = wss.getCurrentUserAtom(); CurrentUserAtom cua = wss.getCurrentUserAtom();
int listedUEPos = (int)cua.getCurrentEditOffset(); int listedUEPos = (int)cua.getCurrentEditOffset();
assertEquals(lastUEPos,listedUEPos); assertEquals(lastUEPos,listedUEPos);
wss.close(); wss.close();
} }
} }