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 [12/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/hslf/model/TestTextRunReWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java Sat May 22 21:37:08 2021
@@ -40,110 +40,110 @@ import org.junit.jupiter.api.Test;
*/
public final class TestTextRunReWrite {
@Test
- void testWritesOutTheSameNonRich() throws IOException {
- try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
- // Ensure the text lengths are as we'd expect to start with
- assertEquals(1, ppt1.getSlides().size());
- assertEquals(2, ppt1.getSlides().get(0).getTextParagraphs().size());
-
- // Grab the first text run on the first sheet
- List<HSLFTextParagraph> tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
- List<HSLFTextParagraph> tr2 = ppt1.getSlides().get(0).getTextParagraphs().get(1);
-
-
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
-
- assertEquals(1, tr1.size());
- assertEquals(30, HSLFTextParagraph.getText(tr1).length());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
-
- // Set the text to be as it is now
- HSLFTextParagraph.setText(tr1, HSLFTextParagraph.getRawText(tr1));
- tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
-
- // Check the text lengths are still right
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
-
- assertEquals(1, tr1.size());
- assertEquals(30, HSLFTextParagraph.getText(tr1).length());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
-
- // Use POIFS to query that lot
- try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
- // Check that the "PowerPoint Document" sections have the same size
- DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
-
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- assertEquals(oProps.getSize(), nProps.getSize());
-
- // Check that they contain the same data
- byte[] _oData = new byte[oProps.getSize()];
- byte[] _nData = new byte[nProps.getSize()];
- int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
- int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
- assertEquals(_oData.length, oLen);
- assertEquals(_nData.length, nLen);
- assertArrayEquals(_oData, _nData);
- }
- }
- }
+ void testWritesOutTheSameNonRich() throws IOException {
+ try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
+ // Ensure the text lengths are as we'd expect to start with
+ assertEquals(1, ppt1.getSlides().size());
+ assertEquals(2, ppt1.getSlides().get(0).getTextParagraphs().size());
+
+ // Grab the first text run on the first sheet
+ List<HSLFTextParagraph> tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+ List<HSLFTextParagraph> tr2 = ppt1.getSlides().get(0).getTextParagraphs().get(1);
+
+
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
+
+ assertEquals(1, tr1.size());
+ assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+
+ // Set the text to be as it is now
+ HSLFTextParagraph.setText(tr1, HSLFTextParagraph.getRawText(tr1));
+ tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+
+ // Check the text lengths are still right
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
+
+ assertEquals(1, tr1.size());
+ assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+
+ // Use POIFS to query that lot
+ try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
+ // Check that the "PowerPoint Document" sections have the same size
+ DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
+
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ assertEquals(oProps.getSize(), nProps.getSize());
+
+ // Check that they contain the same data
+ byte[] _oData = new byte[oProps.getSize()];
+ byte[] _nData = new byte[nProps.getSize()];
+ int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
+ int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
+ assertEquals(_oData.length, oLen);
+ assertEquals(_nData.length, nLen);
+ assertArrayEquals(_oData, _nData);
+ }
+ }
+ }
@Test
void testWritesOutTheSameRich() throws IOException {
- try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
- // Grab the first text run on the first sheet
- List<HSLFTextParagraph> tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
-
- // Get the first rich text run
- HSLFTextRun rtr1 = tr1.get(0).getTextRuns().get(0);
-
- // Check that the text sizes are as expected
- assertEquals(1, tr1.get(0).getTextRuns().size());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(30, rtr1.getLength());
- assertEquals(30, rtr1.getRawText().length());
- assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
-
- // Set the text to be as it is now
- rtr1.setText(rtr1.getRawText());
- rtr1 = tr1.get(0).getTextRuns().get(0);
-
- // Check that the text sizes are still as expected
- assertEquals(1, tr1.get(0).getTextRuns().size());
- assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
- assertEquals(30, tr1.get(0).getTextRuns().get(0).getRawText().length());
- assertEquals(30, rtr1.getLength());
- assertEquals(30, rtr1.getRawText().length());
- assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
- assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
-
- // Use POIFS to query that lot
- try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
- // Check that the "PowerPoint Document" sections have the same size
- DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
-
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- assertEquals(oProps.getSize(), nProps.getSize());
-
- // Check that they contain the same data
- byte[] _oData = new byte[oProps.getSize()];
- byte[] _nData = new byte[nProps.getSize()];
-
- int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
- int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
- assertEquals(_oData.length, oLen);
- assertEquals(_nData.length, nLen);
- assertArrayEquals(_oData, _nData);
- }
- }
- }
+ try (HSLFSlideShow ppt1 = getSlideShow("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")) {
+ // Grab the first text run on the first sheet
+ List<HSLFTextParagraph> tr1 = ppt1.getSlides().get(0).getTextParagraphs().get(0);
+
+ // Get the first rich text run
+ HSLFTextRun rtr1 = tr1.get(0).getTextRuns().get(0);
+
+ // Check that the text sizes are as expected
+ assertEquals(1, tr1.get(0).getTextRuns().size());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(30, rtr1.getLength());
+ assertEquals(30, rtr1.getRawText().length());
+ assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+
+ // Set the text to be as it is now
+ rtr1.setText(rtr1.getRawText());
+ rtr1 = tr1.get(0).getTextRuns().get(0);
+
+ // Check that the text sizes are still as expected
+ assertEquals(1, tr1.get(0).getTextRuns().size());
+ assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+ assertEquals(30, tr1.get(0).getTextRuns().get(0).getRawText().length());
+ assertEquals(30, rtr1.getLength());
+ assertEquals(30, rtr1.getRawText().length());
+ assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+ assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
+
+ // Use POIFS to query that lot
+ try (POIFSFileSystem npfs = writeOutAndReadBack(ppt1.getDirectory().getFileSystem())) {
+ // Check that the "PowerPoint Document" sections have the same size
+ DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
+
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ assertEquals(oProps.getSize(), nProps.getSize());
+
+ // Check that they contain the same data
+ byte[] _oData = new byte[oProps.getSize()];
+ byte[] _nData = new byte[nProps.getSize()];
+
+ int oLen = oDir.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
+ int nLen = npfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
+ assertEquals(_oData.length, oLen);
+ assertEquals(_nData.length, nLen);
+ assertArrayEquals(_oData, _nData);
+ }
+ }
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCString.java Sat May 22 21:37:08 2021
@@ -29,79 +29,79 @@ import org.junit.jupiter.api.Test;
* Tests that CString works properly
*/
public final class TestCString {
- // From a real file
- private final byte[] data_a = { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
- 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
- 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0 };
- private final byte[] data_b = new byte[] { 0x10, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
- 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
- 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0 };
+ // From a real file
+ private final byte[] data_a = { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
+ 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
+ 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0 };
+ private final byte[] data_b = new byte[] { 0x10, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
+ 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
+ 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0 };
- @Test
+ @Test
void testRecordType() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals(4026L, ca.getRecordType());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals(4026L, cb.getRecordType());
- }
-
- @Test
- void testCount() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals(0, ca.getOptions());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals(0x10, cb.getOptions());
-
- ca.setOptions(28);
- assertEquals(28, ca.getOptions());
- }
-
- @Test
- void testText() {
- CString ca = new CString(data_a, 0, data_a.length);
- assertEquals("Hogwarts", ca.getText());
- CString cb = new CString(data_b, 0, data_a.length);
- assertEquals("Comments", cb.getText());
-
- ca.setText("FooBar");
- assertEquals("FooBar", ca.getText());
- }
-
- @Test
- void testWrite() throws Exception {
- CString ca = new CString(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
-
- CString cb = new CString(data_b, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baosB = new UnsynchronizedByteArrayOutputStream();
- cb.writeOut(baosB);
- b = baosB.toByteArray();
- assertArrayEquals(data_b, b);
- }
-
- // Turn data_a into data_b
- @Test
- void testChange() throws Exception {
- CString ca = new CString(data_a, 0, data_a.length);
- ca.setText("Comments");
- ca.setOptions(0x10);
-
- // Check bytes weren't the same
- boolean equals = true;
- for(int i=0; i<data_a.length; i++) {
- if (data_a[i] != data_b[i]) {
- equals = false;
- break;
- }
- }
- assertFalse(equals, "Arrays should not be equals");
-
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_b, b);
- }
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals(4026L, ca.getRecordType());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals(4026L, cb.getRecordType());
+ }
+
+ @Test
+ void testCount() {
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals(0, ca.getOptions());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals(0x10, cb.getOptions());
+
+ ca.setOptions(28);
+ assertEquals(28, ca.getOptions());
+ }
+
+ @Test
+ void testText() {
+ CString ca = new CString(data_a, 0, data_a.length);
+ assertEquals("Hogwarts", ca.getText());
+ CString cb = new CString(data_b, 0, data_a.length);
+ assertEquals("Comments", cb.getText());
+
+ ca.setText("FooBar");
+ assertEquals("FooBar", ca.getText());
+ }
+
+ @Test
+ void testWrite() throws Exception {
+ CString ca = new CString(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_a, b);
+
+ CString cb = new CString(data_b, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baosB = new UnsynchronizedByteArrayOutputStream();
+ cb.writeOut(baosB);
+ b = baosB.toByteArray();
+ assertArrayEquals(data_b, b);
+ }
+
+ // Turn data_a into data_b
+ @Test
+ void testChange() throws Exception {
+ CString ca = new CString(data_a, 0, data_a.length);
+ ca.setText("Comments");
+ ca.setOptions(0x10);
+
+ // Check bytes weren't the same
+ boolean equals = true;
+ for(int i=0; i<data_a.length; i++) {
+ if (data_a[i] != data_b[i]) {
+ equals = false;
+ break;
+ }
+ }
+ assertFalse(equals, "Arrays should not be equals");
+
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_b, b);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestColorSchemeAtom.java Sat May 22 21:37:08 2021
@@ -28,63 +28,63 @@ import org.junit.jupiter.api.Test;
* Tests that ColorSchemAtom works properly
*/
public final class TestColorSchemeAtom {
- // From a real file
- private final byte[] data_a = { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0,
- 0xFF-256, 0xFF-256, 0xFF-256, 0, 0, 0, 0, 0,
- 0x80-256, 0x80-256, 0x80-256, 0, 0, 0, 0, 0,
- 0xBB-256, 0xE0-256, 0xE3-256, 0, 0x33, 0x33, 0x99-256, 0,
- 0, 0x99-256, 0x99-256, 0, 0x99-256, 0xCC-256, 0, 0
- };
-
- @Test
- void testRecordType() {
- ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
- assertEquals(2032L, csa.getRecordType());
- }
-
- @Test
- void testToRGB() {
- byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
-
- assertEquals(3,rgb.length);
- assertEquals(0, rgb[0]);
- assertEquals(255-256, rgb[1]);
- assertEquals(55, rgb[2]);
- }
-
- @Test
- void testFromRGB() {
- byte[] rgb_a = new byte[] { 0, 255-256, 55 };
- byte[] rgb_b = new byte[] { 255-256, 127, 79 };
-
- assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a ) );
- assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b ) );
-
- assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a[0], rgb_a[1], rgb_a[2] ) );
- assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
- }
-
- @Test
- void testRGBs() {
- ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
-
- assertEquals( 16777215 , csa.getBackgroundColourRGB() );
- assertEquals( 0 , csa.getTextAndLinesColourRGB() );
- assertEquals( 8421504 , csa.getShadowsColourRGB() );
- assertEquals( 0 , csa.getTitleTextColourRGB() );
- assertEquals( 14934203 , csa.getFillsColourRGB() );
- assertEquals( 10040115 , csa.getAccentColourRGB() );
- assertEquals( 10066176 , csa.getAccentAndHyperlinkColourRGB() );
- assertEquals( 52377 , csa.getAccentAndFollowingHyperlinkColourRGB() );
- }
-
- @Test
- void testWrite() throws Exception {
- ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- csa.writeOut(baos);
- byte[] b = baos.toByteArray();
+ // From a real file
+ private final byte[] data_a = { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0,
+ 0xFF-256, 0xFF-256, 0xFF-256, 0, 0, 0, 0, 0,
+ 0x80-256, 0x80-256, 0x80-256, 0, 0, 0, 0, 0,
+ 0xBB-256, 0xE0-256, 0xE3-256, 0, 0x33, 0x33, 0x99-256, 0,
+ 0, 0x99-256, 0x99-256, 0, 0x99-256, 0xCC-256, 0, 0
+ };
+
+ @Test
+ void testRecordType() {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+ assertEquals(2032L, csa.getRecordType());
+ }
+
+ @Test
+ void testToRGB() {
+ byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
+
+ assertEquals(3,rgb.length);
+ assertEquals(0, rgb[0]);
+ assertEquals(255-256, rgb[1]);
+ assertEquals(55, rgb[2]);
+ }
+
+ @Test
+ void testFromRGB() {
+ byte[] rgb_a = new byte[] { 0, 255-256, 55 };
+ byte[] rgb_b = new byte[] { 255-256, 127, 79 };
+
+ assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a ) );
+ assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b ) );
+
+ assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a[0], rgb_a[1], rgb_a[2] ) );
+ assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
+ }
+
+ @Test
+ void testRGBs() {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+
+ assertEquals( 16777215 , csa.getBackgroundColourRGB() );
+ assertEquals( 0 , csa.getTextAndLinesColourRGB() );
+ assertEquals( 8421504 , csa.getShadowsColourRGB() );
+ assertEquals( 0 , csa.getTitleTextColourRGB() );
+ assertEquals( 14934203 , csa.getFillsColourRGB() );
+ assertEquals( 10040115 , csa.getAccentColourRGB() );
+ assertEquals( 10066176 , csa.getAccentAndHyperlinkColourRGB() );
+ assertEquals( 52377 , csa.getAccentAndFollowingHyperlinkColourRGB() );
+ }
+
+ @Test
+ void testWrite() throws Exception {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ csa.writeOut(baos);
+ byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
- }
+ assertArrayEquals(data_a, b);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000.java Sat May 22 21:37:08 2021
@@ -38,182 +38,182 @@ import org.junit.jupiter.api.Test;
* TODO: Test Comment200Atom within
*/
public final class TestComment2000 {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0x0F, 0, 0xE0-256, 0x2E, 0x9C-256, 0, 0, 0,
- 0, 0, 0xBA-256, 0x0F, 0x14, 0, 0, 0,
- 0x44, 0, 0x75, 0, 0x6D, 0, 0x62, 0,
- 0x6C, 0, 0x65, 0, 0x64, 0, 0x6F, 0,
- 0x72, 0, 0x65, 0,
- 0x10, 0, 0xBA-256, 0x0F, 0x4A, 0, 0, 0,
- 0x59, 0, 0x65, 0, 0x73, 0, 0x2C, 0,
- 0x20, 0, 0x74, 0, 0x68, 0, 0x65, 0,
- 0x79, 0, 0x20, 0, 0x63, 0, 0x65, 0,
- 0x72, 0, 0x74, 0, 0x61, 0, 0x69, 0,
- 0x6E, 0, 0x6C, 0, 0x79, 0, 0x20, 0,
- 0x61, 0, 0x72, 0, 0x65, 0, 0x2C, 0,
- 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0,
- 0x6E, 0, 0x27, 0, 0x74, 0, 0x20, 0,
- 0x74, 0, 0x68, 0, 0x65, 0, 0x79, 0, 0x21, 0,
- 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0,
- 0x44, 0,
- 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
- 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0,
- 0x02, 0, 0x18, 0, 0x0A, 0, 0x1A, 0,
- 0x0F, 0, 0xCD-256, 0, 0x92-256, 0,
- 0, 0, 0x92-256, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0x0F, 0, 0xE0-256, 0x2E, 0xAC-256, 0, 0, 0,
- 0, 0, 0xBA-256, 0x0F, 0x10, 0, 0, 0,
- 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
- 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0,
- 0x10, 0, 0xBA-256, 0x0F, 0x5E, 0, 0, 0,
- 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
- 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0,
- 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0,
- 0x20, 0, 0x66, 0, 0x75, 0, 0x6E, 0,
- 0x20, 0, 0x74, 0, 0x68, 0, 0x69, 0,
- 0x6E, 0, 0x67, 0, 0x73, 0, 0x20, 0,
- 0x74, 0, 0x6F, 0, 0x20, 0, 0x61, 0,
- 0x64, 0, 0x64, 0, 0x20, 0, 0x69, 0,
- 0x6E, 0, 0x2C, 0, 0x20, 0, 0x61, 0,
- 0x72, 0, 0x65, 0, 0x6E, 0, 0x27, 0,
- 0x74, 0, 0x20, 0, 0x74, 0, 0x68, 0,
- 0x65, 0, 0x79, 0, 0x3F, 0,
- 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0,
- 0x48, 0,
- 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
- 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0,
- 0x02, 0, 0x18, 0, 0x16, 0, 0x19, 0, 0x03,
- 0, 0xD5-256, 0x02, 0x0A, 0, 0, 0,
- 0x0A, 0, 0, 0
- };
-
- private static SimpleDateFormat sdf;
-
- @BeforeAll
- public static void initDateFormat() {
- sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT);
- sdf.setTimeZone(LocaleUtil.getUserTimeZone());
- }
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0x0F, 0, 0xE0-256, 0x2E, 0x9C-256, 0, 0, 0,
+ 0, 0, 0xBA-256, 0x0F, 0x14, 0, 0, 0,
+ 0x44, 0, 0x75, 0, 0x6D, 0, 0x62, 0,
+ 0x6C, 0, 0x65, 0, 0x64, 0, 0x6F, 0,
+ 0x72, 0, 0x65, 0,
+ 0x10, 0, 0xBA-256, 0x0F, 0x4A, 0, 0, 0,
+ 0x59, 0, 0x65, 0, 0x73, 0, 0x2C, 0,
+ 0x20, 0, 0x74, 0, 0x68, 0, 0x65, 0,
+ 0x79, 0, 0x20, 0, 0x63, 0, 0x65, 0,
+ 0x72, 0, 0x74, 0, 0x61, 0, 0x69, 0,
+ 0x6E, 0, 0x6C, 0, 0x79, 0, 0x20, 0,
+ 0x61, 0, 0x72, 0, 0x65, 0, 0x2C, 0,
+ 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0,
+ 0x6E, 0, 0x27, 0, 0x74, 0, 0x20, 0,
+ 0x74, 0, 0x68, 0, 0x65, 0, 0x79, 0, 0x21, 0,
+ 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0,
+ 0x44, 0,
+ 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
+ 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0,
+ 0x02, 0, 0x18, 0, 0x0A, 0, 0x1A, 0,
+ 0x0F, 0, 0xCD-256, 0, 0x92-256, 0,
+ 0, 0, 0x92-256, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0x0F, 0, 0xE0-256, 0x2E, 0xAC-256, 0, 0, 0,
+ 0, 0, 0xBA-256, 0x0F, 0x10, 0, 0, 0,
+ 0x48, 0, 0x6F, 0, 0x67, 0, 0x77, 0,
+ 0x61, 0, 0x72, 0, 0x74, 0, 0x73, 0,
+ 0x10, 0, 0xBA-256, 0x0F, 0x5E, 0, 0, 0,
+ 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
+ 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0,
+ 0x20, 0, 0x61, 0, 0x72, 0, 0x65, 0,
+ 0x20, 0, 0x66, 0, 0x75, 0, 0x6E, 0,
+ 0x20, 0, 0x74, 0, 0x68, 0, 0x69, 0,
+ 0x6E, 0, 0x67, 0, 0x73, 0, 0x20, 0,
+ 0x74, 0, 0x6F, 0, 0x20, 0, 0x61, 0,
+ 0x64, 0, 0x64, 0, 0x20, 0, 0x69, 0,
+ 0x6E, 0, 0x2C, 0, 0x20, 0, 0x61, 0,
+ 0x72, 0, 0x65, 0, 0x6E, 0, 0x27, 0,
+ 0x74, 0, 0x20, 0, 0x74, 0, 0x68, 0,
+ 0x65, 0, 0x79, 0, 0x3F, 0,
+ 0x20, 0, 0xBA-256, 0x0F, 0x02, 0, 0, 0,
+ 0x48, 0,
+ 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
+ 0x01, 0, 0, 0, 0xD6-256, 0x07, 0x01, 0,
+ 0x02, 0, 0x18, 0, 0x16, 0, 0x19, 0, 0x03,
+ 0, 0xD5-256, 0x02, 0x0A, 0, 0, 0,
+ 0x0A, 0, 0, 0
+ };
+
+ private static SimpleDateFormat sdf;
+
+ @BeforeAll
+ public static void initDateFormat() {
+ sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT);
+ sdf.setTimeZone(LocaleUtil.getUserTimeZone());
+ }
@Test
void testRecordType() {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- assertEquals(12000L, ca.getRecordType());
- }
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ assertEquals(12000L, ca.getRecordType());
+ }
@Test
void testAuthor() {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- assertEquals("Dumbledore", ca.getAuthor());
- assertEquals("D", ca.getAuthorInitials());
- }
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ assertEquals("Dumbledore", ca.getAuthor());
+ assertEquals("D", ca.getAuthorInitials());
+ }
@Test
void testText() {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- assertEquals("Yes, they certainly are, aren't they!", ca.getText());
- }
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ assertEquals("Yes, they certainly are, aren't they!", ca.getText());
+ }
@Test
void testCommentAtom() throws Exception {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- Comment2000Atom c2a = ca.getComment2000Atom();
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ Comment2000Atom c2a = ca.getComment2000Atom();
- assertEquals(1, c2a.getNumber());
- assertEquals(0x92, c2a.getXOffset());
- assertEquals(0x92, c2a.getYOffset());
- Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
- assertEquals(exp_a, c2a.getDate());
- }
+ assertEquals(1, c2a.getNumber());
+ assertEquals(0x92, c2a.getXOffset());
+ assertEquals(0x92, c2a.getYOffset());
+ Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
+ assertEquals(exp_a, c2a.getDate());
+ }
@Test
void testCommentAtomB() throws Exception {
- Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
- Comment2000Atom c2b = cb.getComment2000Atom();
+ Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
+ Comment2000Atom c2b = cb.getComment2000Atom();
- assertEquals(1, c2b.getNumber());
- assertEquals(0x0a, c2b.getXOffset());
- assertEquals(0x0a, c2b.getYOffset());
- Date exp_b = sdf.parse("2006-01-24 22:25:03.725");
- assertEquals(exp_b, c2b.getDate());
- }
+ assertEquals(1, c2b.getNumber());
+ assertEquals(0x0a, c2b.getXOffset());
+ assertEquals(0x0a, c2b.getYOffset());
+ Date exp_b = sdf.parse("2006-01-24 22:25:03.725");
+ assertEquals(exp_b, c2b.getDate());
+ }
@Test
void testWrite() throws Exception {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
- }
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_a, b);
+ }
- // Change a few things
+ // Change a few things
@Test
void testChange() throws Exception {
- Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
- Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
- Comment2000 cn = new Comment2000();
- ca.setAuthor("Hogwarts");
- ca.setAuthorInitials("H");
- ca.setText("Comments are fun things to add in, aren't they?");
- cn.setAuthor("Hogwarts");
- cn.setAuthorInitials("H");
- cn.setText("Comments are fun things to add in, aren't they?");
-
- // Change the Comment2000Atom
- Comment2000Atom c2a = ca.getComment2000Atom();
- Comment2000Atom c2n = cn.getComment2000Atom();
- c2a.setNumber(1);
- c2a.setXOffset(0x0a);
- c2a.setYOffset(0x0a);
- c2n.setNumber(1);
- c2n.setXOffset(0x0a);
- c2n.setYOffset(0x0a);
-
- Date new_date = sdf.parse("2006-01-24 22:25:03.725");
- c2a.setDate(new_date);
- c2n.setDate(new_date);
-
- // Check now the same
- assertEquals(ca.getText(), cb.getText());
- assertEquals(cn.getText(), cb.getText());
- assertEquals(ca.getAuthor(), cb.getAuthor());
- assertEquals(cn.getAuthor(), cb.getAuthor());
- assertEquals(ca.getAuthorInitials(), cb.getAuthorInitials());
- assertEquals(cn.getAuthorInitials(), cb.getAuthorInitials());
-
- // Check bytes weren't the same
- boolean equals = true;
- for(int i=0; i<data_a.length; i++) {
- if (data_a[i] != data_b[i]) {
- equals = false;
- break;
- }
- }
- assertFalse(equals, "Arrays should not be equals");
-
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baosa = new UnsynchronizedByteArrayOutputStream();
- UnsynchronizedByteArrayOutputStream baosn = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baosa);
- cn.writeOut(baosn);
- byte[] ba = baosa.toByteArray();
- byte[] bn = baosn.toByteArray();
-
- // Should now be the same
- assertArrayEquals(data_b, ba);
- assertArrayEquals(data_b, bn);
- }
+ Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
+ Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
+ Comment2000 cn = new Comment2000();
+ ca.setAuthor("Hogwarts");
+ ca.setAuthorInitials("H");
+ ca.setText("Comments are fun things to add in, aren't they?");
+ cn.setAuthor("Hogwarts");
+ cn.setAuthorInitials("H");
+ cn.setText("Comments are fun things to add in, aren't they?");
+
+ // Change the Comment2000Atom
+ Comment2000Atom c2a = ca.getComment2000Atom();
+ Comment2000Atom c2n = cn.getComment2000Atom();
+ c2a.setNumber(1);
+ c2a.setXOffset(0x0a);
+ c2a.setYOffset(0x0a);
+ c2n.setNumber(1);
+ c2n.setXOffset(0x0a);
+ c2n.setYOffset(0x0a);
+
+ Date new_date = sdf.parse("2006-01-24 22:25:03.725");
+ c2a.setDate(new_date);
+ c2n.setDate(new_date);
+
+ // Check now the same
+ assertEquals(ca.getText(), cb.getText());
+ assertEquals(cn.getText(), cb.getText());
+ assertEquals(ca.getAuthor(), cb.getAuthor());
+ assertEquals(cn.getAuthor(), cb.getAuthor());
+ assertEquals(ca.getAuthorInitials(), cb.getAuthorInitials());
+ assertEquals(cn.getAuthorInitials(), cb.getAuthorInitials());
+
+ // Check bytes weren't the same
+ boolean equals = true;
+ for(int i=0; i<data_a.length; i++) {
+ if (data_a[i] != data_b[i]) {
+ equals = false;
+ break;
+ }
+ }
+ assertFalse(equals, "Arrays should not be equals");
+
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baosa = new UnsynchronizedByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream baosn = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baosa);
+ cn.writeOut(baosn);
+ byte[] ba = baosa.toByteArray();
+ byte[] bn = baosn.toByteArray();
+
+ // Should now be the same
+ assertArrayEquals(data_b, ba);
+ assertArrayEquals(data_b, bn);
+ }
/**
* A Comment2000 records with missing commentTextAtom
*/
@Test
void testBug44770() {
- byte[] data = {
+ byte[] data = {
0x0F, 0x00, (byte)0xE0, 0x2E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xBA, 0x0F,
0x08, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x45, 0x00, 0x53, 0x00, 0x53, 0x00, 0x20,
0x00, (byte)0xBA, 0x0F, 0x02, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x00, 0x00, (byte)0xE1, 0x2E,
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestComment2000Atom.java Sat May 22 21:37:08 2021
@@ -34,21 +34,21 @@ import org.junit.jupiter.api.Test;
* Tests that Comment2000Atom works properly.
*/
public final class TestComment2000Atom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
- 1, 0, 0, 0, 0xD6-256, 7, 1, 0,
- 2, 0, 0x18, 0, 0x0A, 0, 0x1A, 0,
- 0x0F, 0, 0xCD-256, 0, 0x92-256, 0,
- 0, 0, 0x92-256, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
- 5, 0, 0, 0, 0xD6-256, 0x07, 1, 0,
- 2, 0, 0x18, 0, 0x15, 0, 0x19, 0, 3,
- 0, 0xD5-256, 2, 0x0A, 0, 0, 0,
- 0x0E, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
+ 1, 0, 0, 0, 0xD6-256, 7, 1, 0,
+ 2, 0, 0x18, 0, 0x0A, 0, 0x1A, 0,
+ 0x0F, 0, 0xCD-256, 0, 0x92-256, 0,
+ 0, 0, 0x92-256, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0xE1-256, 0x2E, 0x1C, 0, 0, 0,
+ 5, 0, 0, 0, 0xD6-256, 0x07, 1, 0,
+ 2, 0, 0x18, 0, 0x15, 0, 0x19, 0, 3,
+ 0, 0xD5-256, 2, 0x0A, 0, 0, 0,
+ 0x0E, 0, 0, 0
+ };
private static SimpleDateFormat sdf;
@@ -58,101 +58,101 @@ public final class TestComment2000Atom {
sdf.setTimeZone(LocaleUtil.getUserTimeZone());
}
- @Test
- void testRecordType() {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- assertEquals(12001L, ca.getRecordType());
- }
+ @Test
+ void testRecordType() {
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ assertEquals(12001L, ca.getRecordType());
+ }
- @Test
+ @Test
void testGetDate() throws Exception {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
+
+ // A is 2006-01-24 (2nd day of week) 10:26:15.205
+ Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
+ // B is 2006-01-24 (2nd day of week) 21:25:03.725
+ Date exp_b = sdf.parse("2006-01-24 21:25:03.725");
- // A is 2006-01-24 (2nd day of week) 10:26:15.205
- Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
- // B is 2006-01-24 (2nd day of week) 21:25:03.725
- Date exp_b = sdf.parse("2006-01-24 21:25:03.725");
-
- assertEquals(exp_a, ca.getDate());
- assertEquals(exp_b, cb.getDate());
- }
+ assertEquals(exp_a, ca.getDate());
+ assertEquals(exp_b, cb.getDate());
+ }
- @Test
+ @Test
void testGetNums() {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
- // A is number 1
- assertEquals(1, ca.getNumber());
- // B is number 5
- assertEquals(5, cb.getNumber());
- }
+ // A is number 1
+ assertEquals(1, ca.getNumber());
+ // B is number 5
+ assertEquals(5, cb.getNumber());
+ }
- @Test
+ @Test
void testGetPos() {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
- // A is at 0x92, 0x92
- assertEquals(0x92, ca.getXOffset());
- assertEquals(0x92, ca.getYOffset());
-
- // B is at 0x0A, 0x0E
- assertEquals(0x0A, cb.getXOffset());
- assertEquals(0x0E, cb.getYOffset());
- }
+ // A is at 0x92, 0x92
+ assertEquals(0x92, ca.getXOffset());
+ assertEquals(0x92, ca.getYOffset());
+
+ // B is at 0x0A, 0x0E
+ assertEquals(0x0A, cb.getXOffset());
+ assertEquals(0x0E, cb.getYOffset());
+ }
- @Test
+ @Test
void testWrite() throws Exception {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
- }
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_a, b);
+ }
- // Create A from scratch
- @Test
+ // Create A from scratch
+ @Test
void testCreate() throws Exception {
- Comment2000Atom a = new Comment2000Atom();
+ Comment2000Atom a = new Comment2000Atom();
- // Set number, x and y
- a.setNumber(1);
- a.setXOffset(0x92);
- a.setYOffset(0x92);
-
- // Set the date
- Date date_a = sdf.parse("2006-01-24 10:26:15.205");
- a.setDate(date_a);
-
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- a.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_a, b);
- }
+ // Set number, x and y
+ a.setNumber(1);
+ a.setXOffset(0x92);
+ a.setYOffset(0x92);
+
+ // Set the date
+ Date date_a = sdf.parse("2006-01-24 10:26:15.205");
+ a.setDate(date_a);
+
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ a.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_a, b);
+ }
- // Try to turn a into b
- @Test
+ // Try to turn a into b
+ @Test
void testChange() throws Exception {
- Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
+ Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
- // Change the number
- ca.setNumber(5);
+ // Change the number
+ ca.setNumber(5);
- // Change the date
- Date new_date = sdf.parse("2006-01-24 21:25:03.725");
- ca.setDate(new_date);
-
- // Change the x and y
- ca.setXOffset(0x0A);
- ca.setYOffset(0x0E);
-
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- ca.writeOut(baos);
- byte[] b = baos.toByteArray();
- assertArrayEquals(data_b, b);
- }
+ // Change the date
+ Date new_date = sdf.parse("2006-01-24 21:25:03.725");
+ ca.setDate(new_date);
+
+ // Change the x and y
+ ca.setXOffset(0x0A);
+ ca.setYOffset(0x0E);
+
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ ca.writeOut(baos);
+ byte[] b = baos.toByteArray();
+ assertArrayEquals(data_b, b);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java Sat May 22 21:37:08 2021
@@ -36,63 +36,63 @@ import org.junit.jupiter.api.Test;
*/
public final class TestCurrentUserAtom {
private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
- /** Not encrypted */
- private static final String normalFile = "basic_test_ppt_file.ppt";
- /** Encrypted */
- private static final String encFile = "Password_Protected-hello.ppt";
-
- @Test
- void readNormal() throws Exception {
- POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile));
-
- CurrentUserAtom cu = new CurrentUserAtom(fs.getRoot());
- fs.close();
-
- // Check the contents
- assertEquals("Hogwarts", cu.getLastEditUsername());
- assertEquals(0x2942, cu.getCurrentEditOffset());
-
- // Round trip
- POIFSFileSystem poifs = new POIFSFileSystem();
- cu.writeToFS(poifs);
-
- CurrentUserAtom cu2 = new CurrentUserAtom(poifs.getRoot());
- assertEquals("Hogwarts", cu2.getLastEditUsername());
- assertEquals(0x2942, cu2.getCurrentEditOffset());
+ /** Not encrypted */
+ private static final String normalFile = "basic_test_ppt_file.ppt";
+ /** Encrypted */
+ private static final String encFile = "Password_Protected-hello.ppt";
+
+ @Test
+ void readNormal() throws Exception {
+ POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile));
+
+ CurrentUserAtom cu = new CurrentUserAtom(fs.getRoot());
+ fs.close();
+
+ // Check the contents
+ assertEquals("Hogwarts", cu.getLastEditUsername());
+ assertEquals(0x2942, cu.getCurrentEditOffset());
+
+ // Round trip
+ POIFSFileSystem poifs = new POIFSFileSystem();
+ cu.writeToFS(poifs);
+
+ CurrentUserAtom cu2 = new CurrentUserAtom(poifs.getRoot());
+ assertEquals("Hogwarts", cu2.getLastEditUsername());
+ assertEquals(0x2942, cu2.getCurrentEditOffset());
- poifs.close();
- }
+ poifs.close();
+ }
- @Test
- void readEnc() throws Exception {
+ @Test
+ void readEnc() throws Exception {
try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(encFile))) {
new CurrentUserAtom(fs.getRoot());
- assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(fs).close());
+ assertThrows(EncryptedPowerPointFileException.class, () -> new HSLFSlideShowImpl(fs).close());
}
- }
+ }
- @Test
- void writeNormal() throws Exception {
- // Get raw contents from a known file
- byte[] contents;
- try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) {
- DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User");
- contents = new byte[docProps.getSize()];
- try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) {
- in.read(contents);
- }
- }
-
- // Now build up a new one
- CurrentUserAtom cu = new CurrentUserAtom();
- cu.setLastEditUsername("Hogwarts");
- cu.setCurrentEditOffset(0x2942);
-
- // Check it matches
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- cu.writeOut(baos);
- byte[] out = baos.toByteArray();
+ @Test
+ void writeNormal() throws Exception {
+ // Get raw contents from a known file
+ byte[] contents;
+ try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) {
+ DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User");
+ contents = new byte[docProps.getSize()];
+ try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) {
+ in.read(contents);
+ }
+ }
+
+ // Now build up a new one
+ CurrentUserAtom cu = new CurrentUserAtom();
+ cu.setLastEditUsername("Hogwarts");
+ cu.setCurrentEditOffset(0x2942);
+
+ // Check it matches
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ cu.writeOut(baos);
+ byte[] out = baos.toByteArray();
- assertArrayEquals(contents, out);
- }
+ assertArrayEquals(contents, out);
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocument.java Sat May 22 21:37:08 2021
@@ -30,57 +30,57 @@ import org.junit.jupiter.api.Test;
* Tests that Document works properly (Also tests Environment while we're at it)
*/
public final class TestDocument {
- private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- // HSLFSlideShow primed on the test data
- private HSLFSlideShowImpl ss;
- // POIFS primed on the test data
- private POIFSFileSystem pfs;
-
- @BeforeEach
- void setup() throws Exception {
- pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShowImpl(pfs);
- }
-
- private Document getDocRecord() {
- Record[] r = ss.getRecords();
- for (int i = (r.length - 1); i >= 0; i--) {
- if (r[i] instanceof Document) {
- return (Document) r[i];
- }
- }
- throw new IllegalStateException("No Document record found");
- }
-
- @Test
- void testRecordType() {
- Document dr = getDocRecord();
- assertEquals(1000, dr.getRecordType());
- }
-
- @Test
- void testChildRecords() {
- Document dr = getDocRecord();
- assertNotNull(dr.getDocumentAtom());
-
- assertNotNull(dr.getEnvironment());
-
- assertNotNull(dr.getSlideListWithTexts());
- assertEquals(3, dr.getSlideListWithTexts().length);
- assertNotNull(dr.getSlideListWithTexts()[0]);
- assertNotNull(dr.getSlideListWithTexts()[1]);
- assertNotNull(dr.getSlideListWithTexts()[2]);
- }
-
- @Test
- void testEnvironment() {
- Document dr = getDocRecord();
- Environment env = dr.getEnvironment();
-
- assertEquals(1010, env.getRecordType());
- assertNotNull(env.getFontCollection());
- }
+ // HSLFSlideShow primed on the test data
+ private HSLFSlideShowImpl ss;
+ // POIFS primed on the test data
+ private POIFSFileSystem pfs;
+
+ @BeforeEach
+ void setup() throws Exception {
+ pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShowImpl(pfs);
+ }
+
+ private Document getDocRecord() {
+ Record[] r = ss.getRecords();
+ for (int i = (r.length - 1); i >= 0; i--) {
+ if (r[i] instanceof Document) {
+ return (Document) r[i];
+ }
+ }
+ throw new IllegalStateException("No Document record found");
+ }
+
+ @Test
+ void testRecordType() {
+ Document dr = getDocRecord();
+ assertEquals(1000, dr.getRecordType());
+ }
+
+ @Test
+ void testChildRecords() {
+ Document dr = getDocRecord();
+ assertNotNull(dr.getDocumentAtom());
+
+ assertNotNull(dr.getEnvironment());
+
+ assertNotNull(dr.getSlideListWithTexts());
+ assertEquals(3, dr.getSlideListWithTexts().length);
+ assertNotNull(dr.getSlideListWithTexts()[0]);
+ assertNotNull(dr.getSlideListWithTexts()[1]);
+ assertNotNull(dr.getSlideListWithTexts()[2]);
+ }
+
+ @Test
+ void testEnvironment() {
+ Document dr = getDocRecord();
+ Environment env = dr.getEnvironment();
+
+ assertEquals(1010, env.getRecordType());
+ assertNotNull(env.getFontCollection());
+ }
- // No need to check re-writing - hslf.TestReWrite does all that for us
+ // No need to check re-writing - hslf.TestReWrite does all that for us
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentAtom.java Sat May 22 21:37:08 2021
@@ -30,59 +30,59 @@ import org.junit.jupiter.api.Test;
* Tests that DocumentAtom works properly
*/
public final class TestDocumentAtom {
- // From a real file
- private final byte[] data_a = { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
- 0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0,
- 0xE0-256, 0x10, 0, 0, 0x80-256, 0x16, 0, 0,
- 0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 0, 1 };
+ // From a real file
+ private final byte[] data_a = { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
+ 0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0,
+ 0xE0-256, 0x10, 0, 0, 0x80-256, 0x16, 0, 0,
+ 0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 1 };
- @Test
+ @Test
void testRecordType() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(1001L, da.getRecordType());
- }
-
- @Test
- void testSizeAndZoom() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(5760L, da.getSlideSizeX());
- assertEquals(4320L, da.getSlideSizeY());
- assertEquals(4320L, da.getNotesSizeX());
- assertEquals(5760L, da.getNotesSizeY());
-
- assertEquals(5L, da.getServerZoomFrom());
- assertEquals(10L, da.getServerZoomTo());
- }
-
- @Test
- void testMasterPersist() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(2L, da.getNotesMasterPersist());
- assertEquals(0L, da.getHandoutMasterPersist());
- }
-
- @Test
- void testSlideDetails() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(1, da.getFirstSlideNum());
- assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
- }
-
- @Test
- void testBooleans() {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(1001L, da.getRecordType());
+ }
+
+ @Test
+ void testSizeAndZoom() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(5760L, da.getSlideSizeX());
+ assertEquals(4320L, da.getSlideSizeY());
+ assertEquals(4320L, da.getNotesSizeX());
+ assertEquals(5760L, da.getNotesSizeY());
+
+ assertEquals(5L, da.getServerZoomFrom());
+ assertEquals(10L, da.getServerZoomTo());
+ }
+
+ @Test
+ void testMasterPersist() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(2L, da.getNotesMasterPersist());
+ assertEquals(0L, da.getHandoutMasterPersist());
+ }
+
+ @Test
+ void testSlideDetails() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ assertEquals(1, da.getFirstSlideNum());
+ assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
+ }
+
+ @Test
+ void testBooleans() {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertFalse(da.getSaveWithFonts());
assertFalse(da.getOmitTitlePlace());
assertFalse(da.getRightToLeft());
assertTrue(da.getShowComments());
- }
+ }
- @Test
- void testWrite() throws Exception {
- DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- da.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
+ @Test
+ void testWrite() throws Exception {
+ DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ da.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java Sat May 22 21:37:08 2021
@@ -28,82 +28,82 @@ import org.junit.jupiter.api.Test;
* Tests that DocumentEncryptionAtom works properly.
*/
public final class TestDocumentEncryptionAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0x0F, 00, 0x14, 0x2F, 0xBE-256, 00, 00, 00,
- 02, 00, 02, 00, 0x0C, 00, 00, 00,
- 0x76, 00, 00, 00, 0x0C, 00, 00, 00,
- 00, 00, 00, 00, 01, 0x68, 00, 00,
- 04, 0x80-256, 00, 00, 0x28, 00, 00, 00,
- 01, 00, 00, 00, 0x30, 00, 0x26, 01,
- 00, 00, 00, 00,
-
- 0x4D, 00, 0x69, 00,
- 0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00,
- 0x6F, 00, 0x66, 00, 0x74, 00, 0x20, 00,
- 0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00,
- 0x20, 00, 0x43, 00, 0x72, 00, 0x79, 00,
- 0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00,
- 0x72, 00, 0x61, 00, 0x70, 00, 0x68, 00,
- 0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00,
- 0x72, 00, 0x6F, 00, 0x76, 00, 0x69, 00,
- 0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00,
- 0x76, 00, 0x31, 00, 0x2E, 00, 0x30, 00,
- 0x00, 0x00,
-
- 0x10, 00, 0x00, 00,
- 0x62, 0xA6-256,
- 0xDF-256, 0xEA-256, 0x96-256, 0x84-256,
- 0xFB-256, 0x89-256, 0x93-256, 0xCA-256,
- 0xBA-256, 0xEE-256, 0x8E-256, 0x43,
- 0xC8-256, 0x71, 0xD1-256, 0x89-256,
- 0xF6-256, 0x4B, 0x2B, 0xD9-256,
- 0x7E, 0x0B, 0x52, 0xFB-256,
- 0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00,
- 0x00, 0x00, 0x93-256, 0x15, 0x27, 0xEB-256, 0x21, 0x54,
- 0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F,
- 0xB2-256, 0x8E-256, 0x67, 0x54, 0x07, 0x04, 0x00
- };
-
- private final byte[] data_b = new byte[] {
- 15, 0, 20, 47, -66, 0, 0, 0,
- 2, 0, 2, 0, 4,
- 0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
- 0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0,
- 1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0,
- 105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111,
- 0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115,
- 0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112,
- 0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0,
- 112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0,
- 114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101,
- 0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48,
- 0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57,
- 110, 54, 80, 64, 61, -73, -29, 48, -35, -20,
- 17, -40, 84, 54, 6, -103, 125, -22, -72, 53,
- 103, -114, 13, -48, 111, 29, 78, 20, 0, 0,
- 0, -97, -67, 55, -62, -94, 14, 15, -21, 37,
- 3, -104, 22, 6, 102, -61, -98, 62, 40, 61, 21
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0x0F, 00, 0x14, 0x2F, 0xBE-256, 00, 00, 00,
+ 02, 00, 02, 00, 0x0C, 00, 00, 00,
+ 0x76, 00, 00, 00, 0x0C, 00, 00, 00,
+ 00, 00, 00, 00, 01, 0x68, 00, 00,
+ 04, 0x80-256, 00, 00, 0x28, 00, 00, 00,
+ 01, 00, 00, 00, 0x30, 00, 0x26, 01,
+ 00, 00, 00, 00,
+
+ 0x4D, 00, 0x69, 00,
+ 0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00,
+ 0x6F, 00, 0x66, 00, 0x74, 00, 0x20, 00,
+ 0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00,
+ 0x20, 00, 0x43, 00, 0x72, 00, 0x79, 00,
+ 0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00,
+ 0x72, 00, 0x61, 00, 0x70, 00, 0x68, 00,
+ 0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00,
+ 0x72, 00, 0x6F, 00, 0x76, 00, 0x69, 00,
+ 0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00,
+ 0x76, 00, 0x31, 00, 0x2E, 00, 0x30, 00,
+ 0x00, 0x00,
+
+ 0x10, 00, 0x00, 00,
+ 0x62, 0xA6-256,
+ 0xDF-256, 0xEA-256, 0x96-256, 0x84-256,
+ 0xFB-256, 0x89-256, 0x93-256, 0xCA-256,
+ 0xBA-256, 0xEE-256, 0x8E-256, 0x43,
+ 0xC8-256, 0x71, 0xD1-256, 0x89-256,
+ 0xF6-256, 0x4B, 0x2B, 0xD9-256,
+ 0x7E, 0x0B, 0x52, 0xFB-256,
+ 0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00,
+ 0x00, 0x00, 0x93-256, 0x15, 0x27, 0xEB-256, 0x21, 0x54,
+ 0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F,
+ 0xB2-256, 0x8E-256, 0x67, 0x54, 0x07, 0x04, 0x00
+ };
+
+ private final byte[] data_b = new byte[] {
+ 15, 0, 20, 47, -66, 0, 0, 0,
+ 2, 0, 2, 0, 4,
+ 0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
+ 0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0,
+ 1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0,
+ 105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111,
+ 0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115,
+ 0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112,
+ 0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0,
+ 112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0,
+ 114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101,
+ 0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48,
+ 0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57,
+ 110, 54, 80, 64, 61, -73, -29, 48, -35, -20,
+ 17, -40, 84, 54, 6, -103, 125, -22, -72, 53,
+ 103, -114, 13, -48, 111, 29, 78, 20, 0, 0,
+ 0, -97, -67, 55, -62, -94, 14, 15, -21, 37,
+ 3, -104, 22, 6, 102, -61, -98, 62, 40, 61, 21
+ };
- @Test
+ @Test
void recordType() throws IOException {
- DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
- assertEquals(12052l, dea1.getRecordType());
+ DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
+ assertEquals(12052l, dea1.getRecordType());
- DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
- assertEquals(12052l, dea2.getRecordType());
+ DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
+ assertEquals(12052l, dea2.getRecordType());
- assertEquals(199, data_a.length);
- assertEquals(198, data_b.length);
- }
+ assertEquals(199, data_a.length);
+ assertEquals(198, data_b.length);
+ }
- @Test
+ @Test
void encryptionTypeName() throws IOException {
- DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
- assertEquals("Microsoft Base Cryptographic Provider v1.0", dea1.getEncryptionProviderName());
+ DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
+ assertEquals("Microsoft Base Cryptographic Provider v1.0", dea1.getEncryptionProviderName());
- DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
- assertEquals("Microsoft Base Cryptographic Provider v1.0", dea2.getEncryptionProviderName());
+ DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
+ assertEquals("Microsoft Base Cryptographic Provider v1.0", dea2.getEncryptionProviderName());
}
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExControl.java Sat May 22 21:37:08 2021
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
*/
public final class TestExControl {
- // From a real file (embedded SWF control)
+ // From a real file (embedded SWF control)
/*
<ExControl info="15" type="4078" size="218" offset="76" header="0F 00 EE 0F DA 00 00 00 ">
<ExControlAtom info="0" type="4091" size="4" offset="84" header="00 00 FB 0F 04 00 00 00 ">
@@ -70,53 +70,53 @@ public final class TestExControl {
0x65, 0x00, 0x63, 0x00, 0x74, 0x00
};
- @Test
- void testRead() {
- ExControl record = new ExControl(data, 0, data.length);
- assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
-
- assertNotNull(record.getExControlAtom());
- assertEquals(256, record.getExControlAtom().getSlideId());
-
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- assertNotNull(oleObj);
- assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
- assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
-
- assertEquals("Shockwave Flash Object", record.getMenuName());
- assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
- assertEquals("Shockwave Flash Object", record.getClipboardName());
- }
-
- @Test
- void testWrite() throws Exception {
- ExControl record = new ExControl(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
-
- @Test
- void testNewRecord() throws Exception {
- ExControl record = new ExControl();
- ExControlAtom ctrl = record.getExControlAtom();
- ctrl.setSlideId(256);
-
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
- oleObj.setObjID(1);
- oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
- oleObj.setObjStgDataRef(2);
- oleObj.setOptions(1283584);
-
- record.setMenuName("Shockwave Flash Object");
- record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
- record.setClipboardName("Shockwave Flash Object");
-
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- assertArrayEquals(data, baos.toByteArray());
- }
+ @Test
+ void testRead() {
+ ExControl record = new ExControl(data, 0, data.length);
+ assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
+
+ assertNotNull(record.getExControlAtom());
+ assertEquals(256, record.getExControlAtom().getSlideId());
+
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ assertNotNull(oleObj);
+ assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
+ assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+
+ assertEquals("Shockwave Flash Object", record.getMenuName());
+ assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
+ assertEquals("Shockwave Flash Object", record.getClipboardName());
+ }
+
+ @Test
+ void testWrite() throws Exception {
+ ExControl record = new ExControl(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
+
+ @Test
+ void testNewRecord() throws Exception {
+ ExControl record = new ExControl();
+ ExControlAtom ctrl = record.getExControlAtom();
+ ctrl.setSlideId(256);
+
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+ oleObj.setObjID(1);
+ oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+ oleObj.setObjStgDataRef(2);
+ oleObj.setOptions(1283584);
+
+ record.setMenuName("Shockwave Flash Object");
+ record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
+ record.setClipboardName("Shockwave Flash Object");
+
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ assertArrayEquals(data, baos.toByteArray());
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlink.java Sat May 22 21:37:08 2021
@@ -36,17 +36,17 @@ import org.junit.jupiter.api.Test;
* Tests that ExHyperlink works properly.
*/
public final class TestExHyperlink {
- @Test
+ @Test
void testReadWrite() throws IOException {
// From a real file
byte[] exHyperlinkBytes = org.apache.poi.poifs.storage.RawDataUtil.decompress(
"H4sIAAAAAAAAAONnuM6/ggEELvOzAElmMHsXvxuQzGAoAcICBisGfSDMYkhkyAbi"+
"IqBYIoMeEBcAcTJQVSqQlw8UTweqKgCyMoF0BkMxEKYBWQJUNQ0A/k1x3rAAAAA="
);
- ExHyperlink exHyperlink = new ExHyperlink(exHyperlinkBytes, 0, exHyperlinkBytes.length);
+ ExHyperlink exHyperlink = new ExHyperlink(exHyperlinkBytes, 0, exHyperlinkBytes.length);
- assertEquals(4055L, exHyperlink.getRecordType());
+ assertEquals(4055L, exHyperlink.getRecordType());
assertEquals(3, exHyperlink.getExHyperlinkAtom().getNumber());
String expURL = "http://jakarta.apache.org/poi/hssf/";
assertEquals(expURL, exHyperlink.getLinkURL());
@@ -56,56 +56,56 @@ public final class TestExHyperlink {
UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
exHyperlink.writeOut(baos);
assertArrayEquals(exHyperlinkBytes, baos.toByteArray());
- }
+ }
- @Test
- void testRealFile() throws IOException {
+ @Test
+ void testRealFile() throws IOException {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
- HSLFSlideShow ss = new HSLFSlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
- // Get the document
- Document doc = ss.getDocumentRecord();
- // Get the ExObjList
- ExObjList exObjList = null;
- for (final Record rec : doc._children) {
- if(rec instanceof ExObjList) {
- exObjList = (ExObjList)rec;
- }
- }
-
- assertNotNull(exObjList);
-
- // Within that, grab out the Hyperlink atoms
- List<ExHyperlink> linksA = new ArrayList<>();
- for (Record ch : exObjList._children) {
- if(ch instanceof ExHyperlink) {
- linksA.add((ExHyperlink) ch);
- }
- }
-
- // Should be 4 of them
- assertEquals(4, linksA.size());
- ExHyperlink[] links = new ExHyperlink[linksA.size()];
- linksA.toArray(links);
-
- assertEquals(4, exObjList.getExHyperlinks().length);
-
- // Check the other way
-
- // Check they have what we expect in them
- assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
-
- assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
- assertEquals("http://slashdot.org/", links[1].getLinkURL());
+ // Get the document
+ Document doc = ss.getDocumentRecord();
+ // Get the ExObjList
+ ExObjList exObjList = null;
+ for (final Record rec : doc._children) {
+ if(rec instanceof ExObjList) {
+ exObjList = (ExObjList)rec;
+ }
+ }
+
+ assertNotNull(exObjList);
+
+ // Within that, grab out the Hyperlink atoms
+ List<ExHyperlink> linksA = new ArrayList<>();
+ for (Record ch : exObjList._children) {
+ if(ch instanceof ExHyperlink) {
+ linksA.add((ExHyperlink) ch);
+ }
+ }
+
+ // Should be 4 of them
+ assertEquals(4, linksA.size());
+ ExHyperlink[] links = new ExHyperlink[linksA.size()];
+ linksA.toArray(links);
+
+ assertEquals(4, exObjList.getExHyperlinks().length);
+
+ // Check the other way
+
+ // Check they have what we expect in them
+ assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+
+ assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+ assertEquals("http://slashdot.org/", links[1].getLinkURL());
- assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+ assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
- assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+ assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
- ss.close();
- }
+ ss.close();
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExHyperlinkAtom.java Sat May 22 21:37:08 2021
@@ -28,64 +28,64 @@ import org.junit.jupiter.api.Test;
* Tests that ExHyperlinkAtom works properly.
*/
public class TestExHyperlinkAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
- 1, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
- 4, 0, 0, 0
- };
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 1, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 4, 0, 0, 0
+ };
- @Test
+ @Test
void testRecordType() {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- assertEquals(4051L, eha.getRecordType());
- }
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ assertEquals(4051L, eha.getRecordType());
+ }
- @Test
+ @Test
void testGetNumber() {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
+
+ assertEquals(1, eha.getNumber());
+ assertEquals(4, ehb.getNumber());
+ }
- assertEquals(1, eha.getNumber());
- assertEquals(4, ehb.getNumber());
+ @Test
+ void testWrite() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
}
- @Test
- void testWrite() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
-
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom();
-
- // Set value
- eha.setNumber(1);
-
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
-
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
-
- // Change the number
- eha.setNumber(4);
-
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eha.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom();
+
+ // Set value
+ eha.setNumber(1);
+
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
+
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+
+ // Change the number
+ eha.setNumber(4);
+
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eha.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExMediaAtom.java Sat May 22 21:37:08 2021
@@ -30,68 +30,68 @@ import org.junit.jupiter.api.Test;
* Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
*/
public final class TestExMediaAtom {
- // From a real file
- private static final byte[] data = {
- 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 0,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- @Test
- void testRead() {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
-
- assertEquals(1, record.getObjectId());
- assertFalse(record.getFlag(ExMediaAtom.fLoop));
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
- assertFalse(record.getFlag(ExMediaAtom.fRewind));
- }
-
- @Test
- void testWrite() throws Exception {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
- }
-
- @Test
- void testNewRecord() throws Exception {
- ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
- assertEquals(0, ref.getMask()); //
-
- ExMediaAtom record = new ExMediaAtom();
- record.setObjectId(1);
- record.setFlag(HeadersFootersAtom.fHasDate, false);
- record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- record.setFlag(HeadersFootersAtom.fHasFooter, false);
-
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
- }
-
- @Test
- void testFlags() {
- ExMediaAtom record = new ExMediaAtom();
-
- //in a new record all the bits are 0
- for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
-
- record.setFlag(ExMediaAtom.fLoop, true);
- assertTrue(record.getFlag(ExMediaAtom.fLoop));
-
- record.setFlag(ExMediaAtom.fNarration, true);
- assertTrue(record.getFlag(ExMediaAtom.fNarration));
+ // From a real file
+ private static final byte[] data = {
+ 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 0,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ @Test
+ void testRead() {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
+
+ assertEquals(1, record.getObjectId());
+ assertFalse(record.getFlag(ExMediaAtom.fLoop));
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ assertFalse(record.getFlag(ExMediaAtom.fRewind));
+ }
+
+ @Test
+ void testWrite() throws Exception {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertArrayEquals(data, b);
+ }
+
+ @Test
+ void testNewRecord() throws Exception {
+ ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
+ assertEquals(0, ref.getMask()); //
+
+ ExMediaAtom record = new ExMediaAtom();
+ record.setObjectId(1);
+ record.setFlag(HeadersFootersAtom.fHasDate, false);
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ record.setFlag(HeadersFootersAtom.fHasFooter, false);
+
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertArrayEquals(data, b);
+ }
+
+ @Test
+ void testFlags() {
+ ExMediaAtom record = new ExMediaAtom();
+
+ //in a new record all the bits are 0
+ for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
+
+ record.setFlag(ExMediaAtom.fLoop, true);
+ assertTrue(record.getFlag(ExMediaAtom.fLoop));
+
+ record.setFlag(ExMediaAtom.fNarration, true);
+ assertTrue(record.getFlag(ExMediaAtom.fNarration));
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
- }
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java Sat May 22 21:37:08 2021
@@ -32,38 +32,38 @@ public class TestExObjList {
@Test
void testRealFile() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow ss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
- // Get the document
- Document doc = ss.getDocumentRecord();
- // Get the ExObjList
- ExObjList exObjList = doc.getExObjList(false);
- assertNotNull(exObjList);
- assertEquals(1033l, exObjList.getRecordType());
+ // Get the document
+ Document doc = ss.getDocumentRecord();
+ // Get the ExObjList
+ ExObjList exObjList = doc.getExObjList(false);
+ assertNotNull(exObjList);
+ assertEquals(1033l, exObjList.getRecordType());
- // Check the atom
- assertNotNull(exObjList.getExObjListAtom());
- assertEquals(4, exObjList.getExObjListAtom().getObjectIDSeed());
+ // Check the atom
+ assertNotNull(exObjList.getExObjListAtom());
+ assertEquals(4, exObjList.getExObjListAtom().getObjectIDSeed());
- // Check the Hyperlinks
- assertEquals(4, exObjList.getExHyperlinks().length);
+ // Check the Hyperlinks
+ assertEquals(4, exObjList.getExHyperlinks().length);
- // Check the contents
- ExHyperlink[] links = exObjList.getExHyperlinks();
+ // Check the contents
+ ExHyperlink[] links = exObjList.getExHyperlinks();
- // Check they have what we expect in them
- assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+ // Check they have what we expect in them
+ assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
- assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
- assertEquals("http://slashdot.org/", links[1].getLinkURL());
+ assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+ assertEquals("http://slashdot.org/", links[1].getLinkURL());
- assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+ assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
- assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
- assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+ assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+ assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
- ss.close();
- }
+ ss.close();
+ }
}
Modified: poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java?rev=1890122&r1=1890121&r2=1890122&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjListAtom.java Sat May 22 21:37:08 2021
@@ -28,64 +28,64 @@ import org.junit.jupiter.api.Test;
* Tests that ExObjListAtom works properly.
*/
public class TestExObjListAtom {
- // From a real file
- private final byte[] data_a = new byte[] {
- 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
- 1, 0, 0, 0
- };
- private final byte[] data_b = new byte[] {
- 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
- 4, 0, 0, 0
- };
-
- @Test
- void testRecordType() {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- BaseTestNumeric.assertDouble(1034L, eoa.getRecordType());
- }
-
- @Test
- void testGetSeed() {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
-
- BaseTestNumeric.assertDouble(1, eoa.getObjectIDSeed());
- BaseTestNumeric.assertDouble(4, eob.getObjectIDSeed());
- }
-
- @Test
- void testWrite() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
-
- // Create A from scratch
- @Test
- void testCreate() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom();
-
- // Set seed
- eoa.setObjectIDSeed(1);
-
- // Check it's now the same as a
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_a, baos.toByteArray());
- }
-
- // Try to turn a into b
- @Test
- void testChange() throws Exception {
- ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
-
- // Change the number
- eoa.setObjectIDSeed(4);
-
- // Check bytes are now the same
- UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
- eoa.writeOut(baos);
- assertArrayEquals(data_b, baos.toByteArray());
- }
+ // From a real file
+ private final byte[] data_a = new byte[] {
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 1, 0, 0, 0
+ };
+ private final byte[] data_b = new byte[] {
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 4, 0, 0, 0
+ };
+
+ @Test
+ void testRecordType() {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ BaseTestNumeric.assertDouble(1034L, eoa.getRecordType());
+ }
+
+ @Test
+ void testGetSeed() {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
+
+ BaseTestNumeric.assertDouble(1, eoa.getObjectIDSeed());
+ BaseTestNumeric.assertDouble(4, eob.getObjectIDSeed());
+ }
+
+ @Test
+ void testWrite() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
+
+ // Create A from scratch
+ @Test
+ void testCreate() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom();
+
+ // Set seed
+ eoa.setObjectIDSeed(1);
+
+ // Check it's now the same as a
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_a, baos.toByteArray());
+ }
+
+ // Try to turn a into b
+ @Test
+ void testChange() throws Exception {
+ ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+
+ // Change the number
+ eoa.setObjectIDSeed(4);
+
+ // Check bytes are now the same
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+ eoa.writeOut(baos);
+ assertArrayEquals(data_b, baos.toByteArray());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org