You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 21:37:10 UTC
svn commit: r1890122 [11/16] - in /poi/trunk/poi-scratchpad/src:
main/java/org/apache/poi/hdgf/ main/java/org/apache/poi/hdgf/chunks/
main/java/org/apache/poi/hdgf/dev/ main/java/org/apache/poi/hdgf/exceptions/
main/java/org/apache/poi/hdgf/extractor/ ...
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hdgf/streams/TestStreamComplex.java Sat May 22 21:37:08 2021
@@ -37,246 +37,246 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public final class TestStreamComplex extends StreamTest {
- private byte[] contents;
- private final int trailerPointerAt = 0x24;
- private final int trailerDataAt = 0x8a94;
- private ChunkFactory chunkFactory;
- private PointerFactory ptrFactory;
+ private byte[] contents;
+ private final int trailerPointerAt = 0x24;
+ private final int trailerDataAt = 0x8a94;
+ private ChunkFactory chunkFactory;
+ private PointerFactory ptrFactory;
- @BeforeEach
+ @BeforeEach
void setUp() throws IOException {
- ptrFactory = new PointerFactory(11);
- chunkFactory = new ChunkFactory(11);
+ ptrFactory = new PointerFactory(11);
+ chunkFactory = new ChunkFactory(11);
InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("Test_Visio-Some_Random_Text.vsd");
- POIFSFileSystem filesystem = new POIFSFileSystem(is);
- is.close();
+ POIFSFileSystem filesystem = new POIFSFileSystem(is);
+ is.close();
- // Grab the document stream
- InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
- contents = IOUtils.toByteArray(is2);
- is2.close();
-
- filesystem.close();
- }
-
- /**
- * Test creating the trailer, but not looking for children
- */
- @Test
+ // Grab the document stream
+ InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
+ contents = IOUtils.toByteArray(is2);
+ is2.close();
+
+ filesystem.close();
+ }
+
+ /**
+ * Test creating the trailer, but not looking for children
+ */
+ @Test
void testTrailer() {
- // Find the trailer
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ // Find the trailer
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- assertEquals(20, trailerPtr.getType());
- assertEquals(trailerDataAt, trailerPtr.getOffset());
+ assertEquals(20, trailerPtr.getType());
+ assertEquals(trailerDataAt, trailerPtr.getOffset());
- Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- assertTrue(stream instanceof TrailerStream);
- TrailerStream ts = (TrailerStream)stream;
-
- assertNotNull(ts.getChildPointers());
- assertNull(ts.getPointedToStreams());
-
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(0x16, ts.getChildPointers()[0].getType());
- assertEquals(0x17, ts.getChildPointers()[1].getType());
- assertEquals(0x17, ts.getChildPointers()[2].getType());
- assertEquals(0xff, ts.getChildPointers()[3].getType());
- }
+ Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ assertTrue(stream instanceof TrailerStream);
+ TrailerStream ts = (TrailerStream)stream;
+
+ assertNotNull(ts.getChildPointers());
+ assertNull(ts.getPointedToStreams());
+
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(0x16, ts.getChildPointers()[0].getType());
+ assertEquals(0x17, ts.getChildPointers()[1].getType());
+ assertEquals(0x17, ts.getChildPointers()[2].getType());
+ assertEquals(0xff, ts.getChildPointers()[3].getType());
+ }
- @Test
+ @Test
void testChunks() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
- // Should be 7th one
- Pointer chunkPtr = ts.getChildPointers()[5];
- assertFalse(chunkPtr.destinationHasStrings());
- assertTrue(chunkPtr.destinationHasChunks());
- assertFalse(chunkPtr.destinationHasPointers());
-
- Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(stream);
- assertTrue(stream instanceof ChunkStream);
-
- // Now find the chunks within it
- ChunkStream cs = (ChunkStream)stream;
- cs.findChunks();
- }
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+
+ // Should be 7th one
+ Pointer chunkPtr = ts.getChildPointers()[5];
+ assertFalse(chunkPtr.destinationHasStrings());
+ assertTrue(chunkPtr.destinationHasChunks());
+ assertFalse(chunkPtr.destinationHasPointers());
+
+ Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
+ assertNotNull(stream);
+ assertTrue(stream instanceof ChunkStream);
+
+ // Now find the chunks within it
+ ChunkStream cs = (ChunkStream)stream;
+ cs.findChunks();
+ }
- @Test
+ @Test
void testStrings() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
- // Should be the 1st one
- Pointer stringPtr = ts.getChildPointers()[0];
- assertTrue(stringPtr.destinationHasStrings());
- assertFalse(stringPtr.destinationHasChunks());
- assertFalse(stringPtr.destinationHasPointers());
-
- Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(stream);
- assertTrue(stream instanceof StringsStream);
- }
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+
+ // Should be the 1st one
+ Pointer stringPtr = ts.getChildPointers()[0];
+ assertTrue(stringPtr.destinationHasStrings());
+ assertFalse(stringPtr.destinationHasChunks());
+ assertFalse(stringPtr.destinationHasPointers());
+
+ Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
+ assertNotNull(stream);
+ assertTrue(stream instanceof StringsStream);
+ }
- @Test
+ @Test
void testPointerToStrings() {
- // The stream at 0x347f has strings
- // The stream at 0x4312 has a pointer to 0x347f
- // The stream at 0x44d3 has a pointer to 0x4312
- // (it's the 2nd one of 3, and the block is compressed)
-
- TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
- ptr44d3.hasPointers = true;
- PointerContainingStream s44d3 = (PointerContainingStream)
- Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
-
- // Type: 0d Addr: 014ff644 Offset: 4312 Len: 48 Format: 54 From: 44d3
- Pointer ptr4312 = s44d3.getChildPointers()[1];
- assertEquals(0x0d, ptr4312.getType());
- assertEquals(0x4312, ptr4312.getOffset());
- assertEquals(0x48, ptr4312.getLength());
- assertEquals(0x54, ptr4312.getFormat());
- assertTrue(ptr4312.destinationHasPointers());
- assertFalse(ptr4312.destinationHasStrings());
-
- PointerContainingStream s4312 = (PointerContainingStream)
- Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
-
- // Check it has 0x347f
- // Type: 1f Addr: 01540004 Offset: 347f Len: 8e8 Format: 46 From: 4312
- assertEquals(2, s4312.getChildPointers().length);
- Pointer ptr347f = s4312.getChildPointers()[0];
- assertEquals(0x1f, ptr347f.getType());
- assertEquals(0x347f, ptr347f.getOffset());
- assertEquals(0x8e8, ptr347f.getLength());
- assertEquals(0x46, ptr347f.getFormat());
- assertFalse(ptr347f.destinationHasPointers());
- assertTrue(ptr347f.destinationHasStrings());
-
- // Find the children of 0x4312
- assertNull(s4312.getPointedToStreams());
- s4312.findChildren(contents);
- // Should have two, both strings
- assertNotNull(s4312.getPointedToStreams());
- assertEquals(2, s4312.getPointedToStreams().length);
- assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
- assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
- }
+ // The stream at 0x347f has strings
+ // The stream at 0x4312 has a pointer to 0x347f
+ // The stream at 0x44d3 has a pointer to 0x4312
+ // (it's the 2nd one of 3, and the block is compressed)
+
+ TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
+ ptr44d3.hasPointers = true;
+ PointerContainingStream s44d3 = (PointerContainingStream)
+ Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
+
+ // Type: 0d Addr: 014ff644 Offset: 4312 Len: 48 Format: 54 From: 44d3
+ Pointer ptr4312 = s44d3.getChildPointers()[1];
+ assertEquals(0x0d, ptr4312.getType());
+ assertEquals(0x4312, ptr4312.getOffset());
+ assertEquals(0x48, ptr4312.getLength());
+ assertEquals(0x54, ptr4312.getFormat());
+ assertTrue(ptr4312.destinationHasPointers());
+ assertFalse(ptr4312.destinationHasStrings());
+
+ PointerContainingStream s4312 = (PointerContainingStream)
+ Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
+
+ // Check it has 0x347f
+ // Type: 1f Addr: 01540004 Offset: 347f Len: 8e8 Format: 46 From: 4312
+ assertEquals(2, s4312.getChildPointers().length);
+ Pointer ptr347f = s4312.getChildPointers()[0];
+ assertEquals(0x1f, ptr347f.getType());
+ assertEquals(0x347f, ptr347f.getOffset());
+ assertEquals(0x8e8, ptr347f.getLength());
+ assertEquals(0x46, ptr347f.getFormat());
+ assertFalse(ptr347f.destinationHasPointers());
+ assertTrue(ptr347f.destinationHasStrings());
+
+ // Find the children of 0x4312
+ assertNull(s4312.getPointedToStreams());
+ s4312.findChildren(contents);
+ // Should have two, both strings
+ assertNotNull(s4312.getPointedToStreams());
+ assertEquals(2, s4312.getPointedToStreams().length);
+ assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
+ assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
+ }
- @Test
+ @Test
void testTrailerContents() {
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
- assertNotNull(ts.getChildPointers());
- assertNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
+ assertNotNull(ts.getChildPointers());
+ assertNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
- ts.findChildren(contents);
+ ts.findChildren(contents);
- assertNotNull(ts.getChildPointers());
- assertNotNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(20, ts.getPointedToStreams().length);
+ assertNotNull(ts.getChildPointers());
+ assertNotNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(20, ts.getPointedToStreams().length);
- // Step down:
- // 8 -> 4 -> 5 -> 1 -> 0 == String
- assertNotNull(ts.getPointedToStreams()[8]);
- assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
+ // Step down:
+ // 8 -> 4 -> 5 -> 1 -> 0 == String
+ assertNotNull(ts.getPointedToStreams()[8]);
+ assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
- PointerContainingStream s8 =
- (PointerContainingStream)ts.getPointedToStreams()[8];
- assertNotNull(s8.getPointedToStreams());
+ PointerContainingStream s8 =
+ (PointerContainingStream)ts.getPointedToStreams()[8];
+ assertNotNull(s8.getPointedToStreams());
- assertNotNull(s8.getPointedToStreams()[4]);
- assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
+ assertNotNull(s8.getPointedToStreams()[4]);
+ assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
- PointerContainingStream s84 =
- (PointerContainingStream)s8.getPointedToStreams()[4];
- assertNotNull(s84.getPointedToStreams());
+ PointerContainingStream s84 =
+ (PointerContainingStream)s8.getPointedToStreams()[4];
+ assertNotNull(s84.getPointedToStreams());
- assertNotNull(s84.getPointedToStreams()[5]);
- assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
+ assertNotNull(s84.getPointedToStreams()[5]);
+ assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
- PointerContainingStream s845 =
- (PointerContainingStream)s84.getPointedToStreams()[5];
- assertNotNull(s845.getPointedToStreams());
+ PointerContainingStream s845 =
+ (PointerContainingStream)s84.getPointedToStreams()[5];
+ assertNotNull(s845.getPointedToStreams());
- assertNotNull(s845.getPointedToStreams()[1]);
- assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
+ assertNotNull(s845.getPointedToStreams()[1]);
+ assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
- PointerContainingStream s8451 =
- (PointerContainingStream)s845.getPointedToStreams()[1];
- assertNotNull(s8451.getPointedToStreams());
+ PointerContainingStream s8451 =
+ (PointerContainingStream)s845.getPointedToStreams()[1];
+ assertNotNull(s8451.getPointedToStreams());
- assertNotNull(s8451.getPointedToStreams()[0]);
- assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
- assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
- }
+ assertNotNull(s8451.getPointedToStreams()[0]);
+ assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
+ assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
+ }
- @Test
+ @Test
void testChunkWithText() {
- // Parent ChunkStream is at 0x7194
- // This is one of the last children of the trailer
- Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
- TrailerStream ts = (TrailerStream)
- Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
- ts.findChildren(contents);
-
- assertNotNull(ts.getChildPointers());
- assertNotNull(ts.getPointedToStreams());
- assertEquals(20, ts.getChildPointers().length);
- assertEquals(20, ts.getPointedToStreams().length);
-
- assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
- assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
-
- PointerContainingStream ps7194 = (PointerContainingStream)
- ts.getPointedToStreams()[13];
-
- // First child is at 0x64b3
- assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
- assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
-
- ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
-
- // Should be 26bc bytes un-compressed
- assertEquals(0x26bc, cs.getStore().getContents().length);
- // And should have lots of children
- assertEquals(131, cs.getChunks().length);
-
- // One of which is Text
- boolean hasText = false;
- for(int i=0; i<cs.getChunks().length; i++) {
- if(cs.getChunks()[i].getName().equals("Text")) {
- hasText = true;
- }
- }
- assertTrue(hasText);
- // Which is the 72nd command
- assertEquals("Text", cs.getChunks()[72].getName());
-
- Chunk text = cs.getChunks()[72];
- assertEquals("Text", text.getName());
-
- // Which contains our text
- assertEquals(1, text.getCommands().length);
- assertEquals("Test View\n", text.getCommands()[0].getValue());
-
-
- // Almost at the end is some more text
- assertEquals("Text", cs.getChunks()[128].getName());
- text = cs.getChunks()[128];
- assertEquals("Text", text.getName());
-
- assertEquals(1, text.getCommands().length);
- assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
- }
+ // Parent ChunkStream is at 0x7194
+ // This is one of the last children of the trailer
+ Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
+ TrailerStream ts = (TrailerStream)
+ Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
+
+ ts.findChildren(contents);
+
+ assertNotNull(ts.getChildPointers());
+ assertNotNull(ts.getPointedToStreams());
+ assertEquals(20, ts.getChildPointers().length);
+ assertEquals(20, ts.getPointedToStreams().length);
+
+ assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
+ assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
+
+ PointerContainingStream ps7194 = (PointerContainingStream)
+ ts.getPointedToStreams()[13];
+
+ // First child is at 0x64b3
+ assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
+ assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
+
+ ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
+
+ // Should be 26bc bytes un-compressed
+ assertEquals(0x26bc, cs.getStore().getContents().length);
+ // And should have lots of children
+ assertEquals(131, cs.getChunks().length);
+
+ // One of which is Text
+ boolean hasText = false;
+ for(int i=0; i<cs.getChunks().length; i++) {
+ if(cs.getChunks()[i].getName().equals("Text")) {
+ hasText = true;
+ }
+ }
+ assertTrue(hasText);
+ // Which is the 72nd command
+ assertEquals("Text", cs.getChunks()[72].getName());
+
+ Chunk text = cs.getChunks()[72];
+ assertEquals("Text", text.getName());
+
+ // Which contains our text
+ assertEquals(1, text.getCommands().length);
+ assertEquals("Test View\n", text.getCommands()[0].getValue());
+
+
+ // Almost at the end is some more text
+ assertEquals("Text", cs.getChunks()[128].getName());
+ text = cs.getChunks()[128];
+ assertEquals("Text", text.getName());
+
+ assertEquals(1, text.getCommands().length);
+ assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hmef/attribute/TestTNEFAttributes.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hmef/attribute/TestTNEFAttributes.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hmef/attribute/TestTNEFAttributes.java Sat May 22 21:37:08 2021
@@ -136,7 +136,7 @@ public final class TestTNEFAttributes {
assertEquals(TNEFStringAttribute.class, attr.getClass());
// It is a null terminated string
- assertEquals("quick.doc\u0000", new String(attr.getData(), StandardCharsets.US_ASCII));
+ assertEquals("quick.doc\u0000", new String(attr.getData(), StandardCharsets.US_ASCII));
// But when we ask for the string, that is sorted for us
TNEFStringAttribute str = (TNEFStringAttribute) attr;
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/TestHPBFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/TestHPBFDocument.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/TestHPBFDocument.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/TestHPBFDocument.java Sat May 22 21:37:08 2021
@@ -31,34 +31,34 @@ public final class TestHPBFDocument {
private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
@Test
- void testOpen() throws IOException {
- InputStream is = _samples.openResourceAsStream("Sample.pub");
- HPBFDocument doc = new HPBFDocument(is);
- is.close();
- assertNotNull(doc);
- doc.close();
- }
+ void testOpen() throws IOException {
+ InputStream is = _samples.openResourceAsStream("Sample.pub");
+ HPBFDocument doc = new HPBFDocument(is);
+ is.close();
+ assertNotNull(doc);
+ doc.close();
+ }
@Test
- void testBits() throws IOException {
+ void testBits() throws IOException {
InputStream is = _samples.openResourceAsStream("Sample.pub");
- HPBFDocument doc = new HPBFDocument(is);
+ HPBFDocument doc = new HPBFDocument(is);
is.close();
- assertNotNull(doc.getMainContents());
- assertNotNull(doc.getQuillContents());
- assertNotNull(doc.getEscherStm());
- assertNotNull(doc.getEscherDelayStm());
-
- assertTrue(doc.getMainContents().getData().length > 0);
- assertTrue(doc.getQuillContents().getData().length > 0);
- assertTrue(doc.getEscherStm().getData().length > 0);
+ assertNotNull(doc.getMainContents());
+ assertNotNull(doc.getQuillContents());
+ assertNotNull(doc.getEscherStm());
+ assertNotNull(doc.getEscherDelayStm());
+
+ assertTrue(doc.getMainContents().getData().length > 0);
+ assertTrue(doc.getQuillContents().getData().length > 0);
+ assertTrue(doc.getEscherStm().getData().length > 0);
assertEquals(0, doc.getEscherDelayStm().getData().length);
doc.close();
- }
+ }
- // TODO
-// void testWrite() throws Exception {
-// }
+ // TODO
+// void testWrite() throws Exception {
+// }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestEscherParts.java Sat May 22 21:37:08 2021
@@ -31,55 +31,55 @@ public final class TestEscherParts {
private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
@Test
- void testBasics() throws IOException {
+ void testBasics() throws IOException {
InputStream is = _samples.openResourceAsStream("Sample.pub");
- HPBFDocument doc = new HPBFDocument(is);
- is.close();
+ HPBFDocument doc = new HPBFDocument(is);
+ is.close();
- EscherStm es = doc.getEscherStm();
- EscherDelayStm eds = doc.getEscherDelayStm();
+ EscherStm es = doc.getEscherStm();
+ EscherDelayStm eds = doc.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(13, es.getEscherRecords().length);
- assertEquals(0, eds.getEscherRecords().length);
+ assertEquals(13, es.getEscherRecords().length);
+ assertEquals(0, eds.getEscherRecords().length);
- // TODO - check the contents
- doc.close();
- }
+ // TODO - check the contents
+ doc.close();
+ }
@Test
void testComplex() throws Exception {
InputStream is = _samples.openResourceAsStream("SampleBrochure.pub");
- HPBFDocument doc1 = new HPBFDocument(is);
- is.close();
+ HPBFDocument doc1 = new HPBFDocument(is);
+ is.close();
- EscherStm es = doc1.getEscherStm();
- EscherDelayStm eds = doc1.getEscherDelayStm();
+ EscherStm es = doc1.getEscherStm();
+ EscherDelayStm eds = doc1.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(30, es.getEscherRecords().length);
- assertEquals(19, eds.getEscherRecords().length);
+ assertEquals(30, es.getEscherRecords().length);
+ assertEquals(19, eds.getEscherRecords().length);
- // TODO - check contents
- doc1.close();
+ // TODO - check contents
+ doc1.close();
- // Now do another complex file
- InputStream is2 = _samples.openResourceAsStream("SampleNewsletter.pub");
+ // Now do another complex file
+ InputStream is2 = _samples.openResourceAsStream("SampleNewsletter.pub");
HPBFDocument doc2 = new HPBFDocument(is2);
- is2.close();
+ is2.close();
- es = doc2.getEscherStm();
- eds = doc2.getEscherDelayStm();
+ es = doc2.getEscherStm();
+ eds = doc2.getEscherDelayStm();
- assertNotNull(es);
- assertNotNull(eds);
+ assertNotNull(es);
+ assertNotNull(eds);
- assertEquals(51, es.getEscherRecords().length);
- assertEquals(92, eds.getEscherRecords().length);
- doc2.close();
- }
+ assertEquals(51, es.getEscherRecords().length);
+ assertEquals(92, eds.getEscherRecords().length);
+ doc2.close();
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hpbf/model/TestQuillContents.java Sat May 22 21:37:08 2021
@@ -40,409 +40,409 @@ public final class TestQuillContents {
@Test
void testBasics() throws IOException {
- HPBFDocument doc = new HPBFDocument(
- _samples.openResourceAsStream("Sample.pub")
- );
-
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
- for(int i=0; i<19; i++) {
- assertNotNull(qc.getBits()[i]);
- }
- // Last one is blank
- assertNull(qc.getBits()[19]);
-
- // Should be text, then three STSHs
- assertEquals("TEXT", qc.getBits()[0].getThingType());
- assertEquals("TEXT", qc.getBits()[0].getBitType());
- assertEquals(0, qc.getBits()[0].getOptA());
-
- assertEquals("STSH", qc.getBits()[1].getThingType());
- assertEquals("STSH", qc.getBits()[1].getBitType());
- assertEquals(0, qc.getBits()[1].getOptA());
-
- assertEquals("STSH", qc.getBits()[2].getThingType());
- assertEquals("STSH", qc.getBits()[2].getBitType());
- assertEquals(1, qc.getBits()[2].getOptA());
-
- assertEquals("STSH", qc.getBits()[3].getThingType());
- assertEquals("STSH", qc.getBits()[3].getBitType());
- assertEquals(2, qc.getBits()[3].getOptA());
+ HPBFDocument doc = new HPBFDocument(
+ _samples.openResourceAsStream("Sample.pub")
+ );
+
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
+ for(int i=0; i<19; i++) {
+ assertNotNull(qc.getBits()[i]);
+ }
+ // Last one is blank
+ assertNull(qc.getBits()[19]);
+
+ // Should be text, then three STSHs
+ assertEquals("TEXT", qc.getBits()[0].getThingType());
+ assertEquals("TEXT", qc.getBits()[0].getBitType());
+ assertEquals(0, qc.getBits()[0].getOptA());
+
+ assertEquals("STSH", qc.getBits()[1].getThingType());
+ assertEquals("STSH", qc.getBits()[1].getBitType());
+ assertEquals(0, qc.getBits()[1].getOptA());
+
+ assertEquals("STSH", qc.getBits()[2].getThingType());
+ assertEquals("STSH", qc.getBits()[2].getBitType());
+ assertEquals(1, qc.getBits()[2].getOptA());
+
+ assertEquals("STSH", qc.getBits()[3].getThingType());
+ assertEquals("STSH", qc.getBits()[3].getBitType());
+ assertEquals(2, qc.getBits()[3].getOptA());
- doc.close();
- }
+ doc.close();
+ }
@Test
- void testText() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testText() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- QCTextBit text = (QCTextBit)qc.getBits()[0];
- String t = text.getText();
- assertStartsWith(t, "This is some text on the first page");
- assertEndsWith(t, "Within doc to page 1\r");
+ QCTextBit text = (QCTextBit)qc.getBits()[0];
+ String t = text.getText();
+ assertStartsWith(t, "This is some text on the first page");
+ assertEndsWith(t, "Within doc to page 1\r");
doc.close();
- }
+ }
@Test
- void testPLC() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testPLC() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Simple.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- assertTrue(qc.getBits()[9] instanceof Type4);
- assertTrue(qc.getBits()[10] instanceof Type4);
- assertTrue(qc.getBits()[12] instanceof Type8);
-
- Type4 plc9 = (Type4)qc.getBits()[9];
- Type4 plc10 = (Type4)qc.getBits()[10];
- Type8 plc12 = (Type8)qc.getBits()[12];
-
-
- assertEquals(1, plc9.getNumberOfPLCs());
- assertEquals(4, plc9.getPreData().length);
- assertEquals(1, plc9.getPlcValA().length);
- assertEquals(1, plc9.getPlcValB().length);
-
- assertEquals(0, plc9.getPreData()[0]);
- assertEquals(0, plc9.getPreData()[1]);
- assertEquals(0, plc9.getPreData()[2]);
- assertEquals(0, plc9.getPreData()[3]);
- assertEquals(0x356, plc9.getPlcValA()[0]);
- assertEquals(0x600, plc9.getPlcValB()[0]);
-
-
- assertEquals(1, plc10.getNumberOfPLCs());
- assertEquals(4, plc10.getPreData().length);
- assertEquals(1, plc10.getPlcValA().length);
- assertEquals(1, plc10.getPlcValB().length);
-
- assertEquals(0, plc10.getPreData()[0]);
- assertEquals(0, plc10.getPreData()[1]);
- assertEquals(0, plc10.getPreData()[2]);
- assertEquals(0, plc10.getPreData()[3]);
- assertEquals(0x356, plc10.getPlcValA()[0]);
- assertEquals(0x800, plc10.getPlcValB()[0]);
-
- assertEquals(2, plc12.getNumberOfPLCs());
- assertEquals(7, plc12.getPreData().length);
- assertEquals(2, plc12.getPlcValA().length);
- assertEquals(2, plc12.getPlcValB().length);
-
- assertEquals(0xff, plc12.getPreData()[0]);
- assertEquals(0, plc12.getPreData()[1]);
- assertEquals(0x3d, plc12.getPreData()[2]);
- assertEquals(0, plc12.getPreData()[3]);
- assertEquals(0x6e, plc12.getPreData()[4]);
- assertEquals(0, plc12.getPreData()[5]);
- assertEquals(0, plc12.getPreData()[6]);
- assertEquals(0xa0000, plc12.getPlcValA()[0]);
- assertEquals(0x22000000, plc12.getPlcValB()[0]);
- assertEquals(0x05, plc12.getPlcValA()[1]);
- assertEquals(0x04, plc12.getPlcValB()[1]);
+ assertTrue(qc.getBits()[9] instanceof Type4);
+ assertTrue(qc.getBits()[10] instanceof Type4);
+ assertTrue(qc.getBits()[12] instanceof Type8);
+
+ Type4 plc9 = (Type4)qc.getBits()[9];
+ Type4 plc10 = (Type4)qc.getBits()[10];
+ Type8 plc12 = (Type8)qc.getBits()[12];
+
+
+ assertEquals(1, plc9.getNumberOfPLCs());
+ assertEquals(4, plc9.getPreData().length);
+ assertEquals(1, plc9.getPlcValA().length);
+ assertEquals(1, plc9.getPlcValB().length);
+
+ assertEquals(0, plc9.getPreData()[0]);
+ assertEquals(0, plc9.getPreData()[1]);
+ assertEquals(0, plc9.getPreData()[2]);
+ assertEquals(0, plc9.getPreData()[3]);
+ assertEquals(0x356, plc9.getPlcValA()[0]);
+ assertEquals(0x600, plc9.getPlcValB()[0]);
+
+
+ assertEquals(1, plc10.getNumberOfPLCs());
+ assertEquals(4, plc10.getPreData().length);
+ assertEquals(1, plc10.getPlcValA().length);
+ assertEquals(1, plc10.getPlcValB().length);
+
+ assertEquals(0, plc10.getPreData()[0]);
+ assertEquals(0, plc10.getPreData()[1]);
+ assertEquals(0, plc10.getPreData()[2]);
+ assertEquals(0, plc10.getPreData()[3]);
+ assertEquals(0x356, plc10.getPlcValA()[0]);
+ assertEquals(0x800, plc10.getPlcValB()[0]);
+
+ assertEquals(2, plc12.getNumberOfPLCs());
+ assertEquals(7, plc12.getPreData().length);
+ assertEquals(2, plc12.getPlcValA().length);
+ assertEquals(2, plc12.getPlcValB().length);
+
+ assertEquals(0xff, plc12.getPreData()[0]);
+ assertEquals(0, plc12.getPreData()[1]);
+ assertEquals(0x3d, plc12.getPreData()[2]);
+ assertEquals(0, plc12.getPreData()[3]);
+ assertEquals(0x6e, plc12.getPreData()[4]);
+ assertEquals(0, plc12.getPreData()[5]);
+ assertEquals(0, plc12.getPreData()[6]);
+ assertEquals(0xa0000, plc12.getPlcValA()[0]);
+ assertEquals(0x22000000, plc12.getPlcValB()[0]);
+ assertEquals(0x05, plc12.getPlcValA()[1]);
+ assertEquals(0x04, plc12.getPlcValB()[1]);
- doc.close();
- }
+ doc.close();
+ }
@SuppressWarnings("unused")
@Test
- void testComplexPLC() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testComplexPLC() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- assertTrue(qc.getBits()[10] instanceof Type4);
- assertTrue(qc.getBits()[11] instanceof Type4);
- assertTrue(qc.getBits()[13] instanceof Type0);
- assertTrue(qc.getBits()[14] instanceof Type12);
- assertTrue(qc.getBits()[15] instanceof Type12);
- assertTrue(qc.getBits()[16] instanceof Type8);
-
- Type4 plc10 = (Type4)qc.getBits()[10];
- Type4 plc11 = (Type4)qc.getBits()[11];
- Type0 plc13 = (Type0)qc.getBits()[13];
- Type12 plc14 = (Type12)qc.getBits()[14];
- Type12 plc15 = (Type12)qc.getBits()[15];
- Type8 plc16 = (Type8)qc.getBits()[16];
-
-
- assertEquals(1, plc10.getNumberOfPLCs());
- assertEquals(4, plc10.getPreData().length);
- assertEquals(1, plc10.getPlcValA().length);
- assertEquals(1, plc10.getPlcValB().length);
-
- assertEquals(0, plc10.getPreData()[0]);
- assertEquals(0, plc10.getPreData()[1]);
- assertEquals(0, plc10.getPreData()[2]);
- assertEquals(0, plc10.getPreData()[3]);
- assertEquals(0x5d0, plc10.getPlcValA()[0]);
- assertEquals(0x800, plc10.getPlcValB()[0]);
-
-
- assertEquals(2, plc11.getNumberOfPLCs());
- assertEquals(4, plc11.getPreData().length);
- assertEquals(2, plc11.getPlcValA().length);
- assertEquals(2, plc11.getPlcValB().length);
-
- assertEquals(0, plc11.getPreData()[0]);
- assertEquals(0, plc11.getPreData()[1]);
- assertEquals(0, plc11.getPreData()[2]);
- assertEquals(0, plc11.getPreData()[3]);
- assertEquals(0x53a, plc11.getPlcValA()[0]);
- assertEquals(0x5d0, plc11.getPlcValB()[0]);
- assertEquals(0xa00, plc11.getPlcValA()[1]);
- assertEquals(0xc00, plc11.getPlcValB()[1]);
-
-
- assertEquals(5, plc13.getNumberOfPLCs());
- assertEquals(4, plc13.getPreData().length);
- assertEquals(5, plc13.getPlcValA().length);
- assertEquals(5, plc13.getPlcValB().length);
-
- assertEquals(0xff00, plc13.getPreData()[0]);
- assertEquals(0, plc13.getPreData()[1]);
- assertEquals(0xf, plc13.getPreData()[2]);
- assertEquals(0, plc13.getPreData()[3]);
- assertEquals(0x19, plc13.getPlcValA()[0]);
- assertEquals(0x00, plc13.getPlcValB()[0]);
- assertEquals(0x27, plc13.getPlcValA()[1]);
- assertEquals(0x00, plc13.getPlcValB()[1]);
- assertEquals(0x36, plc13.getPlcValA()[2]);
- assertEquals(0x00, plc13.getPlcValB()[2]);
- assertEquals(0x42, plc13.getPlcValA()[3]);
- assertEquals(0x00, plc13.getPlcValB()[3]);
- assertEquals(0x50, plc13.getPlcValA()[4]);
- assertEquals(0x00, plc13.getPlcValB()[4]);
-
-
- // TODO - test the type 12s
-
-
- assertEquals(6, plc16.getNumberOfPLCs());
- assertEquals(7, plc16.getPreData().length);
- assertEquals(6, plc16.getPlcValA().length);
- assertEquals(6, plc16.getPlcValB().length);
-
- assertEquals(0xff, plc16.getPreData()[0]);
- assertEquals(0, plc16.getPreData()[1]);
- assertEquals(0x56, plc16.getPreData()[2]);
- assertEquals(0, plc16.getPreData()[3]);
- assertEquals(0x62, plc16.getPreData()[4]);
- assertEquals(0, plc16.getPreData()[5]);
- assertEquals(0x3e, plc16.getPreData()[6]);
- assertEquals(0x500000, plc16.getPlcValA()[0]);
- assertEquals(0x570000, plc16.getPlcValB()[0]);
- assertEquals(0x4b0000, plc16.getPlcValA()[1]);
- assertEquals(0x000000, plc16.getPlcValB()[1]);
- assertEquals(0x0a0000, plc16.getPlcValA()[2]);
- assertEquals(0x22000000, plc16.getPlcValB()[2]);
- assertEquals(0x000005, plc16.getPlcValA()[3]);
- assertEquals(0x000004, plc16.getPlcValB()[3]);
- assertEquals(0x000004, plc16.getPlcValA()[4]);
- assertEquals(0x000004, plc16.getPlcValB()[4]);
- assertEquals(0x000004, plc16.getPlcValA()[5]);
- assertEquals(0x000004, plc16.getPlcValB()[5]);
+ assertTrue(qc.getBits()[10] instanceof Type4);
+ assertTrue(qc.getBits()[11] instanceof Type4);
+ assertTrue(qc.getBits()[13] instanceof Type0);
+ assertTrue(qc.getBits()[14] instanceof Type12);
+ assertTrue(qc.getBits()[15] instanceof Type12);
+ assertTrue(qc.getBits()[16] instanceof Type8);
+
+ Type4 plc10 = (Type4)qc.getBits()[10];
+ Type4 plc11 = (Type4)qc.getBits()[11];
+ Type0 plc13 = (Type0)qc.getBits()[13];
+ Type12 plc14 = (Type12)qc.getBits()[14];
+ Type12 plc15 = (Type12)qc.getBits()[15];
+ Type8 plc16 = (Type8)qc.getBits()[16];
+
+
+ assertEquals(1, plc10.getNumberOfPLCs());
+ assertEquals(4, plc10.getPreData().length);
+ assertEquals(1, plc10.getPlcValA().length);
+ assertEquals(1, plc10.getPlcValB().length);
+
+ assertEquals(0, plc10.getPreData()[0]);
+ assertEquals(0, plc10.getPreData()[1]);
+ assertEquals(0, plc10.getPreData()[2]);
+ assertEquals(0, plc10.getPreData()[3]);
+ assertEquals(0x5d0, plc10.getPlcValA()[0]);
+ assertEquals(0x800, plc10.getPlcValB()[0]);
+
+
+ assertEquals(2, plc11.getNumberOfPLCs());
+ assertEquals(4, plc11.getPreData().length);
+ assertEquals(2, plc11.getPlcValA().length);
+ assertEquals(2, plc11.getPlcValB().length);
+
+ assertEquals(0, plc11.getPreData()[0]);
+ assertEquals(0, plc11.getPreData()[1]);
+ assertEquals(0, plc11.getPreData()[2]);
+ assertEquals(0, plc11.getPreData()[3]);
+ assertEquals(0x53a, plc11.getPlcValA()[0]);
+ assertEquals(0x5d0, plc11.getPlcValB()[0]);
+ assertEquals(0xa00, plc11.getPlcValA()[1]);
+ assertEquals(0xc00, plc11.getPlcValB()[1]);
+
+
+ assertEquals(5, plc13.getNumberOfPLCs());
+ assertEquals(4, plc13.getPreData().length);
+ assertEquals(5, plc13.getPlcValA().length);
+ assertEquals(5, plc13.getPlcValB().length);
+
+ assertEquals(0xff00, plc13.getPreData()[0]);
+ assertEquals(0, plc13.getPreData()[1]);
+ assertEquals(0xf, plc13.getPreData()[2]);
+ assertEquals(0, plc13.getPreData()[3]);
+ assertEquals(0x19, plc13.getPlcValA()[0]);
+ assertEquals(0x00, plc13.getPlcValB()[0]);
+ assertEquals(0x27, plc13.getPlcValA()[1]);
+ assertEquals(0x00, plc13.getPlcValB()[1]);
+ assertEquals(0x36, plc13.getPlcValA()[2]);
+ assertEquals(0x00, plc13.getPlcValB()[2]);
+ assertEquals(0x42, plc13.getPlcValA()[3]);
+ assertEquals(0x00, plc13.getPlcValB()[3]);
+ assertEquals(0x50, plc13.getPlcValA()[4]);
+ assertEquals(0x00, plc13.getPlcValB()[4]);
+
+
+ // TODO - test the type 12s
+
+
+ assertEquals(6, plc16.getNumberOfPLCs());
+ assertEquals(7, plc16.getPreData().length);
+ assertEquals(6, plc16.getPlcValA().length);
+ assertEquals(6, plc16.getPlcValB().length);
+
+ assertEquals(0xff, plc16.getPreData()[0]);
+ assertEquals(0, plc16.getPreData()[1]);
+ assertEquals(0x56, plc16.getPreData()[2]);
+ assertEquals(0, plc16.getPreData()[3]);
+ assertEquals(0x62, plc16.getPreData()[4]);
+ assertEquals(0, plc16.getPreData()[5]);
+ assertEquals(0x3e, plc16.getPreData()[6]);
+ assertEquals(0x500000, plc16.getPlcValA()[0]);
+ assertEquals(0x570000, plc16.getPlcValB()[0]);
+ assertEquals(0x4b0000, plc16.getPlcValA()[1]);
+ assertEquals(0x000000, plc16.getPlcValB()[1]);
+ assertEquals(0x0a0000, plc16.getPlcValA()[2]);
+ assertEquals(0x22000000, plc16.getPlcValB()[2]);
+ assertEquals(0x000005, plc16.getPlcValA()[3]);
+ assertEquals(0x000004, plc16.getPlcValB()[3]);
+ assertEquals(0x000004, plc16.getPlcValA()[4]);
+ assertEquals(0x000004, plc16.getPlcValB()[4]);
+ assertEquals(0x000004, plc16.getPlcValA()[5]);
+ assertEquals(0x000004, plc16.getPlcValB()[5]);
doc.close();
- }
+ }
@Test
- void testNoHyperlinks() throws IOException {
- HPBFDocument doc = new HPBFDocument(
+ void testNoHyperlinks() throws IOException {
+ HPBFDocument doc = new HPBFDocument(
_samples.openResourceAsStream("SampleNewsletter.pub")
- );
+ );
- QuillContents qc = doc.getQuillContents();
- assertEquals(20, qc.getBits().length);
+ QuillContents qc = doc.getQuillContents();
+ assertEquals(20, qc.getBits().length);
- Type12 plc18 = (Type12)qc.getBits()[18];
+ Type12 plc18 = (Type12)qc.getBits()[18];
- assertEquals(1, plc18.getNumberOfPLCs());
- assertEquals(0, plc18.getNumberOfHyperlinks());
- assertEquals(0, plc18.getTextStartAt(0));
- assertEquals(601, plc18.getAllTextEndAt());
+ assertEquals(1, plc18.getNumberOfPLCs());
+ assertEquals(0, plc18.getNumberOfHyperlinks());
+ assertEquals(0, plc18.getTextStartAt(0));
+ assertEquals(601, plc18.getAllTextEndAt());
doc.close();
- }
+ }
@Test
- void testSimpleHyperlink() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBit;
+ void testSimpleHyperlink() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBit;
- // Link at 10
- doc = new HPBFDocument(
+ // Link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
-
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
+
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
doc.close();
- // Longer link at 10
- doc = new HPBFDocument(
+ // Longer link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10Longer.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
-
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
+
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));
doc.close();
- // Link at 20
- doc = new HPBFDocument(
+ // Link at 20
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt20.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
-
- assertEquals(20, hlBit.getTextStartAt(0));
- assertEquals(25, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
- doc.close();
- }
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
+
+ assertEquals(20, hlBit.getTextStartAt(0));
+ assertEquals(25, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ doc.close();
+ }
@Test
- void testManyHyperlinks() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBit;
+ void testManyHyperlinks() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBit;
- // Link at 10
- doc = new HPBFDocument(
+ // Link at 10
+ doc = new HPBFDocument(
_samples.openResourceAsStream("LinkAt10.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBit = (Type12)qc.getBits()[12];
- assertEquals(1, hlBit.getNumberOfPLCs());
- assertEquals(1, hlBit.getNumberOfHyperlinks());
-
- assertEquals(10, hlBit.getTextStartAt(0));
- assertEquals(15, hlBit.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
+ hlBit = (Type12)qc.getBits()[12];
+ assertEquals(1, hlBit.getNumberOfPLCs());
+ assertEquals(1, hlBit.getNumberOfHyperlinks());
+
+ assertEquals(10, hlBit.getTextStartAt(0));
+ assertEquals(15, hlBit.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
doc.close();
- }
+ }
@Test
- void testHyperlinkDifferentVersions() throws IOException {
- HPBFDocument doc;
- QuillContents qc;
- Type12 hlBitA;
- Type12 hlBitB;
+ void testHyperlinkDifferentVersions() throws IOException {
+ HPBFDocument doc;
+ QuillContents qc;
+ Type12 hlBitA;
+ Type12 hlBitB;
- // Latest version
- doc = new HPBFDocument(
+ // Latest version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[14];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
-
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-
- hlBitB = (Type12)qc.getBits()[15];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
-
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ hlBitA = (Type12)qc.getBits()[14];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
+
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+
+ hlBitB = (Type12)qc.getBits()[15];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
+
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
- // 2000 version
- doc = new HPBFDocument(
+ // 2000 version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample2000.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[13];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
-
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-
- hlBitB = (Type12)qc.getBits()[14];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
-
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ hlBitA = (Type12)qc.getBits()[13];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
+
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+
+ hlBitB = (Type12)qc.getBits()[14];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
+
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
- // 98 version
- doc = new HPBFDocument(
+ // 98 version
+ doc = new HPBFDocument(
_samples.openResourceAsStream("Sample98.pub")
- );
- qc = doc.getQuillContents();
+ );
+ qc = doc.getQuillContents();
- hlBitA = (Type12)qc.getBits()[13];
- assertEquals(2, hlBitA.getNumberOfPLCs());
- assertEquals(2, hlBitA.getNumberOfHyperlinks());
-
- assertEquals(25, hlBitA.getTextStartAt(0));
- assertEquals(72, hlBitA.getTextStartAt(1));
- assertEquals(87, hlBitA.getAllTextEndAt());
- assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
- assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-
- hlBitB = (Type12)qc.getBits()[14];
- assertEquals(3, hlBitB.getNumberOfPLCs());
- assertEquals(3, hlBitB.getNumberOfHyperlinks());
-
- assertEquals(27, hlBitB.getTextStartAt(0));
- assertEquals(37, hlBitB.getTextStartAt(1));
- assertEquals(54, hlBitB.getTextStartAt(2));
- assertEquals(75, hlBitB.getAllTextEndAt());
- assertEquals("", hlBitB.getHyperlink(0));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
- assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
+ hlBitA = (Type12)qc.getBits()[13];
+ assertEquals(2, hlBitA.getNumberOfPLCs());
+ assertEquals(2, hlBitA.getNumberOfHyperlinks());
+
+ assertEquals(25, hlBitA.getTextStartAt(0));
+ assertEquals(72, hlBitA.getTextStartAt(1));
+ assertEquals(87, hlBitA.getAllTextEndAt());
+ assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
+ assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
+
+ hlBitB = (Type12)qc.getBits()[14];
+ assertEquals(3, hlBitB.getNumberOfPLCs());
+ assertEquals(3, hlBitB.getNumberOfHyperlinks());
+
+ assertEquals(27, hlBitB.getTextStartAt(0));
+ assertEquals(37, hlBitB.getTextStartAt(1));
+ assertEquals(54, hlBitB.getTextStartAt(2));
+ assertEquals(75, hlBitB.getAllTextEndAt());
+ assertEquals("", hlBitB.getHyperlink(0));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
+ assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
doc.close();
}
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/HSLFTestDataSamples.java Sat May 22 21:37:08 2021
@@ -28,53 +28,53 @@ import org.apache.poi.hslf.usermodel.HSL
public class HSLFTestDataSamples {
- private static final POIDataSamples _inst = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples _inst = POIDataSamples.getSlideShowInstance();
- public static InputStream openSampleFileStream(String sampleFileName) {
- return _inst.openResourceAsStream(sampleFileName);
- }
+ public static InputStream openSampleFileStream(String sampleFileName) {
+ return _inst.openResourceAsStream(sampleFileName);
+ }
- public static File getSampleFile(String sampleFileName) {
- return _inst.getFile(sampleFileName);
- }
+ public static File getSampleFile(String sampleFileName) {
+ return _inst.getFile(sampleFileName);
+ }
- public static byte[] getTestDataFileContent(String fileName) {
- return _inst.readFile(fileName);
- }
+ public static byte[] getTestDataFileContent(String fileName) {
+ return _inst.readFile(fileName);
+ }
- public static HSLFSlideShow getSlideShow(String fileName) throws IOException {
+ public static HSLFSlideShow getSlideShow(String fileName) throws IOException {
try (InputStream is = openSampleFileStream(fileName)) {
return new HSLFSlideShow(is);
}
- }
+ }
- /**
- * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
- * from a {@code ByteArrayInputStream}.<p>
- * Useful for verifying that the serialisation round trip
- */
- public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
- original.write(baos);
- try (InputStream is = baos.toInputStream()) {
- return new HSLFSlideShowImpl(is);
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
- * from a {@code ByteArrayInputStream}.<p>
- * Useful for verifying that the serialisation round trip
- */
- public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
- try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
- original.write(baos);
- return new HSLFSlideShow(baos.toInputStream());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ /**
+ * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
+ * from a {@code ByteArrayInputStream}.<p>
+ * Useful for verifying that the serialisation round trip
+ */
+ public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
+ try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
+ original.write(baos);
+ try (InputStream is = baos.toInputStream()) {
+ return new HSLFSlideShowImpl(is);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Writes a slideshow to a {@code UnsynchronizedByteArrayOutputStream} and reads it back
+ * from a {@code ByteArrayInputStream}.<p>
+ * Useful for verifying that the serialisation round trip
+ */
+ public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
+ try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(4096)) {
+ original.write(baos);
+ return new HSLFSlideShow(baos.toInputStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestEncryptedFile.java Sat May 22 21:37:08 2021
@@ -36,16 +36,16 @@ public final class TestEncryptedFile {
private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
@Test
- void testLoadNonEncrypted() throws IOException {
+ void testLoadNonEncrypted() throws IOException {
InputStream is = slTests.openResourceAsStream("basic_test_ppt_file.ppt");
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(is);
- assertNotNull(hss);
- hss.close();
- is.close();
- }
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(is);
+ assertNotNull(hss);
+ hss.close();
+ is.close();
+ }
@Test
- void testLoadEncrypted1() throws IOException {
+ void testLoadEncrypted1() throws IOException {
try (InputStream is = slTests.openResourceAsStream("Password_Protected-hello.ppt")) {
assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(is).close());
}
@@ -63,5 +63,5 @@ public final class TestEncryptedFile {
try (InputStream is = slTests.openResourceAsStream("Password_Protected-56-hello.ppt")) {
assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(is).close());
}
- }
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestPOIDocumentScratchpad.java Sat May 22 21:37:08 2021
@@ -43,64 +43,64 @@ import org.junit.jupiter.api.Test;
* which are part of the scratchpad (not main)
*/
public final class TestPOIDocumentScratchpad {
- @Test
- void testReadProperties() throws IOException {
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt")) {
- testReadPropertiesHelper(doc);
- }
- }
-
- private void testReadPropertiesHelper(POIDocument docPH) {
- // We should have both sets
- assertNotNull(docPH.getDocumentSummaryInformation());
- assertNotNull(docPH.getSummaryInformation());
-
- // Check they are as expected for the test doc
- assertEquals("Hogwarts", docPH.getSummaryInformation().getAuthor());
- assertEquals(10598, docPH.getDocumentSummaryInformation().getByteCount());
- }
-
- @Test
- void testReadProperties2() throws IOException {
- try (POIDocument doc2 = HWPFTestDataSamples.openSampleFile("test2.doc")) {
- // Check again on the word one
- assertNotNull(doc2.getDocumentSummaryInformation());
- assertNotNull(doc2.getSummaryInformation());
-
- assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
- assertEquals("", doc2.getSummaryInformation().getKeywords());
- assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
- }
- }
-
- @Test
- void testWriteProperties() throws IOException {
- // Just check we can write them back out into a filesystem
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- POIFSFileSystem outFS = new POIFSFileSystem()) {
- doc.writeProperties(outFS);
-
- // Should now hold them
- assertNotNull(outFS.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
- assertNotNull(outFS.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME));
- }
- }
+ @Test
+ void testReadProperties() throws IOException {
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt")) {
+ testReadPropertiesHelper(doc);
+ }
+ }
+
+ private void testReadPropertiesHelper(POIDocument docPH) {
+ // We should have both sets
+ assertNotNull(docPH.getDocumentSummaryInformation());
+ assertNotNull(docPH.getSummaryInformation());
+
+ // Check they are as expected for the test doc
+ assertEquals("Hogwarts", docPH.getSummaryInformation().getAuthor());
+ assertEquals(10598, docPH.getDocumentSummaryInformation().getByteCount());
+ }
+
+ @Test
+ void testReadProperties2() throws IOException {
+ try (POIDocument doc2 = HWPFTestDataSamples.openSampleFile("test2.doc")) {
+ // Check again on the word one
+ assertNotNull(doc2.getDocumentSummaryInformation());
+ assertNotNull(doc2.getSummaryInformation());
+
+ assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
+ assertEquals("", doc2.getSummaryInformation().getKeywords());
+ assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
+ }
+ }
+
+ @Test
+ void testWriteProperties() throws IOException {
+ // Just check we can write them back out into a filesystem
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ POIFSFileSystem outFS = new POIFSFileSystem()) {
+ doc.writeProperties(outFS);
+
+ // Should now hold them
+ assertNotNull(outFS.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
+ assertNotNull(outFS.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME));
+ }
+ }
- @Test
+ @Test
void testWriteReadProperties() throws IOException {
- // Write them out
- try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
- POIFSFileSystem outFS = new POIFSFileSystem()) {
- doc.writeProperties(outFS);
-
- // Check they're still there
- try (POIFSFileSystem inFS = writeOutAndReadBack(outFS);
- POIDocument ppt = new HPSFPropertiesOnlyDocument(inFS)) {
- ppt.readProperties();
-
- // Delegate test
- testReadPropertiesHelper(ppt);
- }
- }
+ // Write them out
+ try (POIDocument doc = HSLFTestDataSamples.getSlideShow("basic_test_ppt_file.ppt");
+ POIFSFileSystem outFS = new POIFSFileSystem()) {
+ doc.writeProperties(outFS);
+
+ // Check they're still there
+ try (POIFSFileSystem inFS = writeOutAndReadBack(outFS);
+ POIDocument ppt = new HPSFPropertiesOnlyDocument(inFS)) {
+ ppt.readProperties();
+
+ // Delegate test
+ testReadPropertiesHelper(ppt);
+ }
+ }
}
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestRecordCounts.java Sat May 22 21:37:08 2021
@@ -35,58 +35,58 @@ import org.junit.jupiter.api.Test;
*/
public final class TestRecordCounts {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // HSLFSlideShow primed on the test data
- private HSLFSlideShowImpl ss;
-
- @BeforeEach
- void setup() throws Exception {
- ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- }
-
- @Test
- void testSheetsCount() {
- // Top level
- Record[] r = ss.getRecords();
-
- int count = 0;
- for (final Record rec : r) {
- if(rec instanceof Slide) {
- count++;
- }
- }
- // Currently still sees the Master Sheet, but might not in the future
- assertEquals(3,count);
- }
-
- @Test
- void testNotesCount() {
- // Top level
- Record[] r = ss.getRecords();
-
- int count = 0;
- for (final Record rec : r) {
- if (rec instanceof Notes && rec.getRecordType() == 1008L) {
- count++;
- }
- }
- // Two real sheets, plus the master sheet
- assertEquals(3,count);
- }
-
- @Test
- void testSlideListWithTextCount() {
- // Second level
- Record[] rt = ss.getRecords();
- Record[] r = rt[0].getChildRecords();
-
- int count = 0;
- for (final Record rec : r) {
- if (rec instanceof SlideListWithText && rec.getRecordType() == 4080L) {
- count++;
- }
- }
- // Two real sheets, plus the master sheet
- assertEquals(3,count);
- }
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ // HSLFSlideShow primed on the test data
+ private HSLFSlideShowImpl ss;
+
+ @BeforeEach
+ void setup() throws Exception {
+ ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ }
+
+ @Test
+ void testSheetsCount() {
+ // Top level
+ Record[] r = ss.getRecords();
+
+ int count = 0;
+ for (final Record rec : r) {
+ if(rec instanceof Slide) {
+ count++;
+ }
+ }
+ // Currently still sees the Master Sheet, but might not in the future
+ assertEquals(3,count);
+ }
+
+ @Test
+ void testNotesCount() {
+ // Top level
+ Record[] r = ss.getRecords();
+
+ int count = 0;
+ for (final Record rec : r) {
+ if (rec instanceof Notes && rec.getRecordType() == 1008L) {
+ count++;
+ }
+ }
+ // Two real sheets, plus the master sheet
+ assertEquals(3,count);
+ }
+
+ @Test
+ void testSlideListWithTextCount() {
+ // Second level
+ Record[] rt = ss.getRecords();
+ Record[] r = rt[0].getChildRecords();
+
+ int count = 0;
+ for (final Record rec : r) {
+ if (rec instanceof SlideListWithText && rec.getRecordType() == 4080L) {
+ count++;
+ }
+ }
+ // Two real sheets, plus the master sheet
+ assertEquals(3,count);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java Sat May 22 21:37:08 2021
@@ -42,7 +42,7 @@ import org.junit.jupiter.params.Paramete
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
+@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
public abstract class BaseTestPPTIterating {
protected static final Set<String> OLD_FILES = new HashSet<>();
static {
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestSlideShowDumper.java Sat May 22 21:37:08 2021
@@ -31,7 +31,7 @@ import org.apache.poi.util.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;
-@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
+@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
public class TestSlideShowDumper extends BaseTestPPTIterating {
private static final Set<String> FAILING = new HashSet<>();
static {
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestCruddyExtractor.java Sat May 22 21:37:08 2021
@@ -31,64 +31,64 @@ import org.junit.jupiter.api.Test;
* Tests that the QuickButCruddyTextExtractor works correctly
*/
public final class TestCruddyExtractor {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // Extractor primed on the test data
- private QuickButCruddyTextExtractor te;
+ // Extractor primed on the test data
+ private QuickButCruddyTextExtractor te;
- // All the text to be found in the file
- String[] allTheText = new String[] {
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "Click to edit Master title style",
- "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
- "*",
- "*",
- "*",
- "*",
- "*",
- "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
- "*",
- "*",
- "These are the notes for page 1",
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "This is the title on page 2",
- "This is page two\nIt has several blocks of text\nNone of them have formattingT",
- "These are the notes on page two, again lacking formatting",
- "This is a test title",
- "This is a test subtitle\nThis is on page 1",
- "This is the title on page 2",
- "This is page two\nIt has several blocks of text\nNone of them have formatting",
- };
+ // All the text to be found in the file
+ String[] allTheText = new String[] {
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "Click to edit Master title style",
+ "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
+ "*",
+ "*",
+ "*",
+ "*",
+ "*",
+ "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level",
+ "*",
+ "*",
+ "These are the notes for page 1",
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "This is the title on page 2",
+ "This is page two\nIt has several blocks of text\nNone of them have formattingT",
+ "These are the notes on page two, again lacking formatting",
+ "This is a test title",
+ "This is a test subtitle\nThis is on page 1",
+ "This is the title on page 2",
+ "This is page two\nIt has several blocks of text\nNone of them have formatting",
+ };
- @BeforeEach
+ @BeforeEach
void setup() throws Exception {
- te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
}
- @Test
+ @Test
void testReadAsVector() {
- // Extract the text from the file as a vector
- List<String> foundTextV = te.getTextAsVector();
+ // Extract the text from the file as a vector
+ List<String> foundTextV = te.getTextAsVector();
- // Ensure they match
- assertEquals(allTheText.length,foundTextV.size());
- for(int i=0; i<allTheText.length; i++) {
- String foundText = foundTextV.get(i);
- assertEquals(allTheText[i],foundText);
- }
- }
-
- @Test
- void testReadAsString() {
- // Extract the text as a String
- String foundText = te.getTextAsString();
-
- // Turn the string array into a single string
- String expectText = StringUtil.join(allTheText, "\n") + "\n";
-
- // Ensure they match
- assertEquals(expectText,foundText);
- }
+ // Ensure they match
+ assertEquals(allTheText.length,foundTextV.size());
+ for(int i=0; i<allTheText.length; i++) {
+ String foundText = foundTextV.get(i);
+ assertEquals(allTheText[i],foundText);
+ }
+ }
+
+ @Test
+ void testReadAsString() {
+ // Extract the text as a String
+ String foundText = te.getTextAsString();
+
+ // Turn the string array into a single string
+ String expectText = StringUtil.join(allTheText, "\n") + "\n";
+
+ // Ensure they match
+ assertEquals(expectText,foundText);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestOleEmbedding.java Sat May 22 21:37:08 2021
@@ -114,26 +114,26 @@ public final class TestOleEmbedding {
@Test
void testEmbedding() throws IOException {
- HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg");
- HSLFPictureData pictData = ppt.addPicture(pict, PictureType.JPEG);
+ File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg");
+ HSLFPictureData pictData = ppt.addPicture(pict, PictureType.JPEG);
- InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls");
- POIFSFileSystem poiData1 = new POIFSFileSystem(is);
- is.close();
-
- int oleObjectId1 = ppt.addEmbed(poiData1);
-
- HSLFSlide slide1 = ppt.createSlide();
- HSLFObjectShape oleShape1 = new HSLFObjectShape(pictData);
- oleShape1.setObjectID(oleObjectId1);
- slide1.addShape(oleShape1);
- oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100));
-
- // add second slide with different order in object creation
- HSLFSlide slide2 = ppt.createSlide();
- HSLFObjectShape oleShape2 = new HSLFObjectShape(pictData);
+ InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls");
+ POIFSFileSystem poiData1 = new POIFSFileSystem(is);
+ is.close();
+
+ int oleObjectId1 = ppt.addEmbed(poiData1);
+
+ HSLFSlide slide1 = ppt.createSlide();
+ HSLFObjectShape oleShape1 = new HSLFObjectShape(pictData);
+ oleShape1.setObjectID(oleObjectId1);
+ slide1.addShape(oleShape1);
+ oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100));
+
+ // add second slide with different order in object creation
+ HSLFSlide slide2 = ppt.createSlide();
+ HSLFObjectShape oleShape2 = new HSLFObjectShape(pictData);
is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleWithImages.xls");
POIFSFileSystem poiData2 = new POIFSFileSystem(is);
@@ -145,22 +145,22 @@ public final class TestOleEmbedding {
slide2.addShape(oleShape2);
oleShape2.setAnchor(new Rectangle2D.Double(100,100,100,100));
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
- ppt.write(bos);
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ ppt.write(bos);
- ppt = new HSLFSlideShow(bos.toInputStream());
- HSLFObjectShape comp = (HSLFObjectShape)ppt.getSlides().get(0).getShapes().get(0);
+ ppt = new HSLFSlideShow(bos.toInputStream());
+ HSLFObjectShape comp = (HSLFObjectShape)ppt.getSlides().get(0).getShapes().get(0);
byte[] compData = IOUtils.toByteArray(comp.getObjectData().getInputStream());
- bos.reset();
- poiData1.writeFilesystem(bos);
+ bos.reset();
+ poiData1.writeFilesystem(bos);
byte[] expData = bos.toByteArray();
- assertArrayEquals(expData, compData);
+ assertArrayEquals(expData, compData);
- poiData1.close();
- poiData2.close();
- ppt.close();
+ poiData1.close();
+ poiData2.close();
+ ppt.close();
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestSlideChangeNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestSlideChangeNotes.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestSlideChangeNotes.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestSlideChangeNotes.java Sat May 22 21:37:08 2021
@@ -30,34 +30,34 @@ import org.junit.jupiter.api.Test;
* Tests that changing a slide's idea of what notes sheet is its works right
*/
public final class TestSlideChangeNotes {
- // SlideShow primed on the test data
- private HSLFSlideShow ss;
+ // SlideShow primed on the test data
+ private HSLFSlideShow ss;
- @BeforeEach
- void init() throws Exception {
+ @BeforeEach
+ void init() throws Exception {
POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(hss);
- }
-
- @Test
- void testSetToNone() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
-
- slideOne.setNotes(null);
-
- assertEquals(0, sa.getNotesID());
- }
-
- @Test
- void testSetToSomething() {
- HSLFSlide slideOne = ss.getSlides().get(0);
- HSLFNotes notesOne = ss.getNotes().get(1);
- SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
+ }
+
+ @Test
+ void testSetToNone() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
+
+ slideOne.setNotes(null);
+
+ assertEquals(0, sa.getNotesID());
+ }
+
+ @Test
+ void testSetToSomething() {
+ HSLFSlide slideOne = ss.getSlides().get(0);
+ HSLFNotes notesOne = ss.getNotes().get(1);
+ SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
- slideOne.setNotes(notesOne);
+ slideOne.setNotes(notesOne);
- assertEquals(notesOne._getSheetNumber(), sa.getNotesID());
- }
+ assertEquals(notesOne._getSheetNumber(), sa.getNotesID());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org