You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/12/27 23:00:20 UTC
svn commit: r1872041 [4/23] - in /poi/trunk/src:
excelant/testcases/org/apache/poi/ss/examples/formula/
excelant/testcases/org/apache/poi/ss/excelant/
excelant/testcases/org/apache/poi/ss/excelant/util/
java/org/apache/poi/hssf/record/aggregates/ java/...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java Fri Dec 27 23:00:13 2019
@@ -17,12 +17,15 @@
package org.apache.poi.hdgf;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayInputStream;
-import junit.framework.TestCase;
+import org.junit.Ignore;
+import org.junit.Test;
-public final class TestHDGFLZW extends TestCase {
- public static final byte[] testTrailerComp = new byte[] {
+public final class TestHDGFLZW {
+ public static final byte[] testTrailerComp = {
123, // *mask bit*
-60, 2,
-21, -16, // 3 @ 4093
@@ -38,7 +41,7 @@ public final class TestHDGFLZW extends T
21, // *mask bit* 1,3,5
9,
-21, -16, // 3 @ 4093
- 103,
+ 103,
-21, -16, // 3 @ 4093
34,
-36, -1, // 18 @ 4078
@@ -72,7 +75,7 @@ public final class TestHDGFLZW extends T
1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
85, 1, 102, -119, 72, 37, 0, 97, 33 };
- public static final byte[] testTrailerDecomp = new byte[] {
+ public static final byte[] testTrailerDecomp = {
-60, 2, 0, 0, 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -108,6 +111,7 @@ public final class TestHDGFLZW extends T
0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
};
+ @Test
public void testFromToInt() {
byte b255 = -1;
assertEquals(255, HDGFLZW.fromByte(b255));
@@ -135,6 +139,7 @@ public final class TestHDGFLZW extends T
assertEquals(-128, HDGFLZW.fromInt( 128 ));
}
+ @Test
public void testCounts() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
@@ -155,6 +160,7 @@ public final class TestHDGFLZW extends T
*/
}
+ @Test
public void testDecompress() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
@@ -176,6 +182,7 @@ public final class TestHDGFLZW extends T
* Uses a part short enough that we agree with visio
* on the best way to compress it
*/
+ @Test
public void testCompressMini() throws Exception {
// first 11 bytes compressed = 12 bytes uncompressed
byte[] sourceComp = new byte[11];
@@ -186,7 +193,7 @@ public final class TestHDGFLZW extends T
// Compress it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] comp = lzw.compress(new ByteArrayInputStream(sourceDecomp));
-
+
// Now decompress it again
byte[] decomp = lzw.decompress(new ByteArrayInputStream(comp));
@@ -206,6 +213,7 @@ public final class TestHDGFLZW extends T
/**
* Tests that we can do several mask pages
*/
+ @Test
public void testCompressMidi() throws Exception {
// First 12 -> 11
// Next 32 -> 13
@@ -217,11 +225,11 @@ public final class TestHDGFLZW extends T
// Compress it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] comp = lzw.compress(new ByteArrayInputStream(sourceDecomp));
-
+
// We should be 3 characters bigger, as
// we split one compressed bit into two
assertEquals(27, comp.length);
-
+
// Now decompress it again
byte[] decomp = lzw.decompress(new ByteArrayInputStream(comp));
@@ -237,28 +245,30 @@ public final class TestHDGFLZW extends T
* Gets 160 bytes through then starts going wrong...
* TODO Fix this
*/
- public void DISABLEDtestCompressFull() throws Exception {
+ @Test
+ @Ignore
+ public void testCompressFull() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
// Compress it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
-
+
// Now decompress it again
byte[] decomp = lzw.decompress(new ByteArrayInputStream(comp));
// for(int i=0; i<comp.length; i++) {
// System.err.println(i + "\t" + comp[i] + "\t" + testTrailerComp[i]);
// }
-
+
// First up, check the round tripping
// assertEquals(632, decomp.length);
for(int i=0; i<decomp.length; i++) {
assertEquals("Wrong at " + i, decomp[i], testTrailerDecomp[i]);
}
-
+
// Now check the compressed intermediate version
assertEquals(339, comp.length);
for(int i=0; i<comp.length; i++) {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java Fri Dec 27 23:00:13 2019
@@ -17,48 +17,49 @@
package org.apache.poi.hdgf.pointers;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
/**
* Tests for the pointer factory, and the pointers themselves
*/
-public final class TestPointerFactory extends TestCase {
+public final class TestPointerFactory {
// Type: 14 Addr: 011eb2ac Offset: 1dd4 Len: 14d Format: 52 From: 24
- private static byte[] vp5_a = new byte[] {
+ private static byte[] vp5_a = {
0x14, 0, 0x52, 0, (byte)0xac, (byte)0xb2, 0x1e, 1, (byte)0xd4, 0x1d, 0, 0,
0x4d, 1, 0, 0
};
-
+
// Type: 16 Addr: 0143aff4 Offset: 80 Len: 54 Format: 46 From: 8a94
- private static byte[] vp6_a = new byte[] {
+ private static byte[] vp6_a = {
22, 0, 0, 0, -12, -81, 67, 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0
};
// Type: 17 Addr: 014fd84c Offset: d4 Len: 20 Format: 54 From: 8a94
- private static byte[] vp6_b = new byte[] {
+ private static byte[] vp6_b = {
23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
};
// Type: 17 Addr: 014fd8bc Offset: f8 Len: 20 Format: 54 From: 8a94
- private static byte[] vp6_c = new byte[] {
+ private static byte[] vp6_c = {
23, 0, 0, 0, -68, -40, 79, 1, -8, 0, 0, 0, 32, 0, 0, 0, 84, 0
};
// Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
- private static byte[] vp6_d = new byte[] {
+ private static byte[] vp6_d = {
-1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
};
+ @Test(expected = IllegalArgumentException.class)
public void testCreateV4() {
PointerFactory pf = new PointerFactory(4);
- try {
- pf.createPointer(new byte[]{}, 0);
- fail();
- } catch(IllegalArgumentException e) {
- // As expected
- }
+ pf.createPointer(new byte[]{}, 0);
}
+ @Test
public void testCreateV5() {
PointerFactory pf = new PointerFactory(5);
-
+
Pointer a = pf.createPointer(vp5_a, 0);
assertEquals(0x14, a.getType());
assertEquals(0x011eb2ac, a.getAddress());
@@ -75,6 +76,7 @@ public final class TestPointerFactory ex
assertEquals(16, a.getSizeInBytes());
}
+ @Test
public void testCreateV6() {
PointerFactory pf = new PointerFactory(6);
@@ -131,6 +133,7 @@ public final class TestPointerFactory ex
assertFalse(d.destinationHasPointers());
}
+ @Test
public void testCreateV6FromMid() {
PointerFactory pf = new PointerFactory(11);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java Fri Dec 27 23:00:13 2019
@@ -18,27 +18,33 @@
package org.apache.poi.hslf;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.record.Notes;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.Slide;
+import org.apache.poi.hslf.record.SlideListWithText;
+import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests that HSLFSlideShow returns the right numbers of key records when
* it parses the test file
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestRecordCounts extends TestCase {
+public final class TestRecordCounts {
+
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
// HSLFSlideShow primed on the test data
- private final HSLFSlideShowImpl ss;
+ private HSLFSlideShowImpl ss;
- public TestRecordCounts() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ @Before
+ public void setup() throws Exception {
ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
}
+ @Test
public void testSheetsCount() {
// Top level
Record[] r = ss.getRecords();
@@ -53,13 +59,14 @@ public final class TestRecordCounts exte
assertEquals(3,count);
}
+ @Test
public void testNotesCount() {
// Top level
Record[] r = ss.getRecords();
int count = 0;
for (final Record rec : r) {
- if (rec instanceof Notes && rec.getRecordType() == 1008l) {
+ if (rec instanceof Notes && rec.getRecordType() == 1008L) {
count++;
}
}
@@ -67,6 +74,7 @@ public final class TestRecordCounts exte
assertEquals(3,count);
}
+ @Test
public void testSlideListWithTextCount() {
// Second level
Record[] rt = ss.getRecords();
@@ -74,7 +82,7 @@ public final class TestRecordCounts exte
int count = 0;
for (final Record rec : r) {
- if (rec instanceof SlideListWithText && rec.getRecordType() == 4080l) {
+ if (rec instanceof SlideListWithText && rec.getRecordType() == 4080L) {
count++;
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java Fri Dec 27 23:00:13 2019
@@ -18,21 +18,24 @@
package org.apache.poi.hslf.extractor;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.util.List;
import org.apache.poi.POIDataSamples;
import org.apache.poi.util.StringUtil;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests that the QuickButCruddyTextExtractor works correctly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestCruddyExtractor extends TestCase {
+public final class TestCruddyExtractor {
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+
// Extractor primed on the test data
- private final QuickButCruddyTextExtractor te;
+ private QuickButCruddyTextExtractor te;
+
// All the text to be found in the file
String[] allTheText = new String[] {
"This is a test title",
@@ -59,11 +62,12 @@ public final class TestCruddyExtractor e
"This is page two\nIt has several blocks of text\nNone of them have formatting",
};
- public TestCruddyExtractor() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ @Before
+ public void setup() throws Exception {
te = new QuickButCruddyTextExtractor(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
}
+ @Test
public void testReadAsVector() {
// Extract the text from the file as a vector
List<String> foundTextV = te.getTextAsVector();
@@ -76,6 +80,7 @@ public final class TestCruddyExtractor e
}
}
+ @Test
public void testReadAsString() {
// Extract the text as a String
String foundText = te.getTextAsString();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java Fri Dec 27 23:00:13 2019
@@ -19,17 +19,18 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestAnimationInfoAtom extends TestCase {
+public final class TestAnimationInfoAtom {
// From a real file
/*
<AnimationInfoAtom info="1" type="4081" size="28" offset="4015" header="01 00 F1 0F 1C 00 00 00 ">
@@ -37,12 +38,13 @@ public final class TestAnimationInfoAtom
00 00 00
</AnimationInfoAtom>
*/
- private final byte[] data = new byte[] {
+ private final byte[] data = {
0x01, 0x00, (byte)0xF1, 0x0F, 0x1C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
+ @Test
public void testRead() {
AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
assertEquals(RecordTypes.AnimationInfoAtom.typeID, record.getRecordType());
@@ -61,6 +63,7 @@ public final class TestAnimationInfoAtom
assertEquals(0, record.getSlideCount());
}
+ @Test
public void testWrite() throws Exception {
AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -70,6 +73,7 @@ public final class TestAnimationInfoAtom
assertArrayEquals(data, b);
}
+ @Test
public void testNewRecord() throws Exception {
AnimationInfoAtom record = new AnimationInfoAtom();
record.setDimColor(0x07000000);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java Fri Dec 27 23:00:13 2019
@@ -18,29 +18,34 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that CString works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestCString extends TestCase {
+public final class TestCString {
// From a real file
- private final byte[] data_a = new byte[] { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
- 0x48, 00, 0x6F, 00, 0x67, 00, 0x77, 00,
- 0x61, 00, 0x72, 00, 0x74, 00, 0x73, 00 };
+ 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, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00,
- 0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00 };
+ 0x43, 0, 0x6F, 0, 0x6D, 0, 0x6D, 0,
+ 0x65, 0, 0x6E, 0, 0x74, 0, 0x73, 0 };
+ @Test
public void testRecordType() {
CString ca = new CString(data_a, 0, data_a.length);
- assertEquals(4026l, ca.getRecordType());
+ assertEquals(4026L, ca.getRecordType());
CString cb = new CString(data_b, 0, data_a.length);
- assertEquals(4026l, cb.getRecordType());
+ assertEquals(4026L, cb.getRecordType());
}
+
+ @Test
public void testCount() {
CString ca = new CString(data_a, 0, data_a.length);
assertEquals(0, ca.getOptions());
@@ -51,6 +56,7 @@ public final class TestCString extends T
assertEquals(28, ca.getOptions());
}
+ @Test
public void testText() {
CString ca = new CString(data_a, 0, data_a.length);
assertEquals("Hogwarts", ca.getText());
@@ -61,6 +67,7 @@ public final class TestCString extends T
assertEquals("FooBar", ca.getText());
}
+ @Test
public void testWrite() throws Exception {
CString ca = new CString(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -84,6 +91,7 @@ public final class TestCString extends T
}
// Turn data_a into data_b
+ @Test
public void testChange() throws Exception {
CString ca = new CString(data_a, 0, data_a.length);
ca.setText("Comments");
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java Fri Dec 27 23:00:13 2019
@@ -18,28 +18,31 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that ColorSchemAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestColorSchemeAtom extends TestCase {
+public final class TestColorSchemeAtom {
// From a real file
- private final byte[] data_a = new byte[] { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0,
- 0xFF-256, 0xFF-256, 0xFF-256, 00, 00, 00, 00, 00,
- 0x80-256, 0x80-256, 0x80-256, 00, 00, 00, 00, 00,
- 0xBB-256, 0xE0-256, 0xE3-256, 00, 0x33, 0x33, 0x99-256, 00,
- 00, 0x99-256, 0x99-256, 00, 0x99-256, 0xCC-256, 00, 00
+ 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
public void testRecordType() {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
- assertEquals(2032l, csa.getRecordType());
+ assertEquals(2032L, csa.getRecordType());
}
+ @Test
public void testToRGB() {
byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
@@ -49,6 +52,7 @@ public final class TestColorSchemeAtom e
assertEquals(55, rgb[2]);
}
+ @Test
public void testFromRGB() {
byte[] rgb_a = new byte[] { 0, 255-256, 55 };
byte[] rgb_b = new byte[] { 255-256, 127, 79 };
@@ -60,6 +64,7 @@ public final class TestColorSchemeAtom e
assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
}
+ @Test
public void testRGBs() {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
@@ -73,6 +78,7 @@ public final class TestColorSchemeAtom e
assertEquals( 52377 , csa.getAccentAndFollowingHyperlinkColourRGB() );
}
+ @Test
public void testWrite() throws Exception {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java Fri Dec 27 23:00:13 2019
@@ -17,25 +17,28 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
-import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests that Document works properly (Also tests Environment while we're at it)
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestDocument extends TestCase {
+public final class TestDocument {
+ private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+
// HSLFSlideShow primed on the test data
- private final HSLFSlideShowImpl ss;
+ private HSLFSlideShowImpl ss;
// POIFS primed on the test data
- private final POIFSFileSystem pfs;
+ private POIFSFileSystem pfs;
- public TestDocument() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ @Before
+ public void setup() throws Exception {
pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShowImpl(pfs);
}
@@ -50,11 +53,13 @@ public final class TestDocument extends
throw new IllegalStateException("No Document record found");
}
+ @Test
public void testRecordType() {
Document dr = getDocRecord();
assertEquals(1000, dr.getRecordType());
}
+ @Test
public void testChildRecords() {
Document dr = getDocRecord();
assertNotNull(dr.getDocumentAtom());
@@ -68,6 +73,7 @@ public final class TestDocument extends
assertNotNull(dr.getSlideListWithTexts()[2]);
}
+ @Test
public void testEnvironment() {
Document dr = getDocRecord();
Environment env = dr.getEnvironment();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java Fri Dec 27 23:00:13 2019
@@ -18,46 +18,59 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that DocumentAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestDocumentAtom extends TestCase {
+public final class TestDocumentAtom {
// From a real file
- private final byte[] data_a = new byte[] { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
+ 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
public void testRecordType() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(1001l, da.getRecordType());
}
+
+ @Test
public 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(5760L, da.getSlideSizeX());
+ assertEquals(4320L, da.getSlideSizeY());
+ assertEquals(4320L, da.getNotesSizeX());
+ assertEquals(5760L, da.getNotesSizeY());
- assertEquals(5l, da.getServerZoomFrom());
- assertEquals(10l, da.getServerZoomTo());
+ assertEquals(5L, da.getServerZoomFrom());
+ assertEquals(10L, da.getServerZoomTo());
}
+
+ @Test
public void testMasterPersist() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
- assertEquals(2l, da.getNotesMasterPersist());
- assertEquals(0l, da.getHandoutMasterPersist());
+ assertEquals(2L, da.getNotesMasterPersist());
+ assertEquals(0L, da.getHandoutMasterPersist());
}
+
+ @Test
public void testSlideDetails() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(1, da.getFirstSlideNum());
assertEquals(0, da.getSlideSizeType());
}
+
+ @Test
public void testBooleans() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertFalse(da.getSaveWithFonts());
@@ -66,15 +79,11 @@ public final class TestDocumentAtom exte
assertTrue(da.getShowComments());
}
+ @Test
public void testWrite() throws Exception {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
da.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java Fri Dec 27 23:00:13 2019
@@ -19,17 +19,17 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link org.apache.poi.hslf.record.ExControl} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestExControl extends TestCase {
+public final class TestExControl {
// From a real file (embedded SWF control)
/*
@@ -55,7 +55,7 @@ public final class TestExControl extends
</CString>
</ExControl>
*/
- private final byte[] data = new byte[] {
+ private final byte[] data = {
0x0F, 0x00, (byte)0xEE, 0x0F, (byte)0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFB, 0x0F, 0x04, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00,
@@ -71,6 +71,7 @@ public final class TestExControl extends
0x65, 0x00, 0x63, 0x00, 0x74, 0x00
};
+ @Test
public void testRead() {
ExControl record = new ExControl(data, 0, data.length);
assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
@@ -89,15 +90,15 @@ public final class TestExControl extends
assertEquals("Shockwave Flash Object", record.getClipboardName());
}
+ @Test
public void testWrite() throws Exception {
ExControl record = new ExControl(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testNewRecord() throws Exception {
ExControl record = new ExControl();
ExControlAtom ctrl = record.getExControlAtom();
@@ -117,9 +118,6 @@ public final class TestExControl extends
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data.length, b.length);
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlinkAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlinkAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlinkAtom.java Fri Dec 27 23:00:13 2019
@@ -18,30 +18,34 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that ExHyperlinkAtom works properly.
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public class TestExHyperlinkAtom extends TestCase {
+public class TestExHyperlinkAtom {
// From a real file
private final byte[] data_a = new byte[] {
- 00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00,
- 01, 00, 00, 00
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 1, 0, 0, 0
};
private final byte[] data_b = new byte[] {
- 00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00,
- 04, 00, 00, 00
+ 0, 0, 0xD3-256, 0x0F, 4, 0, 0, 0,
+ 4, 0, 0, 0
};
+ @Test
public void testRecordType() {
ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
- assertEquals(4051l, eha.getRecordType());
+ assertEquals(4051L, eha.getRecordType());
}
+ @Test
public void testGetNumber() {
ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
@@ -50,19 +54,16 @@ public class TestExHyperlinkAtom extends
assertEquals(4, ehb.getNumber());
}
+ @Test
public void testWrite() throws Exception {
ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eha.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Create A from scratch
+ @Test
public void testCreate() throws Exception {
ExHyperlinkAtom eha = new ExHyperlinkAtom();
@@ -72,15 +73,11 @@ public class TestExHyperlinkAtom extends
// Check it's now the same as a
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eha.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Try to turn a into b
+ @Test
public void testChange() throws Exception {
ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
@@ -90,12 +87,6 @@ public class TestExHyperlinkAtom extends
// Check bytes are now the same
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eha.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Should now be the same
- assertEquals(data_b.length, b.length);
- for(int i=0; i<data_b.length; i++) {
- assertEquals(data_b[i],b[i]);
- }
+ assertArrayEquals(data_b, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java Fri Dec 27 23:00:13 2019
@@ -19,22 +19,24 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestExMediaAtom extends TestCase {
+public final class TestExMediaAtom {
// From a real file
private static final byte[] data = {
- 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 00,
+ 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ @Test
public void testRead() {
ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
@@ -45,6 +47,7 @@ public final class TestExMediaAtom exten
assertFalse(record.getFlag(ExMediaAtom.fRewind));
}
+ @Test
public void testWrite() throws Exception {
ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -54,6 +57,7 @@ public final class TestExMediaAtom exten
assertArrayEquals(data, b);
}
+ @Test
public void testNewRecord() throws Exception {
ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
assertEquals(0, ref.getMask()); //
@@ -71,6 +75,7 @@ public final class TestExMediaAtom exten
assertArrayEquals(data, b);
}
+ @Test
public void testFlags() {
ExMediaAtom record = new ExMediaAtom();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java Fri Dec 27 23:00:13 2019
@@ -18,30 +18,34 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.apache.poi.ss.formula.functions.AbstractNumericTestCase.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that ExObjListAtom works properly.
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public class TestExObjListAtom extends TestCase {
+public class TestExObjListAtom {
// From a real file
private final byte[] data_a = new byte[] {
- 00, 00, 0x0A, 0x04, 04, 00, 00, 00,
- 01, 00, 00, 00
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 1, 0, 0, 0
};
private final byte[] data_b = new byte[] {
- 00, 00, 0x0A, 0x04, 04, 00, 00, 00,
- 04, 00, 00, 00
+ 0, 0, 0x0A, 0x04, 4, 0, 0, 0,
+ 4, 0, 0, 0
};
+ @Test
public void testRecordType() {
ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
- assertEquals(1034l, eoa.getRecordType());
+ assertEquals(1034L, eoa.getRecordType());
}
+ @Test
public void testGetSeed() {
ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
@@ -50,19 +54,16 @@ public class TestExObjListAtom extends T
assertEquals(4, eob.getObjectIDSeed());
}
+ @Test
public void testWrite() throws Exception {
ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eoa.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Create A from scratch
+ @Test
public void testCreate() throws Exception {
ExObjListAtom eoa = new ExObjListAtom();
@@ -72,15 +73,11 @@ public class TestExObjListAtom extends T
// Check it's now the same as a
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eoa.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Try to turn a into b
+ @Test
public void testChange() throws Exception {
ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
@@ -90,12 +87,6 @@ public class TestExObjListAtom extends T
// Check bytes are now the same
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eoa.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Should now be the same
- assertEquals(data_b.length, b.length);
- for(int i=0; i<data_b.length; i++) {
- assertEquals(data_b[i],b[i]);
- }
+ assertArrayEquals(data_b, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java Fri Dec 27 23:00:13 2019
@@ -18,23 +18,23 @@
package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link ExOleObjAtom} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestExOleObjAtom extends TestCase {
+public final class TestExOleObjAtom {
// From a real file (embedded SWF control)
private final byte[] data = {
0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00 };
+ @Test
public void testRead() {
ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
@@ -47,15 +47,15 @@ public final class TestExOleObjAtom exte
assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
}
+ @Test
public void testWrite() throws Exception {
ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testNewRecord() throws Exception {
ExOleObjAtom record = new ExOleObjAtom();
record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
@@ -67,8 +67,6 @@ public final class TestExOleObjAtom exte
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java Fri Dec 27 23:00:13 2019
@@ -19,17 +19,20 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link HeadersFootersAtom} works properly
*
* @author Yegor Kozlov
*/
-public final class TestExVideoContainer extends TestCase {
+public final class TestExVideoContainer {
// From a real file
private final byte[] data = new byte[]{
@@ -47,9 +50,7 @@ public final class TestExVideoContainer
0x73, 0x00, 0x5C, 0x00, 0x63, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x2E, 0x00,
0x6D, 0x00, 0x70, 0x00, 0x67, 0x00};
-
-
-
+ @Test
public void testRead() {
ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
@@ -66,15 +67,15 @@ public final class TestExVideoContainer
assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());
}
+ @Test
public void testWrite() throws Exception {
ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testNewRecord() throws Exception {
ExVideoContainer record = new ExVideoContainer();
record.getExMediaAtom().setObjectId(1);
@@ -82,8 +83,6 @@ public final class TestExVideoContainer
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java Fri Dec 27 23:00:13 2019
@@ -19,22 +19,24 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestHeadersFootersAtom extends TestCase {
+public final class TestHeadersFootersAtom {
// From a real file
private final byte[] data = new byte[] {
- 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
+ 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0,
0x00, 0x00, 0x23, 0x00 };
+ @Test
public void testRead() {
HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
@@ -50,15 +52,15 @@ public final class TestHeadersFootersAto
assertTrue(record.getFlag(HeadersFootersAtom.fHasFooter));
}
+ @Test
public void testWrite() throws Exception {
HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testNewRecord() throws Exception {
HeadersFootersAtom record = new HeadersFootersAtom();
record.setFlag(HeadersFootersAtom.fHasDate, true);
@@ -67,11 +69,10 @@ public final class TestHeadersFootersAto
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(data, b);
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testFlags() {
HeadersFootersAtom record = new HeadersFootersAtom();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java Fri Dec 27 23:00:13 2019
@@ -19,17 +19,18 @@ package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that {@link HeadersFootersContainer} works properly
- *
- * @author Yegor Kozlov
*/
-public final class TestHeadersFootersContainer extends TestCase {
+public final class TestHeadersFootersContainer {
// SlideHeadersFootersContainer
private final byte[] slideData = new byte[] {
0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,
@@ -52,6 +53,7 @@ public final class TestHeadersFootersCon
0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
};
+ @Test
public void testReadSlideHeadersFootersContainer() {
HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
@@ -71,15 +73,15 @@ public final class TestHeadersFootersCon
assertNull(record.getHeaderAtom());
}
+ @Test
public void testWriteSlideHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(slideData, b);
+ assertArrayEquals(slideData, baos.toByteArray());
}
+ @Test
public void testNewSlideHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
@@ -100,11 +102,10 @@ public final class TestHeadersFootersCon
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(slideData, b);
+ assertArrayEquals(slideData, baos.toByteArray());
}
+ @Test
public void testReadNotesHeadersFootersContainer() {
HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
@@ -125,15 +126,15 @@ public final class TestHeadersFootersCon
assertEquals("Note Footer", csFooter.getText());
}
+ @Test
public void testWriteNotesHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(notesData, b);
+ assertArrayEquals(notesData, baos.toByteArray());
}
+ @Test
public void testNewNotesHeadersFootersContainer() throws Exception {
HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
@@ -162,9 +163,7 @@ public final class TestHeadersFootersCon
ByteArrayOutputStream baos = new ByteArrayOutputStream();
record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertArrayEquals(notesData, b);
+ assertArrayEquals(notesData, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfo.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfo.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfo.java Fri Dec 27 23:00:13 2019
@@ -21,29 +21,32 @@
package org.apache.poi.hslf.record;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests that InteractiveInfoAtom works properly.
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public class TestInteractiveInfo extends TestCase {
+public class TestInteractiveInfo {
// From a real file
- private final byte[] data_a = new byte[] {
- 0x0F, 00, 0xF2-256, 0x0F, 0x18, 00, 00, 00,
- 00, 00, 0xF3-256, 0x0F, 0x10, 00, 00, 00,
- 00, 00, 00, 00, 01, 00, 00, 00,
- 04, 00, 00, 00, 8, 00, 00, 00
+ private final byte[] data_a = {
+ 0x0F, 0, 0xF2-256, 0x0F, 0x18, 0, 0, 0,
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
};
+ @Test
public void testRecordType() {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
assertEquals(4082, ii.getRecordType());
}
+ @Test
public void testGetChildDetails() {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
@@ -51,19 +54,16 @@ public class TestInteractiveInfo extends
assertEquals(1, ia.getHyperlinkID());
}
+ @Test
public void testWrite() throws Exception {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ii.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Create A from scratch
+ @Test
public void testCreate() throws Exception {
InteractiveInfo ii = new InteractiveInfo();
InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
@@ -77,11 +77,6 @@ public class TestInteractiveInfo extends
// Check it's now the same as a
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ii.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java Fri Dec 27 23:00:13 2019
@@ -18,32 +18,36 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that InteractiveInfoAtom works properly.
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public class TestInteractiveInfoAtom extends TestCase {
+public class TestInteractiveInfoAtom {
// From a real file
private final byte[] data_a = new byte[] {
- 00, 00, 0xF3-256, 0x0F, 0x10, 00, 00, 00,
- 00, 00, 00, 00, 01, 00, 00, 00,
- 04, 00, 00, 00, 8, 00, 00, 00
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
};
private final byte[] data_b = new byte[] {
- 00, 00, 0xF3-256, 0x0F, 0x10, 00, 00, 00,
- 00, 00, 00, 00, 04, 00, 00, 00,
- 04, 00, 00, 00, 8, 00, 00, 00
+ 0, 0, 0xF3-256, 0x0F, 0x10, 0, 0, 0,
+ 0, 0, 0, 0, 4, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0
};
+ @Test
public void testRecordType() {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
- assertEquals(4083l, ia.getRecordType());
+ assertEquals(4083L, ia.getRecordType());
}
+ @Test
public void testGetNumber() {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
@@ -52,6 +56,7 @@ public class TestInteractiveInfoAtom ext
assertEquals(4, ib.getHyperlinkID());
}
+ @Test
public void testGetRest() {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
@@ -66,19 +71,16 @@ public class TestInteractiveInfoAtom ext
assertEquals(8, ib.getHyperlinkType());
}
+ @Test
public void testWrite() throws Exception {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ia.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Create A from scratch
+ @Test
public void testCreate() throws Exception {
InteractiveInfoAtom ia = new InteractiveInfoAtom();
@@ -91,15 +93,11 @@ public class TestInteractiveInfoAtom ext
// Check it's now the same as a
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ia.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Try to turn a into b
+ @Test
public void testChange() throws Exception {
InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
@@ -109,12 +107,6 @@ public class TestInteractiveInfoAtom ext
// Check bytes are now the same
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ia.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Should now be the same
- assertEquals(data_b.length, b.length);
- for(int i=0; i<data_b.length; i++) {
- assertEquals(data_b[i],b[i]);
- }
+ assertArrayEquals(data_b, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java Fri Dec 27 23:00:13 2019
@@ -18,23 +18,29 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that NotesAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestNotesAtom extends TestCase {
+public final class TestNotesAtom {
// From a real file
private final byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
+ @Test
public void testRecordType() {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
- assertEquals(1009l, na.getRecordType());
+ assertEquals(1009L, na.getRecordType());
}
+
+ @Test
public void testFlags() {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
assertEquals(0x80000000, na.getSlideID());
@@ -43,15 +49,11 @@ public final class TestNotesAtom extends
assertFalse(na.getFollowMasterBackground());
}
+ @Test
public void testWrite() throws Exception {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
na.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java Fri Dec 27 23:00:13 2019
@@ -18,24 +18,30 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that SlidePersistAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestSlidePersistAtom extends TestCase {
+public final class TestSlidePersistAtom {
// From a real file
private final byte[] data_a = new byte[] { 0, 0, 0xF3-256, 3, 0x14, 0, 0, 0,
4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0 };
+ @Test
public void testRecordType() {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
- assertEquals(1011l, spa.getRecordType());
+ assertEquals(1011L, spa.getRecordType());
}
+
+ @Test
public void testFlags() {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
assertEquals(4, spa.getRefID() );
@@ -44,15 +50,11 @@ public final class TestSlidePersistAtom
assertEquals(256, spa.getSlideIdentifier());
}
+ @Test
public void testWrite() throws Exception {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
spa.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextBytesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextBytesAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextBytesAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextBytesAtom.java Fri Dec 27 23:00:13 2019
@@ -18,65 +18,62 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
+import org.junit.Test;
+
/**
* Tests that TextBytesAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestTextBytesAtom extends TestCase {
+public final class TestTextBytesAtom {
// From a real file
- private final byte[] data = new byte[] { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0,
+ private final byte[] data = { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0,
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
0x65, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65, 0x20, 0x6F, 0x6E,
0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x32 };
- private final String data_text = "This is the title on page 2";
- private final byte[] alt_data = new byte[] { 0, 0, 0xA8-256, 0x0F, 0x14, 0, 0, 0,
+ private final byte[] alt_data = { 0, 0, 0xA8-256, 0x0F, 0x14, 0, 0, 0,
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
private final String alt_text = "This is a test title";
+ @Test
public void testRecordType() {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
- assertEquals(4008l, tba.getRecordType());
+ assertEquals(4008L, tba.getRecordType());
}
+ @Test
public void testTextA() {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
+ String data_text = "This is the title on page 2";
assertEquals(data_text, tba.getText());
}
+
+ @Test
public void testTextB() {
TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
assertEquals(alt_text, tba.getText());
}
+ @Test
public void testChangeText() throws Exception {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
tba.setText(alt_text.getBytes(StandardCharsets.ISO_8859_1));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tba.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Compare the header and the text
- assertEquals(alt_data.length, b.length);
- for(int i=0; i<alt_data.length; i++) {
- assertEquals(alt_data[i],b[i]);
- }
+ assertArrayEquals(alt_data, baos.toByteArray());
}
+ @Test
public void testWrite() throws Exception {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tba.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data.length, b.length);
- for(int i=0; i<data.length; i++) {
- assertEquals(data[i],b[i]);
- }
+ assertArrayEquals(data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java Fri Dec 27 23:00:13 2019
@@ -18,15 +18,17 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that TextCharsAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestTextCharsAtom extends TestCase {
+public final class TestTextCharsAtom {
// From a real file
private final byte[] data = new byte[] { 0, 0, 0xA0-256, 0x0f, 0x08, 0, 0, 0,
0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00 };
@@ -35,47 +37,43 @@ public final class TestTextCharsAtom ext
0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 };
private final String alt_text = "This\u01A3";
+ @Test
public void testRecordType() {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
- assertEquals(4000l, tca.getRecordType());
+ assertEquals(4000L, tca.getRecordType());
}
+ @Test
public void testTextA() {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
assertEquals(data_text, tca.getText());
}
+
+ @Test
public void testTextB() {
TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
assertEquals(alt_text, tca.getText());
}
+ @Test
public void testChangeText() throws Exception {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
tca.setText(alt_text);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tca.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Compare the header and the text
- assertEquals(alt_data.length, b.length);
- for(int i=0; i<alt_data.length; i++) {
- assertEquals(alt_data[i],b[i]);
- }
+ assertArrayEquals(alt_data, baos.toByteArray());
}
+ @Test
public void testWrite() throws Exception {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tca.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data.length, b.length);
- for(int i=0; i<data.length; i++) {
- assertEquals(data[i],b[i]);
- }
+ assertArrayEquals(data, baos.toByteArray());
}
+ @Test
public void testCreateNew() throws Exception {
TextCharsAtom tca = new TextCharsAtom();
assertEquals(0, tca.getText().length());
@@ -86,12 +84,7 @@ public final class TestTextCharsAtom ext
// Check it's now like data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tca.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data.length, b.length);
- for(int i=0; i<data.length; i++) {
- assertEquals(data[i],b[i]);
- }
+ assertArrayEquals(data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.java Fri Dec 27 23:00:13 2019
@@ -18,26 +18,30 @@
package org.apache.poi.hslf.record;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
+import org.junit.Test;
/**
* Tests that TextHeaderAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestTextHeaderAtom extends TestCase {
+public final class TestTextHeaderAtom {
// From a real file
- private final byte[] notes_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 2, 0, 0, 0};
- private final byte[] title_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
- private final byte[] body_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
+ private final byte[] notes_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 2, 0, 0, 0 };
+ private final byte[] title_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
+ private final byte[] body_data = { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
+ @Test
public void testRecordType() {
TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
- assertEquals(3999l, tha.getRecordType());
+ assertEquals(3999L, tha.getRecordType());
}
+
+ @Test
public void testTypes() {
TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12);
TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12);
@@ -47,15 +51,11 @@ public final class TestTextHeaderAtom ex
assertEquals(TextPlaceholder.BODY.nativeId, b_tha.getTextType());
}
+ @Test
public void testWrite() throws Exception {
TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tha.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(notes_data.length, b.length);
- for(int i=0; i<notes_data.length; i++) {
- assertEquals(notes_data[i],b[i]);
- }
+ assertArrayEquals(notes_data, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java Fri Dec 27 23:00:13 2019
@@ -18,20 +18,21 @@
package org.apache.poi.hslf.record;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Tests TextSpecInfoAtom
*
* @author Yegor Kozlov
*/
-public final class TestTextSpecInfoAtom extends TestCase {
+public final class TestTextSpecInfoAtom {
//from a real file
- private final byte[] data_1 = new byte[] {
+ private final byte[] data_1 = {
0x00, 0x00, (byte)0xAA, 0x0F, 0x2C, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00,
@@ -39,7 +40,7 @@ public final class TestTextSpecInfoAtom
0x00, 0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-
+ @Test
public void testRead() {
TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
@@ -50,18 +51,17 @@ public final class TestTextSpecInfoAtom
assertEquals(70, run[2].getLength());
assertEquals(9, run[3].getLength());
assertEquals(32, run[4].getLength());
-
}
+ @Test
public void testWrite() throws Exception {
TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
ByteArrayOutputStream out = new ByteArrayOutputStream();
spec.writeOut(out);
-
- byte[] result = out.toByteArray();
- assertArrayEquals(result, data_1);
+ assertArrayEquals(data_1, out.toByteArray());
}
+ @Test
public void testReset() throws Exception {
TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
spec.reset(32); //length of the parent text
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java Fri Dec 27 23:00:13 2019
@@ -18,26 +18,29 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that TxInteractiveInfoAtom works properly.
- *
- * @author Yegor Kozlov
*/
-public final class TestTxInteractiveInfoAtom extends TestCase {
+public final class TestTxInteractiveInfoAtom {
// From WithLinks.ppt
- private final byte[] data_a = new byte[] {
- 00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,
- 0x19, 00, 00, 00, 0x38, 00, 00, 00
+ private final byte[] data_a = {
+ 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
+ 0x19, 0, 0, 0, 0x38, 0, 0, 0
};
- private final byte[] data_b = new byte[] {
- 00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,
- 0x39, 00, 00, 00, 0x4E, 00, 00, 00
+ private final byte[] data_b = {
+ 0, 0, (byte)0xDF, 0x0F, 0x08, 0, 0, 0,
+ 0x39, 0, 0, 0, 0x4E, 0, 0, 0
};
+ @Test
public void testRead() {
TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
@@ -52,19 +55,16 @@ public final class TestTxInteractiveInfo
assertEquals(78, ia2.getEndIndex());
}
+ @Test
public void testWrite() throws Exception {
TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
atom.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Create A from scratch
+ @Test
public void testCreate() throws Exception {
TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
@@ -75,15 +75,11 @@ public final class TestTxInteractiveInfo
// Check it's now the same as a
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ia.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
// Try to turn a into b
+ @Test
public void testChange() throws Exception {
TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
@@ -94,12 +90,6 @@ public final class TestTxInteractiveInfo
// Check bytes are now the same
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ia.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- // Should now be the same
- assertEquals(data_b.length, b.length);
- for(int i=0; i<data_b.length; i++) {
- assertEquals(data_b[i],b[i]);
- }
+ assertArrayEquals(data_b, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java Fri Dec 27 23:00:13 2019
@@ -17,37 +17,43 @@
package org.apache.poi.hslf.record;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
+import org.junit.Before;
+import org.junit.Test;
/**
* Test <code>TestTxMasterStyleAtom</code> record.
* Check master style for the empty ppt which is created
* by the default constructor of <code>SlideShow</code>
- *
- * @author Yegor Kozlov
*/
-public final class TestTxMasterStyleAtom extends TestCase {
- protected HSLFSlideShow _ppt;
+public final class TestTxMasterStyleAtom {
+ private HSLFSlideShow _ppt;
- @Override
+ @Before
public void setUp() {
_ppt = new HSLFSlideShow();
}
+ @Test
public void testDefaultStyles() {
TxMasterStyleAtom[] txmaster = getMasterStyles();
for (final TxMasterStyleAtom atom : txmaster) {
final int txtype = atom.getTextType();
- switch (TextPlaceholder.fromNativeId(txtype)){
+ TextPlaceholder tp = TextPlaceholder.fromNativeId(txtype);
+ assertNotNull(tp);
+ switch (tp) {
case TITLE:
checkTitleType(atom);
break;
@@ -61,11 +67,8 @@ public final class TestTxMasterStyleAtom
checkOtherType(atom);
break;
case CENTER_BODY:
- break;
case CENTER_TITLE:
- break;
case HALF_BODY:
- break;
case QUARTER_BODY:
break;
default:
@@ -200,7 +203,7 @@ public final class TestTxMasterStyleAtom
* Collect all TxMasterStyleAtom records contained in the supplied slide show.
* There must be a TxMasterStyleAtom per each type of text defined in TextHeaderAtom
*/
- protected TxMasterStyleAtom[] getMasterStyles(){
+ private TxMasterStyleAtom[] getMasterStyles(){
List<TxMasterStyleAtom> lst = new ArrayList<>();
Record[] coreRecs = _ppt.getMostRecentCoreRecords();
@@ -221,13 +224,12 @@ public final class TestTxMasterStyleAtom
Record[] rec = doc.getEnvironment().getChildRecords();
for (final Record atom : rec) {
if (atom instanceof TxMasterStyleAtom) {
- if (txstyle != null) fail("Document.Environment must contain 1 TxMasterStyleAtom");
+ assertNull("Document.Environment must contain 1 TxMasterStyleAtom", txstyle);
txstyle = (TxMasterStyleAtom)atom;
}
}
- if (txstyle == null) {
- throw new AssertionFailedError("TxMasterStyleAtom not found in Document.Environment");
- }
+
+ assertNotNull("TxMasterStyleAtom not found in Document.Environment", txstyle);
assertEquals("Document.Environment must contain TxMasterStyleAtom with type=TextHeaderAtom.OTHER_TYPE",
TextPlaceholder.OTHER.nativeId, txstyle.getTextType());
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java Fri Dec 27 23:00:13 2019
@@ -18,25 +18,30 @@
package org.apache.poi.hslf.record;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
/**
* Tests that UserEditAtom works properly
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestUserEditAtom extends TestCase {
+public final class TestUserEditAtom {
// From a real file
private final byte[] data_a = new byte[] { 0, 0, 0xF5-256, 0x0F, 0x1C, 0, 0, 0,
- 00, 01, 00, 00, 0xD9-256, 18, 00, 03,
- 00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00,
- 05, 00, 00, 00, 01, 00, 0xF6-256, 77 };
+ 0, 1, 0, 0, 0xD9-256, 18, 0, 3,
+ 0, 0, 0, 0, 0, 0x18, 0, 0, 1, 0, 0, 0,
+ 5, 0, 0, 0, 1, 0, 0xF6-256, 77 };
+ @Test
public void testRecordType() {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
- assertEquals(4085l, uea.getRecordType());
+ assertEquals(4085L, uea.getRecordType());
}
+
+ @Test
public void testFlags() {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
@@ -49,15 +54,11 @@ public final class TestUserEditAtom exte
assertEquals((short)1, uea.getLastViewType() );
}
+ @Test
public void testWrite() throws Exception {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
uea.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data_a.length, b.length);
- for(int i=0; i<data_a.length; i++) {
- assertEquals(data_a[i],b[i]);
- }
+ assertArrayEquals(data_a, baos.toByteArray());
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java Fri Dec 27 23:00:13 2019
@@ -18,28 +18,30 @@
package org.apache.poi.hslf.usermodel;
+import static org.junit.Assert.assertEquals;
+
import org.apache.poi.POIDataSamples;
import org.apache.poi.hslf.record.Record;
-
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests that SlideShow finds the right records as its most recent ones
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestMostRecentRecords extends TestCase {
+public final class TestMostRecentRecords {
// HSLFSlideShow primed on the test data
- private final HSLFSlideShowImpl hss;
+ private HSLFSlideShowImpl hss;
// SlideShow primed on the test data
- private final HSLFSlideShow ss;
+ private HSLFSlideShow ss;
- public TestMostRecentRecords() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ @Before
+ public void setup() throws Exception {
+ POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShow(hss);
}
+ @Test
public void testCount() {
// Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords();
@@ -48,6 +50,7 @@ public final class TestMostRecentRecords
assertEquals(7, mrcr.length);
}
+ @Test
public void testRightRecordTypes() {
// Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords();
@@ -69,6 +72,7 @@ public final class TestMostRecentRecords
assertEquals(1008, mrcr[6].getRecordType());
}
+ @Test
public void testCorrectRecords() {
// Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java Fri Dec 27 23:00:13 2019
@@ -18,41 +18,41 @@
package org.apache.poi.hslf.usermodel;
-import org.apache.poi.POIDataSamples;
+import static org.junit.Assert.assertArrayEquals;
-import junit.framework.TestCase;
+import org.apache.poi.POIDataSamples;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests that SlideShow returns MetaSheets which have the right text in them
- *
- * @author Nick Burch (nick at torchbox dot com)
*/
-public final class TestNotesText extends TestCase {
+public final class TestNotesText {
// SlideShow primed on the test data
- private final HSLFSlideShow ss;
+ private HSLFSlideShow ss;
- public TestNotesText() throws Exception {
- POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+ @Before
+ public void setup() throws Exception {
+ POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShow(hss);
}
+ @Test
public void testNotesOne() {
HSLFNotes notes = ss.getNotes().get(0);
-
- String[] expectText = new String[] {"These are the notes for page 1"};
- assertEquals(expectText.length, notes.getTextParagraphs().size());
- for(int i=0; i<expectText.length; i++) {
- assertEquals(expectText[i], HSLFTextParagraph.getRawText(notes.getTextParagraphs().get(i)));
- }
+ String[] expectText = {"These are the notes for page 1"};
+ assertArrayEquals(expectText, toStrings(notes));
}
+ @Test
public void testNotesTwo() {
HSLFNotes notes = ss.getNotes().get(1);
- String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"};
- assertEquals(expectText.length, notes.getTextParagraphs().size());
- for(int i=0; i<expectText.length; i++) {
- assertEquals(expectText[i], HSLFTextParagraph.getRawText(notes.getTextParagraphs().get(i)));
- }
+ String[] expectText = {"These are the notes on page two, again lacking formatting"};
+ assertArrayEquals(expectText, toStrings(notes));
+ }
+
+ private static String[] toStrings(HSLFNotes notes) {
+ return notes.getTextParagraphs().stream().map(HSLFTextParagraph::getRawText).toArray(String[]::new);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org