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 [12/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/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java Fri Dec 27 23:00:13 2019
@@ -17,27 +17,31 @@
 
 package org.apache.poi.hssf.record;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.ComparisonFailure;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.stream.Stream;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.formula.FormulaParser;
+import org.apache.poi.ss.formula.FormulaRenderer;
+import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.formula.SharedFormula;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefPtg;
-import org.apache.poi.ss.formula.SharedFormula;
-import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.formula.FormulaParser;
-import org.apache.poi.ss.formula.FormulaRenderer;
-import org.apache.poi.ss.formula.FormulaType;
-import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.util.LittleEndianInput;
+import org.junit.Test;
 
-/**
- * @author Josh Micich
- */
-public final class TestSharedFormulaRecord extends TestCase {
+public final class TestSharedFormulaRecord {
 
     /**
      * A sample spreadsheet known to have one sheet with 4 shared formula ranges
@@ -71,6 +75,7 @@ public final class TestSharedFormulaReco
      * classes are preserved during this transformation, because Excel may not tolerate the
      * incorrect encoding.  The formula here is one such example (Excel displays #VALUE!).
      */
+    @Test
     public void testConvertSharedFormulasOperandClasses_bug45123() {
 
         LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(SHARED_FORMULA_WITH_REF_ARRAYS_DATA);
@@ -82,25 +87,17 @@ public final class TestSharedFormulaReco
 
         RefPtg refPtg = (RefPtg) convertedFormula[1];
         assertEquals("$C101", refPtg.toFormulaString());
-        if (refPtg.getPtgClass() == Ptg.CLASS_REF) {
-            throw new AssertionFailedError("Identified bug 45123");
-        }
-
+        assertNotEquals("Identified bug 45123", Ptg.CLASS_REF, refPtg.getPtgClass());
         confirmOperandClasses(sharedFormula, convertedFormula);
     }
 
     private static void confirmOperandClasses(Ptg[] originalPtgs, Ptg[] convertedPtgs) {
-        assertEquals(originalPtgs.length, convertedPtgs.length);
-        for (int i = 0; i < convertedPtgs.length; i++) {
-            Ptg originalPtg = originalPtgs[i];
-            Ptg convertedPtg = convertedPtgs[i];
-            if (originalPtg.getPtgClass() != convertedPtg.getPtgClass()) {
-                throw new ComparisonFailure("Different operand class for token[" + i + "]",
-                        String.valueOf(originalPtg.getPtgClass()), String.valueOf(convertedPtg.getPtgClass()));
-            }
-        }
+        int[] exp = Stream.of(originalPtgs).map(Ptg::getPtgClass).mapToInt(Byte::intValue).toArray();
+        int[] act = Stream.of(convertedPtgs).map(Ptg::getPtgClass).mapToInt(Byte::intValue).toArray();
+        assertArrayEquals("Different operand class", exp, act);
     }
 
+    @Test
     public void testConvertSharedFormulas() {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFEvaluationWorkbook fpb = HSSFEvaluationWorkbook.create(wb);
@@ -141,6 +138,7 @@ public final class TestSharedFormulaReco
     /**
      * Make sure that POI preserves {@link SharedFormulaRecord}s
      */
+    @Test
     public void testPreserveOnReserialize() {
         HSSFWorkbook wb;
         HSSFSheet sheet;
@@ -168,10 +166,12 @@ public final class TestSharedFormulaReco
         cellB32769 = sheet.getRow(32768).getCell(1);
         cellC32769 = sheet.getRow(32768).getCell(2);
         assertEquals("B32770*2", cellB32769.getCellFormula());
+        assertEquals("C32770*2", cellC32769.getCellFormula());
         confirmCellEvaluation(wb, cellB32769, 4);
         assertEquals(4, countSharedFormulas(sheet));
     }
 
+    @Test
     public void testUnshareFormulaDueToChangeFormula() {
         HSSFWorkbook wb;
         HSSFSheet sheet;
@@ -192,6 +192,8 @@ public final class TestSharedFormulaReco
         assertEquals("C32770*2", cellC32769.getCellFormula());
         confirmCellEvaluation(wb, cellC32769, 6);
     }
+
+    @Test
     public void testUnshareFormulaDueToDelete() {
         HSSFWorkbook wb;
         HSSFSheet sheet;
@@ -236,13 +238,8 @@ public final class TestSharedFormulaReco
      * @return the number of {@link SharedFormulaRecord}s encoded for the specified sheet
      */
     private static int countSharedFormulas(HSSFSheet sheet) {
-        Record[] records = RecordInspector.getRecords(sheet, 0);
-        int count = 0;
-        for (Record rec : records) {
-            if(rec instanceof SharedFormulaRecord) {
-                count++;
-            }
-        }
-        return count;
+        int[] count = { 0 };
+        sheet.getSheet().visitContainedRecords(r -> count[0] += r instanceof SharedFormulaRecord ? 1 : 0, 0);
+        return count[0];
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java Fri Dec 27 23:00:13 2019
@@ -17,30 +17,24 @@
 
 package org.apache.poi.hssf.record;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.poi.util.HexRead;
+import org.junit.Test;
 
 /**
  * Tests for {@link StyleRecord}
  */
-public final class TestStyleRecord extends TestCase {
+public final class TestStyleRecord {
+	@Test
 	public void testUnicodeReadName() {
 		byte[] data = HexRead.readFromString(
 				"11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
 		RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
 		StyleRecord sr = new StyleRecord(in);
 		assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
-		byte[] ser;
-		try {
-			ser = sr.serialize();
-		} catch (IllegalStateException e) {
-			if (e.getMessage().equals("Incorrect number of bytes written - expected 27 but got 18")) {
-				throw new AssertionFailedError("Identified bug 46385");
-			}
-			throw e;
-		}
+		// bug 46385 - Incorrect number of bytes written - expected 27 but got 18
+		byte[] ser = sr.serialize();
 		TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java Fri Dec 27 23:00:13 2019
@@ -20,21 +20,18 @@ package org.apache.poi.hssf.record;
 
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 
 import org.apache.poi.util.HexRead;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.RecordFormatException;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * Tests Subrecord components of an OBJ record.  Test data taken directly
  * from a real Excel file.
- *
- * @author Michael Zalewski (zalewski@optonline.net)
  */
-public final class TestSubRecord extends TestCase {
+public final class TestSubRecord {
 	/*
 	   The following is a dump of the OBJ record corresponding to an auto-filter
 	   drop-down list. The 3rd subrecord beginning at offset 0x002e (type=0x0013)
@@ -51,7 +48,7 @@ public final class TestSubRecord extends
 	                  00 00 00 00                               l.....            Type=0x00 Len=0x0000 ftEnd
 	*/
 
-	private static final byte[] dataAutoFilter 
+	private static final byte[] dataAutoFilter
 		= HexRead.readFromString(""
 			+ "5D 00 46 00 " // ObjRecord.sid, size=70
 			// ftCmo
@@ -71,20 +68,20 @@ public final class TestSubRecord extends
 	/**
 	 * Make sure that ftLbsData (which has abnormal size info) is parsed correctly.
 	 * If the size field is interpreted incorrectly, the resulting ObjRecord becomes way too big.
-	 * At the time of fixing (Oct-2008 svn r707447) {@link RecordInputStream} allowed  buffer 
+	 * At the time of fixing (Oct-2008 svn r707447) {@link RecordInputStream} allowed  buffer
 	 * read overruns, so the bug was mostly silent.
 	 */
+	@Test
 	public void testReadAll_bug45778() {
 		RecordInputStream in = TestcaseRecordInputStream.create(dataAutoFilter);
 		ObjRecord or = new ObjRecord(in);
 		byte[] data2 = or.serialize();
-		if (data2.length == 8228) {
-			throw new AssertionFailedError("Identified bug 45778");
-		}
+		assertNotEquals("Identified bug 45778", 8228, data2.length);
 		assertEquals(74, data2.length);
 		assertArrayEquals(dataAutoFilter, data2);
 	}
-	
+
+	@Test
 	public void testReadManualComboWithFormula() {
 		byte[] data = HexRead.readFromString(""
 			+ "5D 00 66 00 "
@@ -96,35 +93,29 @@ public final class TestSubRecord extends
 			+ "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 "
 			+ "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero
 		);
-		
+
 		RecordInputStream in = TestcaseRecordInputStream.create(data);
 		ObjRecord or = new ObjRecord(in);
 		byte[] data2 = or.serialize();
-		if (data2.length == 8228) {
-			throw new AssertionFailedError("Identified bug 45778");
-		}
+		assertNotEquals("Identified bug 45778", 8228, data2.length);
 		assertEquals("Encoded length", data.length, data2.length);
-		for (int i = 0; i < data.length; i++) {
-			if (data[i] != data2[i]) {
-				throw new AssertionFailedError("Encoded data differs at index " + i);
-			}
-		}
-		assertArrayEquals(data, data2);
+		assertArrayEquals("Encoded data differs", data, data2);
 	}
 
 	/**
-	 * Some versions of POI (e.g. 3.1 - prior to svn r707450 / bug 45778) interpreted the ftLbs 
-	 * subrecord second short (0x1FEE) as a length, and hence read lots of extra padding.  This 
+	 * Some versions of POI (e.g. 3.1 - prior to svn r707450 / bug 45778) interpreted the ftLbs
+	 * subrecord second short (0x1FEE) as a length, and hence read lots of extra padding.  This
 	 * buffer-overrun in {@link RecordInputStream} happened silently due to problems later fixed
-	 * in svn 707778. When the ObjRecord is written, the extra padding is written too, making the 
-	 * record 8224 bytes long instead of 70.  
+	 * in svn 707778. When the ObjRecord is written, the extra padding is written too, making the
+	 * record 8224 bytes long instead of 70.
 	 * (An aside: It seems more than a coincidence that this problem creates a record of exactly
-	 * {@link RecordInputStream#MAX_RECORD_DATA_SIZE} but not enough is understood about 
+	 * {@link RecordInputStream#MAX_RECORD_DATA_SIZE} but not enough is understood about
 	 * subrecords to explain this.)<br>
-	 * 
+	 *
 	 * Excel reads files with this excessive padding OK.  It also truncates the over-sized
 	 * ObjRecord back to the proper size.  POI should do the same.
 	 */
+	@Test
 	public void testWayTooMuchPadding_bug46545() {
 		byte[] data = HexRead.readFromString(""
 			+ "15 00 12 00 14 00 13 00 01 21 00 00 00"
@@ -143,18 +134,11 @@ public final class TestSubRecord extends
 		int wrongTotalSize = LBS_START_POS + 4 + WRONG_LBS_SIZE;
 		byte[] wrongData = new byte[wrongTotalSize];
 		System.arraycopy(data, 0, wrongData, 0, data.length);
-		// wrongData has the ObjRecord data as would have been written by v3.1 
-		
+		// wrongData has the ObjRecord data as would have been written by v3.1
+
 		RecordInputStream in = TestcaseRecordInputStream.create(ObjRecord.sid, wrongData);
-		ObjRecord or;
-		try {
-			or = new ObjRecord(in);
-		} catch (RecordFormatException e) {
-			if (e.getMessage().startsWith("Leftover 8154 bytes in subrecord data")) {
-				throw new AssertionFailedError("Identified bug 46545");
-			}
-			throw e;
-		}
+		// bug 46545 - Leftover 8154 bytes in subrecord data
+		ObjRecord or = new ObjRecord(in);
 		// make sure POI properly truncates the ObjRecord data
 		byte[] data2 = or.serialize();
 		TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, data2);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java Fri Dec 27 23:00:13 2019
@@ -18,17 +18,24 @@
 package org.apache.poi.hssf.record;
 
 
-import junit.framework.TestCase;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_ALT_STARTUP_DIR;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_DOWN_DIR;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_LIB_DIR;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_SAME_VOLUME;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_STARTUP_DIR;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_UP_DIR;
+import static org.apache.poi.hssf.record.SupBookRecord.CH_VOLUME;
+import static org.apache.poi.hssf.record.SupBookRecord.PATH_SEPERATOR;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-import static org.apache.poi.hssf.record.SupBookRecord.*;
+import org.junit.Test;
 
 /**
  * Tests the serialization and deserialization of the SupBook record
- * class works correctly.  
- *
- * @author Andrew C. Oliver (acoliver at apache dot org)
+ * class works correctly.
  */
-public final class TestSupBookRecord extends TestCase {
+public final class TestSupBookRecord {
     /**
      * This contains a fake data section of a SubBookRecord
      */
@@ -40,64 +47,66 @@ public final class TestSupBookRecord ext
     };
     byte[] dataER = new byte[] {
         (byte)0x02,(byte)0x00,
-        (byte)0x07,(byte)0x00,   (byte)0x00,   
-                (byte)'t', (byte)'e', (byte)'s', (byte)'t', (byte)'U', (byte)'R', (byte)'L',  
-        (byte)0x06,(byte)0x00,   (byte)0x00,   
-                (byte)'S', (byte)'h', (byte)'e', (byte)'e', (byte)'t', (byte)'1', 
-        (byte)0x06,(byte)0x00,   (byte)0x00,   
-                (byte)'S', (byte)'h', (byte)'e', (byte)'e', (byte)'t', (byte)'2', 
+        (byte)0x07,(byte)0x00,   (byte)0x00,
+                (byte)'t', (byte)'e', (byte)'s', (byte)'t', (byte)'U', (byte)'R', (byte)'L',
+        (byte)0x06,(byte)0x00,   (byte)0x00,
+                (byte)'S', (byte)'h', (byte)'e', (byte)'e', (byte)'t', (byte)'1',
+        (byte)0x06,(byte)0x00,   (byte)0x00,
+                (byte)'S', (byte)'h', (byte)'e', (byte)'e', (byte)'t', (byte)'2',
    };
 
     /**
      * tests that we can load the record
      */
+    @Test
     public void testLoadIR() {
-
-        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataIR));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataIR));
         assertTrue( record.isInternalReferences() );             //expected flag
         assertEquals( 0x4, record.getNumberOfSheets() );    //expected # of sheets
 
         assertEquals( 8, record.getRecordSize() );  //sid+size+data
     }
+
     /**
      * tests that we can load the record
      */
+    @Test
     public void testLoadER() {
-
-        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataER));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataER));
         assertTrue( record.isExternalReferences() );             //expected flag
         assertEquals( 0x2, record.getNumberOfSheets() );    //expected # of sheets
 
         assertEquals( 34, record.getRecordSize() );  //sid+size+data
-        
+
         assertEquals("testURL", record.getURL());
         String[] sheetNames = record.getSheetNames();
         assertEquals(2, sheetNames.length);
         assertEquals("Sheet1", sheetNames[0]);
         assertEquals("Sheet2", sheetNames[1]);
     }
-    
+
     /**
      * tests that we can load the record
      */
+    @Test
     public void testLoadAIF() {
-
-        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataAIF));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataAIF));
         assertTrue( record.isAddInFunctions() );             //expected flag
         assertEquals( 0x1, record.getNumberOfSheets() );    //expected # of sheets
         assertEquals( 8, record.getRecordSize() );  //sid+size+data
     }
-   
+
     /**
      * Tests that we can store the record
-     *
      */
+    @Test
     public void testStoreIR() {
         SupBookRecord record = SupBookRecord.createInternalReferences((short)4);
 
         TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataIR, record.serialize());
-    }   
-    
+    }
+
+    @Test
     public void testStoreER() {
         String url = "testURL";
         String[] sheetNames = { "Sheet1", "Sheet2", };
@@ -106,26 +115,28 @@ public final class TestSupBookRecord ext
         TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataER, record.serialize());
     }
 
