Whitespace
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1766501 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e01fe6f68
commit
6bbdb9c8a5
@ -17,80 +17,80 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdgf;
|
package org.apache.poi.hdgf;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.hdgf.extractor.VisioTextExtractor;
|
import org.apache.poi.hdgf.extractor.VisioTextExtractor;
|
||||||
import org.apache.poi.hdgf.streams.PointerContainingStream;
|
import org.apache.poi.hdgf.streams.PointerContainingStream;
|
||||||
import org.apache.poi.hdgf.streams.TrailerStream;
|
import org.apache.poi.hdgf.streams.TrailerStream;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.apache.poi.POIDataSamples;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
public final class TestHDGFCore extends TestCase {
|
public final class TestHDGFCore extends TestCase {
|
||||||
private static POIDataSamples _dgTests = POIDataSamples.getDiagramInstance();
|
private static POIDataSamples _dgTests = POIDataSamples.getDiagramInstance();
|
||||||
|
|
||||||
private POIFSFileSystem fs;
|
private POIFSFileSystem fs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("Test_Visio-Some_Random_Text.vsd"));
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("Test_Visio-Some_Random_Text.vsd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreate() throws Exception {
|
|
||||||
new HDGFDiagram(fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testTrailer() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
new HDGFDiagram(fs);
|
||||||
assertNotNull(hdgf);
|
}
|
||||||
assertNotNull(hdgf.getTrailerStream());
|
|
||||||
|
|
||||||
// Check it has what we'd expect
|
public void testTrailer() throws Exception {
|
||||||
TrailerStream trailer = hdgf.getTrailerStream();
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
assertEquals(0x8a94, trailer.getPointer().getOffset());
|
assertNotNull(hdgf);
|
||||||
|
assertNotNull(hdgf.getTrailerStream());
|
||||||
|
|
||||||
assertNotNull(trailer.getPointedToStreams());
|
// Check it has what we'd expect
|
||||||
assertEquals(20, trailer.getPointedToStreams().length);
|
TrailerStream trailer = hdgf.getTrailerStream();
|
||||||
|
assertEquals(0x8a94, trailer.getPointer().getOffset());
|
||||||
|
|
||||||
assertEquals(20, hdgf.getTopLevelStreams().length);
|
assertNotNull(trailer.getPointedToStreams());
|
||||||
|
assertEquals(20, trailer.getPointedToStreams().length);
|
||||||
|
|
||||||
// 9th one should have children
|
assertEquals(20, hdgf.getTopLevelStreams().length);
|
||||||
assertNotNull(trailer.getPointedToStreams()[8]);
|
|
||||||
assertNotNull(trailer.getPointedToStreams()[8].getPointer());
|
|
||||||
PointerContainingStream ps8 = (PointerContainingStream)
|
|
||||||
trailer.getPointedToStreams()[8];
|
|
||||||
assertNotNull(ps8.getPointedToStreams());
|
|
||||||
assertEquals(8, ps8.getPointedToStreams().length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 9th one should have children
|
||||||
* Tests that we can open a problematic file, that used to
|
assertNotNull(trailer.getPointedToStreams()[8]);
|
||||||
* break with a negative chunk length
|
assertNotNull(trailer.getPointedToStreams()[8].getPointer());
|
||||||
*/
|
PointerContainingStream ps8 = (PointerContainingStream)
|
||||||
public void testNegativeChunkLength() throws Exception {
|
trailer.getPointedToStreams()[8];
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength.vsd"));
|
assertNotNull(ps8.getPointedToStreams());
|
||||||
|
assertEquals(8, ps8.getPointedToStreams().length);
|
||||||
|
}
|
||||||
|
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
/**
|
||||||
assertNotNull(hdgf);
|
* Tests that we can open a problematic file, that used to
|
||||||
|
* break with a negative chunk length
|
||||||
|
*/
|
||||||
|
public void testNegativeChunkLength() throws Exception {
|
||||||
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength.vsd"));
|
||||||
|
|
||||||
// And another file
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength2.vsd"));
|
assertNotNull(hdgf);
|
||||||
hdgf = new HDGFDiagram(fs);
|
|
||||||
assertNotNull(hdgf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// And another file
|
||||||
* Tests that we can open a problematic file that triggers
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("NegativeChunkLength2.vsd"));
|
||||||
* an ArrayIndexOutOfBoundsException when processing the
|
hdgf = new HDGFDiagram(fs);
|
||||||
* chunk commands.
|
assertNotNull(hdgf);
|
||||||
* @throws Exception
|
}
|
||||||
*/
|
|
||||||
public void DISABLEDtestAIOOB() throws Exception {
|
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("44501.vsd"));
|
|
||||||
|
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
/**
|
||||||
assertNotNull(hdgf);
|
* Tests that we can open a problematic file that triggers
|
||||||
}
|
* an ArrayIndexOutOfBoundsException when processing the
|
||||||
|
* chunk commands.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void DISABLEDtestAIOOB() throws Exception {
|
||||||
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("44501.vsd"));
|
||||||
|
|
||||||
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
|
assertNotNull(hdgf);
|
||||||
|
}
|
||||||
|
|
||||||
public void testV5() throws Exception {
|
public void testV5() throws Exception {
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("v5_Connection_Types.vsd"));
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("v5_Connection_Types.vsd"));
|
||||||
@ -105,26 +105,26 @@ public final class TestHDGFCore extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testV6NonUtf16LE() throws Exception {
|
public void testV6NonUtf16LE() throws Exception {
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("v6-non-utf16le.vsd"));
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("v6-non-utf16le.vsd"));
|
||||||
|
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
assertNotNull(hdgf);
|
assertNotNull(hdgf);
|
||||||
|
|
||||||
VisioTextExtractor textExtractor = new VisioTextExtractor(hdgf);
|
VisioTextExtractor textExtractor = new VisioTextExtractor(hdgf);
|
||||||
String text = textExtractor.getText().replace("\u0000", "").trim();
|
String text = textExtractor.getText().replace("\u0000", "").trim();
|
||||||
|
|
||||||
assertEquals("Table\n\n\nPropertySheet\n\n\n\nPropertySheetField", text);
|
assertEquals("Table\n\n\nPropertySheet\n\n\n\nPropertySheetField", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUtf16LE() throws Exception {
|
public void testUtf16LE() throws Exception {
|
||||||
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("Test_Visio-Some_Random_Text.vsd"));
|
fs = new POIFSFileSystem(_dgTests.openResourceAsStream("Test_Visio-Some_Random_Text.vsd"));
|
||||||
|
|
||||||
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
HDGFDiagram hdgf = new HDGFDiagram(fs);
|
||||||
assertNotNull(hdgf);
|
assertNotNull(hdgf);
|
||||||
|
|
||||||
VisioTextExtractor textExtractor = new VisioTextExtractor(hdgf);
|
VisioTextExtractor textExtractor = new VisioTextExtractor(hdgf);
|
||||||
String text = textExtractor.getText().trim();
|
String text = textExtractor.getText().trim();
|
||||||
|
|
||||||
assertEquals("text\nView\nTest View\nI am a test view\nSome random text, on a page", text);
|
assertEquals("text\nView\nTest View\nI am a test view\nSome random text, on a page", text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user