+    @Test
     public void testStoreAIF() {
         SupBookRecord record = SupBookRecord.createAddInFunctions();
         assertEquals(1, record.getNumberOfSheets());
         assertTrue(record.isAddInFunctions());
         TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
     }
-    
+
+    @Test
     public void testExternalReferenceUrl() {
     	String[] sheetNames = new String[]{"SampleSheet"};
     	final char startMarker = (char)1;
-    	
+
 		SupBookRecord record;
-		
+
 		record = new SupBookRecord(startMarker + "test.xls", sheetNames);
     	assertEquals("test.xls", record.getURL());
 
     	//UNC path notation
     	record = new SupBookRecord(startMarker + "" + CH_VOLUME + "@servername" + CH_DOWN_DIR + "test.xls", sheetNames);
     	assertEquals("\\\\servername" + PATH_SEPERATOR + "test.xls", record.getURL());
-    	
+
     	//Absolute path notation - different device
     	record = new SupBookRecord(startMarker + "" + CH_VOLUME + "D" + CH_DOWN_DIR + "test.xls", sheetNames);
     	assertEquals("D:" + PATH_SEPERATOR + "test.xls", record.getURL());
@@ -133,11 +144,11 @@ public final class TestSupBookRecord ext
     	//Absolute path notation - same device
     	record = new SupBookRecord(startMarker + "" + CH_SAME_VOLUME + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
     	assertEquals(PATH_SEPERATOR + "folder" + PATH_SEPERATOR + "test.xls", record.getURL());
-    	
+
     	//Relative path notation - down
     	record = new SupBookRecord(startMarker + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
     	assertEquals("folder" + PATH_SEPERATOR + "test.xls", record.getURL());
-    	
+
     	//Relative path notation - up
     	record = new SupBookRecord(startMarker +""+ CH_UP_DIR + "test.xls", sheetNames);
     	assertEquals(".." + PATH_SEPERATOR + "test.xls", record.getURL());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java Fri Dec 27 23:00:13 2019
@@ -17,21 +17,23 @@
 
 package org.apache.poi.hssf.record;
 
-import org.apache.poi.hssf.util.CellRangeAddress8Bit;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.TestCase;
+import org.apache.poi.hssf.util.CellRangeAddress8Bit;
+import org.junit.Test;
 
 /**
  * Tests the serialization and deserialization of the TableRecord
  * class works correctly.  Test data taken directly from a real
  * Excel file.
  */
-public final class TestTableRecord extends TestCase {
+public final class TestTableRecord {
 	byte[] header = new byte[] {
 			0x36, 02, 0x10, 00, // sid=x236, 16 bytes long
 	};
 	byte[] data = new byte[] {
-			03, 00,  // from row 3 
+			03, 00,  // from row 3
 			8, 00,   // to row 8
 			04,      // from col 4
 			06,      // to col 6
@@ -42,6 +44,7 @@ public final class TestTableRecord exten
 			00, 00   // col inp col 0
 	};
 
+	@Test
 	public void testLoad() {
 
 		TableRecord record = new TableRecord(TestcaseRecordInputStream.create(0x236, data));
@@ -60,6 +63,7 @@ public final class TestTableRecord exten
 		assertEquals( 16 + 4, record.getRecordSize() );
 	}
 
+	@Test
     public void testStore()
     {
 //    	Offset 0x3bd9 (15321)
@@ -87,8 +91,6 @@ public final class TestTableRecord exten
 		record.setColInputCol(0);
 
 		byte [] recordBytes = record.serialize();
-		assertEquals(recordBytes.length - 4, data.length);
-		for (int i = 0; i < data.length; i++)
-			assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+		confirmRecordEncoding(TableRecord.sid, data, recordBytes);
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java Fri Dec 27 23:00:13 2019
@@ -18,19 +18,20 @@
 package org.apache.poi.hssf.record;
 
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.util.HexRead;
-
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * Tests the serialization and deserialization of the TextObjectBaseRecord
  * class works correctly.  Test data taken directly from a real
  * Excel file.
- *
- * @author Glen Stampoultzis (glens at apache.org)
  */
-public final class TestTextObjectBaseRecord extends TestCase {
+public final class TestTextObjectBaseRecord {
 	/** data for one TXO rec and two continue recs */
     private static final byte[] data = HexRead.readFromString(
         "B6 01 " + // TextObjectRecord.sid
@@ -51,6 +52,7 @@ public final class TestTextObjectBaseRec
         "02 00 00 00 00 00 00 00 "
     );
 
+    @Test
     public void testLoad() {
         RecordInputStream in = TestcaseRecordInputStream.create(data);
         TextObjectRecord record = new TextObjectRecord(in);
@@ -63,6 +65,7 @@ public final class TestTextObjectBaseRec
         assertEquals(49, record.getRecordSize() );
     }
 
+    @Test
     public void testStore() {
         TextObjectRecord record = new TextObjectRecord();
 
@@ -77,8 +80,6 @@ public final class TestTextObjectBaseRec
         record.setStr(str);
 
         byte [] recordBytes = record.serialize();
-        assertEquals(recordBytes.length, data.length);
-        for (int i = 0; i < data.length; i++)
-            assertEquals("At offset " + i, data[i], recordBytes[i]);
+        assertArrayEquals(data, recordBytes);
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java Fri Dec 27 23:00:13 2019
@@ -18,15 +18,17 @@
 package org.apache.poi.hssf.record;
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.ByteArrayInputStream;
 
-import junit.framework.TestCase;
 import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefPtg;
 import org.apache.poi.util.HexRead;
 import org.apache.poi.util.LittleEndian;
+import org.junit.Test;
 
 /**
  * Tests that serialization and deserialization of the TextObjectRecord .
@@ -34,7 +36,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Yegor Kozlov
  */
-public final class TestTextObjectRecord extends TestCase {
+public final class TestTextObjectRecord {
 
     private static final byte[] simpleData = HexRead.readFromString(
         "B6 01 12 00 " +
@@ -47,7 +49,7 @@ public final class TestTextObjectRecord
         "00 0D 00 00 00 00 00 00 00"
     );
 
-
+    @Test
     public void testRead() {
 
         RecordInputStream is =TestcaseRecordInputStream.create(simpleData);
@@ -60,6 +62,7 @@ public final class TestTextObjectRecord
         assertEquals("Hello, World!", record.getStr().getString());
     }
 
+    @Test
     public void testWrite() {
         HSSFRichTextString str = new HSSFRichTextString("Hello, World!");
 
@@ -78,11 +81,13 @@ public final class TestTextObjectRecord
         //read again
         RecordInputStream is = TestcaseRecordInputStream.create(simpleData);
         record = new TextObjectRecord(is);
+        assertNotNull(record);
     }
 
     /**
      * Zero {@link ContinueRecord}s follow a {@link TextObjectRecord} if the text is empty
      */
+    @Test
     public void testWriteEmpty() {
         HSSFRichTextString str = new HSSFRichTextString("");
 
@@ -105,6 +110,7 @@ public final class TestTextObjectRecord
     /**
      * Test that TextObjectRecord serializes logs records properly.
      */
+    @Test
     public void testLongRecords() {
         int[] lengths = {1024, 2048, 4096, 8192, 16384}; //test against strings of different length
         for (int length : lengths) {
@@ -131,6 +137,7 @@ public final class TestTextObjectRecord
     /**
      * Test cloning
      */
+    @Test
     public void testClone() {
         String text = "Hello, World";
         HSSFRichTextString str = new HSSFRichTextString(text);
@@ -175,7 +182,7 @@ public final class TestTextObjectRecord
             "02 00 00 00 00 00 00 00 "
         );
 
-
+    @Test
     public void testLinkFormula() {
         RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(linkData));
         is.nextRecord();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java Fri Dec 27 23:00:13 2019
@@ -18,19 +18,23 @@
 package org.apache.poi.hssf.record;
 
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-/**
- * 
- */
-public final class TestUnicodeNameRecord extends TestCase {
+import org.junit.Test;
 
-	public void testReadBook() {
+public final class TestUnicodeNameRecord {
 
+	@Test
+	public void testReadBook() throws IOException {
 		// This bit used to crash
-		HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("unicodeNameRecord.xls");
-		book.getSheetAt(0);
+		try (HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("unicodeNameRecord.xls")) {
+			HSSFSheet sheet = book.getSheetAt(0);
+			assertNotNull(sheet);
+		}
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java Fri Dec 27 23:00:13 2019
@@ -17,18 +17,15 @@
 
 package org.apache.poi.hssf.record;
 
-import org.apache.poi.util.HexRead;
-import org.apache.poi.util.RecordFormatException;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+import org.junit.Test;
 
 /**
  * Tests for {@link WriteAccessRecord}
- *
- * @author Josh Micich
  */
-public final class TestWriteAccessRecord extends TestCase {
+public final class TestWriteAccessRecord {
 
 	private static final String HEX_SIXTYFOUR_SPACES = ""
 		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
@@ -36,7 +33,7 @@ public final class TestWriteAccessRecord
 		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
 		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20";
 
-
+	@Test
 	public void testMissingStringHeader_bug47001a() {
 		/*
 		 * Data taken from offset 0x0224 in
@@ -52,15 +49,8 @@ public final class TestWriteAccessRecord
 
 		RecordInputStream in = TestcaseRecordInputStream.create(data);
 
-		WriteAccessRecord rec;
-		try {
-			rec = new WriteAccessRecord(in);
-		} catch (RecordFormatException e) {
-			if (e.getMessage().equals("Not enough data (0) to read requested (1) bytes")) {
-				throw new AssertionFailedError("Identified bug 47001a");
-			}
-			throw e;
-		}
+		// bug 47001a - Not enough data (0) to read requested (1) bytes
+		WriteAccessRecord rec = new WriteAccessRecord(in);
 		assertEquals("Java Excel API v2.6.4", rec.getUsername());
 
 
@@ -74,6 +64,7 @@ public final class TestWriteAccessRecord
 		TestcaseRecordInputStream.confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
 	}
 
+	@Test
 	public void testShortRecordWrittenByMSAccess() {
 		/*
 		 * Data taken from two example files

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java Fri Dec 27 23:00:13 2019
@@ -17,13 +17,12 @@
 
 package org.apache.poi.hssf.record;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
-
-import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianByteArrayInputStream;
 import org.apache.poi.util.LittleEndianInput;
@@ -74,8 +73,7 @@ public final class TestcaseRecordInputSt
 	 * @param expectedData - just raw data (without sid or size short ints)
 	 * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
 	 */
-	public static void confirmRecordEncoding(int expectedSid, byte[] expectedData, byte[] actualRecordBytes)
-			throws AssertionFailedError {
+	public static void confirmRecordEncoding(int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
 		confirmRecordEncoding(null, expectedSid, expectedData, actualRecordBytes);
 	}
 	/**
@@ -84,22 +82,22 @@ public final class TestcaseRecordInputSt
 	 * @param expectedData - just raw data (without ushort sid, ushort size)
 	 * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
 	 */
-	public static void confirmRecordEncoding(String msgPrefix, int expectedSid, byte[] expectedData, byte[] actualRecordBytes)
-			throws AssertionFailedError {
+	public static void confirmRecordEncoding(String msgPrefix, int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
 		int expectedDataSize = expectedData.length;
-		Assert.assertEquals("Size of encode data mismatch", actualRecordBytes.length - 4, expectedDataSize);
-		Assert.assertEquals(expectedSid, LittleEndian.getShort(actualRecordBytes, 0));
-		Assert.assertEquals(expectedDataSize, LittleEndian.getShort(actualRecordBytes, 2));
-		for (int i = 0; i < expectedDataSize; i++)
-			if (expectedData[i] != actualRecordBytes[i+4]) {
-				StringBuilder sb = new StringBuilder(64);
-				if (msgPrefix != null) {
-					sb.append(msgPrefix).append(": ");
-				}
-				sb.append("At offset ").append(i);
-				sb.append(": expected ").append(HexDump.byteToHex(expectedData[i]));
-				sb.append(" but found ").append(HexDump.byteToHex(actualRecordBytes[i+4]));
-				throw new AssertionFailedError(sb.toString());
-			}
+		assertEquals("Size of encode data mismatch", actualRecordBytes.length - 4, expectedDataSize);
+		assertEquals(expectedSid, LittleEndian.getShort(actualRecordBytes, 0));
+		assertEquals(expectedDataSize, LittleEndian.getShort(actualRecordBytes, 2));
+		assertArrayEquals(expectedData, cut(actualRecordBytes, 4));
+	}
+
+	public static byte[] cut( byte[] data, int fromInclusive ) {
+		return cut(data, fromInclusive, data.length);
+	}
+
+	public static byte[] cut(byte[] data, int fromInclusive, int toExclusive) {
+		int length = toExclusive - fromInclusive;
+		byte[] result = new byte[length];
+		System.arraycopy( data, fromInclusive, result, 0, length);
+		return result;
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java Fri Dec 27 23:00:13 2019
@@ -17,14 +17,18 @@
 
 package org.apache.poi.hssf.record.aggregates;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
 import org.apache.poi.hssf.model.RecordStream;
 import org.apache.poi.hssf.record.CFHeaderBase;
 import org.apache.poi.hssf.record.CFHeaderRecord;
@@ -38,13 +42,15 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LittleEndian;
+import org.junit.Test;
 
 /**
  * Tests the serialization and deserialization of the CFRecordsAggregate
- * class works correctly.  
+ * class works correctly.
  */
 @SuppressWarnings("resource")
-public final class TestCFRecordsAggregate extends TestCase {
+public final class TestCFRecordsAggregate {
+    @Test
     public void testCFRecordsAggregate() {
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFSheet sheet = workbook.createSheet();
@@ -115,6 +121,7 @@ public final class TestCFRecordsAggregat
     /**
      * Make sure that the CF Header record is properly updated with the number of rules
      */
+    @Test
     public void testNRules() {
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFSheet sheet = workbook.createSheet();
@@ -131,12 +138,11 @@ public final class TestCFRecordsAggregat
         agg.serialize(0, serializedRecord);
 
         int nRules = LittleEndian.getUShort(serializedRecord, 4);
-        if (nRules == 0) {
-            throw new AssertionFailedError("Identified bug 45682 b");
-        }
+        assertNotEquals("Identified bug 45682 b", 0, nRules);
         assertEquals(rules.length, nRules);
     }
-    
+
+    @Test
     public void testCantMixTypes() {
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFSheet sheet = workbook.createSheet();
@@ -154,12 +160,12 @@ public final class TestCFRecordsAggregat
         } catch (IllegalArgumentException e) {
             // expected here
         }
-        
-        
+
+
         rules = new CFRuleBase[] { CFRuleRecord.create(sheet, "7") };
         CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);
         assertTrue(agg.getHeader().getNeedRecalculation());
-        
+
         try {
             agg.addRule(CFRule12Record.create(sheet, "7"));
             fail("Shouldn't be able to mix between types");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java Fri Dec 27 23:00:13 2019
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record.aggregates;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -25,11 +26,8 @@ import java.util.List;
 import org.apache.poi.hssf.record.ColumnInfoRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.RecordBase;
-import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
 import org.junit.Test;
 
-import junit.framework.AssertionFailedError;
-
 public final class TestColumnInfoRecordsAggregate {
 
 	@Test
@@ -62,34 +60,19 @@ public final class TestColumnInfoRecords
 		return columnInfoRecord;
 	}
 
-	private static final class CIRCollector implements RecordVisitor {
-
-		private final List<Record> _list = new ArrayList<>();
-
-		@Override
-        public void visitRecord(Record r) {
-			_list.add(r);
-		}
-
-		public static ColumnInfoRecord[] getRecords(ColumnInfoRecordsAggregate agg) {
-			CIRCollector circ = new CIRCollector();
-			agg.visitContainedRecords(circ);
-            return circ._list.toArray(new ColumnInfoRecord[0]);
-		}
-	}
-
 	@Test
 	public void testGroupColumns_bug45639() {
 		ColumnInfoRecordsAggregate agg = new ColumnInfoRecordsAggregate();
 		agg.groupColumnRange( 7, 9, true);
 		agg.groupColumnRange( 4, 12, true);
-		try {
-			agg.groupColumnRange( 1, 15, true);
-		} catch (ArrayIndexOutOfBoundsException e) {
-			throw new AssertionFailedError("Identified bug 45639");
-		}
-		ColumnInfoRecord[] cirs = CIRCollector.getRecords(agg);
-		assertEquals(5, cirs.length);
+
+		// bug 45639 - ArrayIndexOutOfBoundsException
+		agg.groupColumnRange( 1, 15, true);
+
+		List<Record> cirs = new ArrayList<>();
+		agg.visitContainedRecords(cirs::add);
+
+		assertEquals(5, cirs.size());
 		confirmCIR(cirs, 0,  1,  3, 1, false, false);
 		confirmCIR(cirs, 1,  4,  6, 2, false, false);
 		confirmCIR(cirs, 2,  7,  9, 3, false, false);
@@ -106,14 +89,14 @@ public final class TestColumnInfoRecords
 		agg.groupColumnRange(1, 15, true);
 		agg.groupColumnRange(4, 12, true);
 
-		ColumnInfoRecord[] cirs;
+		List<Record> cirs = new ArrayList<>();
 
 		// collapse both inner and outer groups
 		agg.collapseColumn(6);
 		agg.collapseColumn(3);
 
-		cirs = CIRCollector.getRecords(agg);
-		assertEquals(5, cirs.length);
+		agg.visitContainedRecords(cirs::add);
+		assertEquals(5, cirs.size());
 		confirmCIR(cirs, 0,  1,  3, 1, true, false);
 		confirmCIR(cirs, 1,  4, 12, 2, true, false);
 		confirmCIR(cirs, 2, 13, 13, 1, true, true);
@@ -123,19 +106,19 @@ public final class TestColumnInfoRecords
 		// just expand the inner group
 		agg.expandColumn(6);
 
-		cirs = CIRCollector.getRecords(agg);
-		assertEquals(4, cirs.length);
-		if (!cirs[1].getHidden()) {
-			throw new AssertionFailedError("Inner group should still be hidden");
-		}
+		cirs.clear();
+		agg.visitContainedRecords(cirs::add);
+		assertEquals(4, cirs.size());
+		assertTrue("Inner group should still be hidden", ((ColumnInfoRecord)cirs.get(1)).getHidden());
 		confirmCIR(cirs, 0,  1,  3, 1, true, false);
 		confirmCIR(cirs, 1,  4, 12, 2, true, false);
 		confirmCIR(cirs, 2, 13, 15, 1, true, false);
 		confirmCIR(cirs, 3, 16, 16, 0, false, true);
 	}
-	
-	private static void confirmCIR(ColumnInfoRecord[] cirs, int ix, int startColIx, int endColIx, int level, boolean isHidden, boolean isCollapsed) {
-		ColumnInfoRecord cir = cirs[ix];
+
+	private static void confirmCIR(List<Record> cirs, int ix, int startColIx, int endColIx, int level, boolean isHidden, boolean isCollapsed) {
+		assertTrue(cirs.get(ix) instanceof ColumnInfoRecord);
+		ColumnInfoRecord cir = (ColumnInfoRecord)cirs.get(ix);
 		assertEquals("startColIx", startColIx, cir.getFirstColumn());
 		assertEquals("endColIx", endColIx, cir.getLastColumn());
 		assertEquals("level", level, cir.getOutlineLevel());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java Fri Dec 27 23:00:13 2019
@@ -17,27 +17,27 @@
 
 package org.apache.poi.hssf.record.aggregates;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.poi.hssf.model.HSSFFormulaParser;
 import org.apache.poi.hssf.record.FormulaRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.StringRecord;
-import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
 import org.apache.poi.ss.formula.FormulaRenderer;
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.ptg.ExpPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.util.RecordFormatException;
+import org.junit.Test;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-/**
- *
- * @author avik
- */
-public final class TestFormulaRecordAggregate extends TestCase {
+public final class TestFormulaRecordAggregate {
 
+	@Test
 	public void testBasic() {
 		FormulaRecord f = new FormulaRecord();
 		f.setCachedResultTypeString();
@@ -56,29 +56,22 @@ public final class TestFormulaRecordAggr
 	 * This file seems to open in Excel (2007) with no trouble.  When it is re-saved, Excel omits
 	 * the extra record.  POI should do the same.
 	 */
+	@Test
 	public void testExtraStringRecord_bug46213() {
 		FormulaRecord fr = new FormulaRecord();
 		fr.setValue(2.0);
 		StringRecord sr = new StringRecord();
 		sr.setString("NA");
 		SharedValueManager svm = SharedValueManager.createEmpty();
-		FormulaRecordAggregate fra;
-
-		try {
-			fra = new FormulaRecordAggregate(fr, sr, svm);
-		} catch (RecordFormatException e) {
-			if ("String record was  supplied but formula record flag is not  set".equals(e.getMessage())) {
-				throw new AssertionFailedError("Identified bug 46213");
-			}
-			throw e;
-		}
-		RecordCollector rc = new RecordCollector();
-		fra.visitContainedRecords(rc);
-		Record[] vraRecs = rc.getRecords();
-		assertEquals(1, vraRecs.length);
-		assertEquals(fr, vraRecs[0]);
+		// bug 46213 -> String record was  supplied but formula record flag is not  set
+		FormulaRecordAggregate fra = new FormulaRecordAggregate(fr, sr, svm);
+		List<Record> vraRecs = new ArrayList<>();
+		fra.visitContainedRecords(vraRecs::add);
+		assertEquals(1, vraRecs.size());
+		assertEquals(fr, vraRecs.get(0));
 	}
 
+	@Test
 	public void testArrayFormulas() {
 		int rownum = 4;
 		int colnum = 4;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java Fri Dec 27 23:00:13 2019
@@ -18,29 +18,54 @@
 package org.apache.poi.hssf.record.aggregates;
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.Arrays;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import java.util.List;
+import java.util.stream.Stream;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.model.RecordStream;
-import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.record.BOFRecord;
+import org.apache.poi.hssf.record.BottomMarginRecord;
+import org.apache.poi.hssf.record.ContinueRecord;
+import org.apache.poi.hssf.record.DimensionsRecord;
+import org.apache.poi.hssf.record.EOFRecord;
+import org.apache.poi.hssf.record.FooterRecord;
+import org.apache.poi.hssf.record.HCenterRecord;
+import org.apache.poi.hssf.record.HeaderFooterRecord;
+import org.apache.poi.hssf.record.HeaderRecord;
+import org.apache.poi.hssf.record.IndexRecord;
+import org.apache.poi.hssf.record.NumberRecord;
+import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.SelectionRecord;
+import org.apache.poi.hssf.record.UnknownRecord;
+import org.apache.poi.hssf.record.UserSViewBegin;
+import org.apache.poi.hssf.record.UserSViewEnd;
+import org.apache.poi.hssf.record.VCenterRecord;
+import org.apache.poi.hssf.record.WindowTwoRecord;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
 import org.apache.poi.util.HexRead;
+import org.apache.poi.util.RecordFormatException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * Tess for {@link PageSettingsBlock}
- *
- * @author Dmitriy Kumshayev
  */
-public final class TestPageSettingsBlock extends TestCase {
+public final class TestPageSettingsBlock {
+	@Rule
+	public ExpectedException thrown = ExpectedException.none();
 
+	@Test
 	public void testPrintSetup_bug46548() {
 
 		// PageSettingBlock in this file contains PLS (sid=x004D) record
@@ -49,18 +74,15 @@ public final class TestPageSettingsBlock
 		HSSFSheet sheet = wb.getSheetAt(0);
 		HSSFPrintSetup ps = sheet.getPrintSetup();
 
-		try {
-			ps.getCopies();
-		} catch (NullPointerException e) {
-			e.printStackTrace();
-			throw new AssertionFailedError("Identified bug 46548: PageSettingBlock missing PrintSetupRecord record");
-		}
+		// bug 46548: PageSettingBlock missing PrintSetupRecord record
+		assertEquals(1, ps.getCopies());
 	}
 
 	/**
 	 * Bug 46840 occurred because POI failed to recognise HEADERFOOTER as part of the
 	 * {@link PageSettingsBlock}.
 	 */
+	@Test
 	public void testHeaderFooter_bug46840() {
 
 		int rowIx = 5;
@@ -86,25 +108,18 @@ public final class TestPageSettingsBlock
 				EOFRecord.instance,
 		};
 		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
-		InternalSheet sheet;
-		try {
-			sheet = InternalSheet.createSheet(rs);
-		} catch (RuntimeException e) {
-			if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
-				throw new AssertionFailedError("Identified bug 46480");
-			}
-			throw e;
-		}
-
-		RecordCollector rv = new RecordCollector();
-		sheet.visitContainedRecords(rv, rowIx);
-		Record[] outRecs = rv.getRecords();
-		assertEquals(13, outRecs.length);
+		// bug 46480- two Page Settings Blocks found in the same sheet
+		InternalSheet sheet = InternalSheet.createSheet(rs);
+
+		List<Record> outRecs = new ArrayList<>();
+		sheet.visitContainedRecords(outRecs::add, rowIx);
+		assertEquals(13, outRecs.size());
 	}
 
 	/**
 	 * Bug 46953 occurred because POI didn't handle late PSB records properly.
 	 */
+	@Test
 	public void testLateHeaderFooter_bug46953() {
 
 		int rowIx = 5;
@@ -126,22 +141,16 @@ public final class TestPageSettingsBlock
 		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
 		InternalSheet sheet = InternalSheet.createSheet(rs);
 
-		RecordCollector rv = new RecordCollector();
-		sheet.visitContainedRecords(rv, 0);
-		Record[] outRecs = rv.getRecords();
-		if (outRecs[4] == EOFRecord.instance) {
-			throw new AssertionFailedError("Identified bug 46953 - EOF incorrectly appended to PSB");
-		}
-		assertEquals(recs.length+1, outRecs.length); // +1 for index record
-
-		assertEquals(BOFRecord.class, outRecs[0].getClass());
-		assertEquals(IndexRecord.class, outRecs[1].getClass());
-		assertEquals(HeaderRecord.class, outRecs[2].getClass());
-		assertEquals(FooterRecord.class, outRecs[3].getClass());
-		assertEquals(HeaderFooterRecord.class, outRecs[4].getClass());
-		assertEquals(DimensionsRecord.class, outRecs[5].getClass());
-		assertEquals(WindowTwoRecord.class, outRecs[6].getClass());
-		assertEquals(EOFRecord.instance, outRecs[7]);
+		List<Record> outRecs = new ArrayList<>();
+		sheet.visitContainedRecords(outRecs::add, 0);
+		// Identified bug 46953 - EOF incorrectly appended to PSB
+		assertNotEquals(EOFRecord.instance, outRecs.get(4));
+		assertEquals(recs.length+1, outRecs.size()); // +1 for index record
+
+		Class<?>[] act = outRecs.stream().map(Object::getClass).toArray(Class[]::new);
+		Class<?>[] exp = { BOFRecord.class, IndexRecord.class, HeaderRecord.class, FooterRecord.class,
+				HeaderFooterRecord.class, DimensionsRecord.class, WindowTwoRecord.class, EOFRecord.class };
+		assertArrayEquals(exp, act);
 	}
 	/**
 	 * Bug 47199 was due to the margin records being located well after the initial PSB records.
@@ -155,53 +164,41 @@ public final class TestPageSettingsBlock
 	 * <li>BottomMargin(0x0029)</li>
 	 * </ul>
 	 */
+	@Test
 	public void testLateMargins_bug47199() {
 
+		BottomMarginRecord bottomMargin = new BottomMarginRecord();
+		bottomMargin.setMargin(0.787F);
+
 		Record[] recs = {
 				BOFRecord.createSheetBOF(),
 				new HeaderRecord("&LSales Figures"),
 				new FooterRecord("&LJanuary"),
 				new DimensionsRecord(),
-				createBottomMargin(0.787F),
+				bottomMargin,
 				new WindowTwoRecord(),
 				EOFRecord.instance,
 		};
 		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
 
-		InternalSheet sheet;
-		try {
-			sheet = InternalSheet.createSheet(rs);
-		} catch (RuntimeException e) {
-			if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
-				throw new AssertionFailedError("Identified bug 47199a - failed to process late margings records");
-			}
-			throw e;
-		}
-
-		RecordCollector rv = new RecordCollector();
-		sheet.visitContainedRecords(rv, 0);
-		Record[] outRecs = rv.getRecords();
-		assertEquals(recs.length+1, outRecs.length); // +1 for index record
-
-		assertEquals(BOFRecord.class, outRecs[0].getClass());
-		assertEquals(IndexRecord.class, outRecs[1].getClass());
-		assertEquals(HeaderRecord.class, outRecs[2].getClass());
-		assertEquals(FooterRecord.class, outRecs[3].getClass());
-		assertEquals(DimensionsRecord.class, outRecs[5].getClass());
-		assertEquals(WindowTwoRecord.class, outRecs[6].getClass());
-		assertEquals(EOFRecord.instance, outRecs[7]);
-	}
+		// bug 47199a - failed to process late margins records
+		InternalSheet sheet = InternalSheet.createSheet(rs);
 
-	private Record createBottomMargin(float value) {
-		BottomMarginRecord result = new BottomMarginRecord();
-		result.setMargin(value);
-		return result;
+		List<Record> outRecs = new ArrayList<>();
+		sheet.visitContainedRecords(outRecs::add, 0);
+		assertEquals(recs.length+1, outRecs.size()); // +1 for index record
+
+		Class<?>[] act = outRecs.stream().map(Object::getClass).toArray(Class[]::new);
+		Class<?>[] exp = { BOFRecord.class, IndexRecord.class, HeaderRecord.class, FooterRecord.class,
+				BottomMarginRecord.class, DimensionsRecord.class, WindowTwoRecord.class, EOFRecord.class };
+		assertArrayEquals(exp, act);
 	}
 
 	/**
 	 * The PageSettingsBlock should not allow multiple copies of the same record.  This extra assertion
 	 * was added while fixing bug 47199.  All existing POI test samples comply with this requirement.
 	 */
+	@Test
 	public void testDuplicatePSBRecord_bug47199() {
 		// Hypothetical setup of PSB records which should cause POI to crash
 		Record[] recs = {
@@ -210,18 +207,9 @@ public final class TestPageSettingsBlock
 		};
 		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
 
-		try {
-			new PageSettingsBlock(rs);
-			throw new AssertionFailedError("Identified bug 47199b - duplicate PSB records should not be allowed");
-		} catch (org.apache.poi.util.RecordFormatException e) {
-			if (!e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x14)")) {
-				throw new AssertionFailedError("Expected RecordFormatException due to duplicate PSB record");
-			}
-		}
-	}
-
-	private static UnknownRecord ur(int sid, String hexData) {
-		return new UnknownRecord(sid, HexRead.readFromString(hexData));
+		thrown.expectMessage("Duplicate PageSettingsBlock record (sid=0x14)");
+		thrown.expect(RecordFormatException.class);
+		new PageSettingsBlock(rs);
 	}
 
 	/**
@@ -229,6 +217,7 @@ public final class TestPageSettingsBlock
 	 * This is not critical functionality but it has been decided to keep POI consistent with
 	 * Excel in this regard.
 	 */
+	@Test
 	public void testMissingHeaderFooter() {
 		// initialise PSB with some records, but not the header / footer
 		Record[] recs = {
@@ -239,23 +228,19 @@ public final class TestPageSettingsBlock
 		PageSettingsBlock psb = new PageSettingsBlock(rs);
 
 		// serialize the PSB to see what records come out
-		RecordCollector rc = new RecordCollector();
-		psb.visitContainedRecords(rc);
-		Record[] outRecs = rc.getRecords();
-
-		if (outRecs.length == 2) {
-			throw new AssertionFailedError("PageSettingsBlock didn't add missing header/footer records");
-		}
-		assertEquals(4, outRecs.length);
-		assertEquals(HeaderRecord.class, outRecs[0].getClass());
-		assertEquals(FooterRecord.class, outRecs[1].getClass());
-		assertEquals(HCenterRecord.class, outRecs[2].getClass());
-		assertEquals(VCenterRecord.class, outRecs[3].getClass());
+		List<Record> outRecs = new ArrayList<>();
+		psb.visitContainedRecords(outRecs::add);
+
+		assertNotEquals("PageSettingsBlock didn't add missing header/footer records", 2, outRecs.size());
+
+		Class<?>[] act = outRecs.stream().map(Object::getClass).toArray(Class[]::new);
+		Class<?>[] exp = { HeaderRecord.class, FooterRecord.class, HCenterRecord.class, VCenterRecord.class};
+		assertArrayEquals(exp, act);
 
 		// make sure the added header / footer records are empty
-		HeaderRecord hr = (HeaderRecord) outRecs[0];
+		HeaderRecord hr = (HeaderRecord) outRecs.get(0);
 		assertEquals("", hr.getText());
-		FooterRecord fr = (FooterRecord) outRecs[1];
+		FooterRecord fr = (FooterRecord) outRecs.get(1);
 		assertEquals("", fr.getText());
 	}
 
@@ -268,9 +253,10 @@ public final class TestPageSettingsBlock
 	 *
 	 * As of June 2009, PLS is still uninterpreted by POI
 	 */
+	@Test
 	public void testDuplicatePLS_bug47415() {
-		Record plsA = ur(UnknownRecord.PLS_004D, "BA AD F0 0D");
-		Record plsB = ur(UnknownRecord.PLS_004D, "DE AD BE EF");
+		Record plsA = new UnknownRecord(UnknownRecord.PLS_004D, HexRead.readFromString("BA AD F0 0D"));
+		Record plsB = new UnknownRecord(UnknownRecord.PLS_004D, HexRead.readFromString("DE AD BE EF"));
 		Record contB1 = new ContinueRecord(HexRead.readFromString("FE ED"));
 		Record contB2 = new ContinueRecord(HexRead.readFromString("FA CE"));
 		Record[] recs = {
@@ -282,25 +268,18 @@ public final class TestPageSettingsBlock
 				plsB, contB1, contB2, // make sure continuing PLS is still OK
 		};
 		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
-		PageSettingsBlock psb;
-		try {
-			psb = new PageSettingsBlock(rs);
-		} catch (org.apache.poi.util.RecordFormatException e) {
-			if ("Duplicate PageSettingsBlock record (sid=0x4d)".equals(e.getMessage())) {
-				throw new AssertionFailedError("Identified bug 47415");
-			}
-			throw e;
-		}
+		// bug 47415 - Duplicate PageSettingsBlock record (sid=0x4d)
+		PageSettingsBlock psb = new PageSettingsBlock(rs);
 
 		// serialize the PSB to see what records come out
-		RecordCollector rc = new RecordCollector();
-		psb.visitContainedRecords(rc);
-		Record[] outRecs = rc.getRecords();
+		List<Record> outRecs = new ArrayList<>();
+		psb.visitContainedRecords(outRecs::add);
 
 		// records were assembled in standard order, so this simple check is OK
-		assertArrayEquals(recs, outRecs);
+		assertArrayEquals(recs, outRecs.toArray(new Record[0]));
 	}
 
+	@Test
     public void testDuplicateHeaderFooter_bug48026() {
 
         Record[] recs = {
@@ -327,21 +306,13 @@ public final class TestPageSettingsBlock
                 EOFRecord.instance,
         };
         RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
-        InternalSheet sheet;
-        try {
-            sheet = InternalSheet.createSheet(rs);
-        } catch (RuntimeException e) {
-            if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x89c)")) {
-                throw new AssertionFailedError("Identified bug 48026");
-            }
-            throw e;
-        }
-
-        RecordCollector rv = new RecordCollector();
-        sheet.visitContainedRecords(rv, 0);
-        Record[] outRecs = rv.getRecords();
+        // bug 48026 - Duplicate PageSettingsBlock record (sid=0x89c)
+        InternalSheet sheet = InternalSheet.createSheet(rs);
 
-        assertEquals(recs.length, outRecs.length);
+        List<Record> outRecs = new ArrayList<>();
+        sheet.visitContainedRecords(outRecs::add, 0);
+
+        assertEquals(recs.length, outRecs.size());
         //expected order of records:
         Record[] expectedRecs = {
                 recs[0],  //BOFRecord
@@ -362,9 +333,12 @@ public final class TestPageSettingsBlock
 
                 recs[11],  //EOFRecord
         };
-        for(int i=0; i < expectedRecs.length; i++){
-            assertEquals("Record mismatch at index " + i,  expectedRecs[i].getClass(), outRecs[i].getClass());
-        }
+
+        assertArrayEquals(
+			Stream.of(expectedRecs).map(Object::getClass).toArray(Class[]::new),
+			outRecs.stream().map(Object::getClass).toArray(Class[]::new)
+		);
+
         HeaderFooterRecord hd1 = (HeaderFooterRecord)expectedRecs[4];
         //GUID is zero
         assertArrayEquals(new byte[16], hd1.getGuid());
@@ -377,6 +351,7 @@ public final class TestPageSettingsBlock
         assertArrayEquals(svb.getGuid(), hd2.getGuid());
     }
 
+	@Test
     public void testDuplicateHeaderFooterInside_bug48026() {
 
         Record[] recs = {
@@ -404,21 +379,13 @@ public final class TestPageSettingsBlock
                 EOFRecord.instance,
         };
         RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
-        InternalSheet sheet;
-        try {
-            sheet = InternalSheet.createSheet(rs);
-        } catch (RuntimeException e) {
-            if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x89c)")) {
-                throw new AssertionFailedError("Identified bug 48026");
-            }
-            throw e;
-        }
-
-        RecordCollector rv = new RecordCollector();
-        sheet.visitContainedRecords(rv, 0);
-        Record[] outRecs = rv.getRecords();
+        // Bug 48026 : Duplicate PageSettingsBlock record (sid=0x89c)
+        InternalSheet sheet = InternalSheet.createSheet(rs);
+
+		List<Record> outRecs = new ArrayList<>();
+        sheet.visitContainedRecords(outRecs::add, 0);
 
-        assertEquals(recs.length+1, outRecs.length);
+        assertEquals(recs.length+1, outRecs.size());
         //expected order of records:
         Record[] expectedRecs = {
                 recs[0],  //BOFRecord
@@ -441,9 +408,12 @@ public final class TestPageSettingsBlock
 
                 recs[11],  //EOFRecord
         };
-        for(int i=0; i < expectedRecs.length; i++){
-            assertEquals("Record mismatch at index " + i,  expectedRecs[i].getClass(), outRecs[i].getClass());
-        }
+
+		assertArrayEquals(
+			Stream.of(expectedRecs).map(Object::getClass).toArray(Class[]::new),
+			outRecs.stream().map(Object::getClass).toArray(Class[]::new)
+		);
+
         HeaderFooterRecord hd1 = (HeaderFooterRecord)expectedRecs[10];
         //GUID is zero
         assertArrayEquals(new byte[16], hd1.getGuid());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java Fri Dec 27 23:00:13 2019
@@ -20,10 +20,11 @@ package org.apache.poi.hssf.record.aggre
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.model.RecordStream;
@@ -38,8 +39,6 @@ import org.apache.poi.hssf.record.Shared
 import org.apache.poi.hssf.record.TableRecord;
 import org.apache.poi.hssf.record.UnknownRecord;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.RecordInspector;
-import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
 import org.apache.poi.hssf.util.CellRangeAddress8Bit;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.Test;
@@ -71,18 +70,19 @@ public final class TestRowRecordsAggrega
 	 */
     @Test
 	public void testArraysAndTables() throws Exception {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testArraysAndTables.xls");
-		Record[] sheetRecs = RecordInspector.getRecords(wb.getSheetAt(0), 0);
-
-		int countArrayFormulas = verifySharedValues(sheetRecs, ArrayRecord.class);
-		assertEquals(5, countArrayFormulas);
-		int countTableFormulas = verifySharedValues(sheetRecs, TableRecord.class);
-		assertEquals(3, countTableFormulas);
-
-		// Note - SharedFormulaRecords are currently not re-serialized by POI (each is extracted
-		// into many non-shared formulas), but if they ever were, the same rules would apply.
-		int countSharedFormulas = verifySharedValues(sheetRecs, SharedFormulaRecord.class);
-		assertEquals(0, countSharedFormulas);
+		try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testArraysAndTables.xls")) {
+			final List<Record> sheetRecs = new ArrayList<>();
+			wb.getSheetAt(0).getSheet().visitContainedRecords(sheetRecs::add, 0);
+
+			int countArrayFormulas = verifySharedValues(sheetRecs, ArrayRecord.class);
+			assertEquals(5, countArrayFormulas);
+			int countTableFormulas = verifySharedValues(sheetRecs, TableRecord.class);
+			assertEquals(3, countTableFormulas);
+
+			// Note - SharedFormulaRecords are currently not re-serialized by POI (each is extracted
+			// into many non-shared formulas), but if they ever were, the same rules would apply.
+			int countSharedFormulas = verifySharedValues(sheetRecs, SharedFormulaRecord.class);
+			assertEquals(0, countSharedFormulas);
 
 
 //		if (false) { // set true to observe re-serialized file
@@ -96,18 +96,18 @@ public final class TestRowRecordsAggrega
 //			}
 //			System.out.println("Output file to " + f.getAbsolutePath());
 //		}
-		
-		wb.close();
+
+		}
 	}
 
-	private static int verifySharedValues(Record[] recs, Class<? extends SharedValueRecordBase> shfClass) {
+	private static int verifySharedValues(List<Record> recs, Class<? extends SharedValueRecordBase> shfClass) {
 
 		int result =0;
-		for(int i=0; i<recs.length; i++) {
-			Record rec = recs[i];
+		for(int i=0; i<recs.size(); i++) {
+			Record rec = recs.get(i);
 			if (rec.getClass() == shfClass) {
 				result++;
-				Record prevRec = recs[i-1];
+				Record prevRec = recs.get(i-1);
 				if (!(prevRec instanceof FormulaRecord)) {
 					fail("Bad record order at index "
 							+ i + ": Formula record expected but got ("
@@ -153,9 +153,9 @@ public final class TestRowRecordsAggrega
 			}
 			throw e;
 		}
-		RecordCollector rv = new RecordCollector();
-		rra.visitContainedRecords(rv);
-		Record[] outRecs = rv.getRecords();
-		assertEquals(5, outRecs.length);
+
+		List<Record> outRecs = new ArrayList<>();
+		rra.visitContainedRecords(outRecs::add);
+		assertEquals(5, outRecs.size());
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java Fri Dec 27 23:00:13 2019
@@ -17,27 +17,23 @@
 
 package org.apache.poi.hssf.record.aggregates;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
 import java.util.Collection;
 import java.util.HashMap;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import org.apache.poi.POITestCase;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.SharedFormulaRecord;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.RecordInspector;
+import org.junit.Test;
 
 /**
  * Tests for {@link SharedValueManager}
- *
- * @author Josh Micich
  */
-public final class TestSharedValueManager extends TestCase {
+public final class TestSharedValueManager {
 
 	/**
 	 * This Excel workbook contains two sheets that each have a pair of overlapping shared formula
@@ -66,61 +62,43 @@ public final class TestSharedValueManage
 	 * This bug happened when there were two or more shared formula ranges that overlapped.  POI
 	 * would sometimes associate formulas in the overlapping region with the wrong shared formula
 	 */
+	@Test
 	public void testPartiallyOverlappingRanges() {
-		Record[] records;
 
-		int attempt=1;
-		do {
+
+		for (int attempt=1; attempt < MAX_ATTEMPTS; attempt++) {
 			HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
 
 			HSSFSheet sheet = wb.getSheetAt(0);
-			RecordInspector.getRecords(sheet, 0);
 			assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
-			if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
-				throw new AssertionFailedError("Identified bug - wrong shared formula record chosen"
-						+ " (attempt " + attempt + ")");
-			}
-			assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
-			records = RecordInspector.getRecords(sheet, 0);
-		} while (attempt++ < MAX_ATTEMPTS);
-
-		int count=0;
-		for (Record record : records) {
-			if (record instanceof SharedFormulaRecord) {
-				count++;
-			}
+			String act = sheet.getRow(3).getCell(0).getCellFormula();
+			assertNotEquals("wrong shared formula record chosen", "1+1", act);
+			act = sheet.getRow(3).getCell(0).getCellFormula();
+			assertEquals("2+2", act);
+
+			int[] count = { 0 };
+			sheet.getSheet().visitContainedRecords(r -> count[0] += r instanceof SharedFormulaRecord ? 1 : 0, 0);
+			assertEquals(2, count[0]);
 		}
-		assertEquals(2, count);
 	}
 
 	/**
 	 * This bug occurs for similar reasons to the bug in {@link #testPartiallyOverlappingRanges()}
 	 * but the symptoms are much uglier - serialization fails with {@link NullPointerException}.<br>
 	 */
+	@Test
 	public void testCompletelyOverlappedRanges() {
-		Record[] records;
-
-		int attempt=1;
-		do {
+		for (int attempt=1; attempt < MAX_ATTEMPTS; attempt++) {
 			HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
 
 			HSSFSheet sheet = wb.getSheetAt(1);
-			try {
-				records = RecordInspector.getRecords(sheet, 0);
-			} catch (NullPointerException e) {
-				throw new AssertionFailedError("Identified bug " +
-						"- cannot reserialize completely overlapped shared formula"
-						+ " (attempt " + attempt + ")");
-			}
-		} while (attempt++ < MAX_ATTEMPTS);
-
-		int count=0;
-		for (Record record : records) {
-			if (record instanceof SharedFormulaRecord) {
-				count++;
-			}
+
+			int[] count = { 0 };
+
+			// NullPointerException -> cannot reserialize completely overlapped shared formula
+			sheet.getSheet().visitContainedRecords(r -> count[0] += r instanceof SharedFormulaRecord ? 1 : 0, 0);
+			assertEquals(2, count[0]);
 		}
-		assertEquals(2, count);
 	}
 
 	/**
@@ -133,6 +111,7 @@ public final class TestSharedValueManage
 	 * Two existing sample files (15228.xls and ex45046-21984.xls) had similar issues.
 	 * These were not explored fully, but seem to be fixed now.
 	 */
+	@Test
 	public void testRecalculateFormulas47747() {
 
 		/*
@@ -155,30 +134,13 @@ public final class TestSharedValueManage
 
 		// pick out a cell from within the second shared formula group
 		HSSFCell cell = wb.getSheetAt(0).getRow(23).getCell(0);
-		String formulaText;
-		try {
-			formulaText = cell.getCellFormula();
-			// succeeds if the formula record has been associated
-			// with the second shared formula group
-		} catch (RuntimeException e) {
-			// bug occurs if the formula record has been associated
-			// with the first shared formula group
-			if ("Shared Formula Conversion: Coding Error".equals(e.getMessage())) {
-				throw new AssertionFailedError("Identified bug 47747");
-			}
-			throw e;
-		}
+		// bug occurs if the formula record has been associated
+		// with the first (and not the second) shared formula group
+		String formulaText = cell.getCellFormula();
 		assertEquals("$AF24*A$7", formulaText);
 	}
 
-	/**
-	 * Convenience test method for digging the {@link SharedValueManager} out of a
-	 * {@link RowRecordsAggregate}.
-	 */
-	public static SharedValueManager extractFromRRA(RowRecordsAggregate rra) {
-		return POITestCase.getFieldValue(RowRecordsAggregate.class, rra, SharedValueManager.class, "_sharedValueManager");
-	}
-
+	@Test
     public void testBug52527() {
         HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("52527.xls");
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java Fri Dec 27 23:00:13 2019
@@ -17,7 +17,11 @@
 
 package org.apache.poi.hssf.record.aggregates;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -42,15 +46,13 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.util.HexRead;
 import org.junit.Test;
 
-import junit.framework.AssertionFailedError;
-
 /**
  * Tests for {@link ValueRecordsAggregate}
  */
 public final class TestValueRecordsAggregate {
 	private static final String ABNORMAL_SHARED_FORMULA_FLAG_TEST_FILE = "AbnormalSharedFormulaFlag.xls";
 	private final ValueRecordsAggregate valueRecord = new ValueRecordsAggregate();
-	
+
 	private List<CellValueRecordInterface> getValueRecords() {
 	    List<CellValueRecordInterface> list = new ArrayList<>();
 	    for ( CellValueRecordInterface rec : valueRecord ) {
@@ -263,7 +265,7 @@ public final class TestValueRecordsAggre
 		assertNotEquals("found bug 44449 (Wrong SharedFormulaRecord was used).", "\"second formula\"", cellFormula);
 
 		assertEquals("Something else wrong with this test case", "\"first formula\"", cellFormula);
-		
+
 		wb.close();
 	}
 	private static String getFormulaFromFirstCell(HSSFSheet s, int rowIx) {
@@ -310,21 +312,15 @@ public final class TestValueRecordsAggre
 
 		return crc.getValue();
 	}
-	
+
     @Test
 	public void testRemoveNewRow_bug46312() {
 		// To make bug occur, rowIndex needs to be >= ValueRecordsAggregate.records.length
 		int rowIndex = 30;
 
 		ValueRecordsAggregate vra = new ValueRecordsAggregate();
-		try {
-			vra.removeAllCellsValuesForRow(rowIndex);
-		} catch (IllegalArgumentException e) {
-			if (e.getMessage().equals("Specified rowIndex 30 is outside the allowable range (0..30)")) {
-				throw new AssertionFailedError("Identified bug 46312");
-			}
-			throw e;
-		}
+		// bug 46312 - Specified rowIndex 30 is outside the allowable range (0..30)
+		vra.removeAllCellsValuesForRow(rowIndex);
 
 //		if (false) { // same bug as demonstrated through usermodel API
 //
@@ -395,18 +391,14 @@ public final class TestValueRecordsAggre
 		}
 
 		final BlankStats bs = new BlankStats();
-		RecordVisitor rv = new RecordVisitor() {
-
-			@Override
-            public void visitRecord(Record r) {
-				if (r instanceof MulBlankRecord) {
-					MulBlankRecord mbr = (MulBlankRecord) r;
-					bs.countMulBlankRecords++;
-					bs.countBlankCells += mbr.getNumColumns();
-				} else if (r instanceof BlankRecord) {
-					bs.countSingleBlankRecords++;
-					bs.countBlankCells++;
-				}
+		RecordVisitor rv = r -> {
+			if (r instanceof MulBlankRecord) {
+				MulBlankRecord mbr = (MulBlankRecord) r;
+				bs.countMulBlankRecords++;
+				bs.countBlankCells += mbr.getNumColumns();
+			} else if (r instanceof BlankRecord) {
+				bs.countSingleBlankRecords++;
+				bs.countBlankCells++;
 			}
 		};
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/cf/TestCellRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/cf/TestCellRange.java?rev=1872041&r1=1872040&r2=1872041&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/cf/TestCellRange.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/cf/TestCellRange.java Fri Dec 27 23:00:13 2019
@@ -17,19 +17,20 @@ limitations under the License.
 
 package org.apache.poi.hssf.record.cf;
 
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import java.util.Arrays;
 
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeUtil;
+import org.junit.Test;
 
 /**
  * Tests CellRange operations.
  */
-public final class TestCellRange extends TestCase
-{
+public final class TestCellRange {
 	private static final CellRangeAddress biggest     = createCR( 0, -1, 0,-1);
 	private static final CellRangeAddress tenthColumn = createCR( 0, -1,10,10);
 	private static final CellRangeAddress tenthRow    = createCR(10, 10, 0,-1);
@@ -41,33 +42,34 @@ public final class TestCellRange extends
 	private static final CellRangeAddress[] sampleRanges = {
 		biggest, tenthColumn, tenthRow, box10x10, box9x9, box10to20c, oneCell,
 	};
-	
+
 	/** cross-reference of <tt>contains()</tt> operations for sampleRanges against itself */
-	private static final boolean [][] containsExpectedResults = 
+	private static final boolean [][] containsExpectedResults =
     {
 	//               biggest, tenthColumn, tenthRow, box10x10, box9x9, box10to20c, oneCell
-	/*biggest    */ {true,       true ,    true ,    true ,    true ,      true ,  true},	
-	/*tenthColumn*/ {false,      true ,    false,    false,    false,      false,  true},	
-	/*tenthRow   */ {false,      false,    true ,    false,    false,      false,  true},	
-	/*box10x10   */ {false,      false,    false,    true ,    true ,      false,  true},	
-	/*box9x9     */ {false,      false,    false,    false,    true ,      false, false},	
-	/*box10to20c */ {false,      false,    false,    false,    false,      true ,  true},	
-	/*oneCell    */ {false,      false,    false,    false,    false,      false,  true},	
+	/*biggest    */ {true,       true ,    true ,    true ,    true ,      true ,  true},
+	/*tenthColumn*/ {false,      true ,    false,    false,    false,      false,  true},
+	/*tenthRow   */ {false,      false,    true ,    false,    false,      false,  true},
+	/*box10x10   */ {false,      false,    false,    true ,    true ,      false,  true},
+	/*box9x9     */ {false,      false,    false,    false,    true ,      false, false},
+	/*box10to20c */ {false,      false,    false,    false,    false,      true ,  true},
+	/*oneCell    */ {false,      false,    false,    false,    false,      false,  true},
      } ;
 
 	/**
-	 * @param lastRow pass -1 for max row index 
+	 * @param lastRow pass -1 for max row index
 	 * @param lastCol pass -1 for max col index
 	 */
 	private static CellRangeAddress createCR(int firstRow, int lastRow, int firstCol, int lastCol) {
 		// max row & max col limit as per BIFF8
 		return new CellRangeAddress(
-				firstRow, 
-				lastRow == -1 ? 0xFFFF : lastRow, 
+				firstRow,
+				lastRow == -1 ? 0xFFFF : lastRow,
 				firstCol,
 				lastCol == -1 ? 0x00FF : lastCol);
 	}
-	
+
+	@Test
 	public void testContainsMethod()
 	{
 		CellRangeAddress [] ranges = sampleRanges;
@@ -93,8 +95,8 @@ public final class TestCellRange extends
 	private static final CellRangeAddress box4     = createCR( 2, 3, 2,3);
 	private static final CellRangeAddress box5     = createCR( 1, 3, 1,3);
 
-	public void testHasSharedBorderMethod()
-	{
+	@Test
+	public void testHasSharedBorderMethod() {
 		assertFalse(CellRangeUtil.hasExactSharedBorder(col1, col1));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(col2, col2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(col1, col2));
@@ -104,7 +106,7 @@ public final class TestCellRange extends
 		assertFalse(CellRangeUtil.hasExactSharedBorder(row2, row2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(row1, row2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(row2, row1));
-		
+
 		assertFalse(CellRangeUtil.hasExactSharedBorder(row1, col1));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(row1, col2));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(col1, row1));
@@ -114,30 +116,30 @@ public final class TestCellRange extends
 		assertFalse(CellRangeUtil.hasExactSharedBorder(col1, row2));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(col2, row2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(col2, col1));
-		
+
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box1, box1));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box1, box2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box1, box3));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box1, box4));
-		
+
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box2, box1));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box2, box2));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box2, box3));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box2, box4));
-		
+
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box3, box1));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box3, box2));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box3, box3));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box3, box4));
-		
+
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box4, box1));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box4, box2));
 		assertTrue(CellRangeUtil.hasExactSharedBorder(box4, box3));
 		assertFalse(CellRangeUtil.hasExactSharedBorder(box4, box4));
 	}
 
-	public void testIntersectMethod()
-	{
+	@Test
+	public void testIntersectMethod() {
 		assertEquals(CellRangeUtil.OVERLAP, CellRangeUtil.intersect(box0, box5));
 		assertEquals(CellRangeUtil.OVERLAP, CellRangeUtil.intersect(box5, box0));
 		assertEquals(CellRangeUtil.NO_INTERSECTION, CellRangeUtil.intersect(box1, box4));
@@ -153,45 +155,40 @@ public final class TestCellRange extends
 		assertEquals(CellRangeUtil.OVERLAP, CellRangeUtil.intersect(tenthRow, tenthColumn));
 		assertEquals(CellRangeUtil.INSIDE, CellRangeUtil.intersect(tenthColumn, tenthColumn));
 		assertEquals(CellRangeUtil.INSIDE, CellRangeUtil.intersect(tenthRow, tenthRow));
-		
+
 		// Bug 55380
 		assertEquals(CellRangeUtil.OVERLAP, CellRangeUtil.intersect(
 		        CellRangeAddress.valueOf("C1:D2"), CellRangeAddress.valueOf("C2:C3")));
 	}
-	
+
 	/**
 	 * Cell ranges like the following are valid
 	 * =$C:$IV,$B$1:$B$8,$B$10:$B$65536,$A:$A
 	 */
+	@Test
 	public void testCreate() {
-		CellRangeAddress cr;
-		
-		cr = createCR(0, -1, 2, 255); // $C:$IV
-		confirmRange(cr, false, true);
-		cr = createCR(0, 7, 1, 1); // $B$1:$B$8
-		
-		try {
-			cr = createCR(9, -1, 1, 1); // $B$65536
-		} catch (IllegalArgumentException e) {
-			if(e.getMessage().startsWith("invalid cell range")) {
-				throw new AssertionFailedError("Identified bug 44739");
-			}
-			throw e;
-		}
-		cr = createCR(0, -1, 0, 0); // $A:$A
-	}
+		CellRangeAddress cr = createCR(0, -1, 2, 255); // $C:$IV
+
+		assertFalse("isFullRowRange", cr.isFullRowRange());
+		assertTrue("isFullColumnRange", cr.isFullColumnRange());
 
-	private static void confirmRange(CellRangeAddress cr, boolean isFullRow, boolean isFullColumn) {
-		assertEquals("isFullRowRange", isFullRow, cr.isFullRowRange());
-		assertEquals("isFullColumnRange", isFullColumn, cr.isFullColumnRange());
+		createCR(0, 7, 1, 1); // $B$1:$B$8
+
+		// bug 44739 - invalid cell range
+		createCR(9, -1, 1, 1); // $B$65536
+
+		createCR(0, -1, 0, 0); // $A:$A
 	}
-	
+
+	@Test
 	public void testNumberOfCells() {
 		assertEquals(1, oneCell.getNumberOfCells());
 		assertEquals(100, box9x9.getNumberOfCells());
 		assertEquals(121, box10to20c.getNumberOfCells());
 	}
 
+	@SuppressWarnings("RedundantArrayCreation")
+	@Test
     public void testMergeCellRanges() {
         // no result on empty
         cellRangeTest(new String[]{ });
@@ -202,11 +199,11 @@ public final class TestCellRange extends
         cellRangeTest(new String[]{"A1:B2", "A2:B2"}, "A1:B2");
         cellRangeTest(new String[]{"A1:B3", "A2:B2"}, "A1:B3");
         cellRangeTest(new String[]{"A1:C1", "A2:B2"}, new String[] {"A1:C1", "A2:B2"});
-        
+
         // cases with three ranges
         cellRangeTest(new String[]{"A1:A1", "A2:B2", "A1:C1"}, new String[] {"A1:C1", "A2:B2"});
         cellRangeTest(new String[]{"A1:C1", "A2:B2", "A1:A1"}, new String[] {"A1:C1", "A2:B2"});
-        
+
         // "standard" cases
         // enclose
         cellRangeTest(new String[]{"A1:D4", "B2:C3"}, new String[] {"A1:D4"});
@@ -223,16 +220,18 @@ public final class TestCellRange extends
         cellRangeTest(new String[]{"A1:C3", "B1:D1"}, new String[] {"A1:C3", "B1:D1"}); // could be one region "A1:D3"
     }
 
+	@SuppressWarnings("RedundantArrayCreation")
+	@Test
     public void testMergeCellRanges55380() {
         cellRangeTest(new String[]{"C1:D2", "C2:C3"}, new String[] {"C1:D2", "C2:C3"});
         cellRangeTest(new String[]{"A1:C3", "B2:D2"}, new String[] {"A1:C3", "B2:D2"});
         cellRangeTest(new String[]{"C9:D30", "C7:C31"}, new String[] {"C9:D30",  "C7:C31"});
     }
-    
+
 //    public void testResolveRangeOverlap() {
 //        resolveRangeOverlapTest("C1:D2", "C2:C3");
 //    }
-    
+
     private void cellRangeTest(String[] input, String... expectedOutput) {
         CellRangeAddress[] inputArr = new CellRangeAddress[input.length];
         for(int i = 0;i < input.length;i++) {
@@ -248,16 +247,17 @@ public final class TestCellRange extends
 //        CellRangeAddress[] result = CellRangeUtil.resolveRangeOverlap(rangeA, rangeB);
 //        verifyExpectedResult(result, expectedOutput);
 //    }
-    
+
     private void verifyExpectedResult(CellRangeAddress[] result, String... expectedOutput) {
-        assertEquals("\nExpected: " + Arrays.toString(expectedOutput) + "\nHad: " + Arrays.toString(result), 
+        assertEquals("\nExpected: " + Arrays.toString(expectedOutput) + "\nHad: " + Arrays.toString(result),
                 expectedOutput.length, result.length);
         for(int i = 0;i < expectedOutput.length;i++) {
             assertEquals("\nExpected: " + Arrays.toString(expectedOutput) + "\nHad: " + Arrays.toString(result),
                     expectedOutput[i], result[i].formatAsString());
         }
     }
-    
+
+	@Test
     public void testValueOf() {
         CellRangeAddress cr1 = CellRangeAddress.valueOf("A1:B1");
         assertEquals(0, cr1.getFirstColumn());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org