From 764ec1df173d6362676b2938f19949cc1b498094 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 16 May 2014 13:25:45 +0000 Subject: [PATCH] Apache POI - Use assertArrayEquals() instead of assertTrue(Arrays.equals()), this way we get better information on failure git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1595190 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xslf/usermodel/TestXSLFSlide.java | 10 +- .../poi/xssf/usermodel/TestXSSFDrawing.java | 39 ++--- .../poi/xssf/usermodel/TestXSSFPicture.java | 21 +-- .../xwpf/usermodel/TestXWPFPictureData.java | 6 +- .../poi/hslf/model/TestOleEmbedding.java | 5 +- .../hslf/record/TestAnimationInfoAtom.java | 10 +- .../apache/poi/hslf/record/TestExControl.java | 10 +- .../poi/hslf/record/TestExMediaAtom.java | 10 +- .../poi/hslf/record/TestExOleObjAtom.java | 10 +- .../poi/hslf/record/TestExOleObjStg.java | 14 +- .../poi/hslf/record/TestExVideoContainer.java | 10 +- .../poi/hslf/record/TestFontCollection.java | 7 +- .../hslf/record/TestHeadersFootersAtom.java | 10 +- .../record/TestHeadersFootersContainer.java | 14 +- .../org/apache/poi/hslf/record/TestSound.java | 7 +- .../hslf/record/TestStyleTextPropAtom.java | 139 +++++++++--------- .../poi/hslf/record/TestTextRulerAtom.java | 11 +- .../poi/hslf/record/TestTextSpecInfoAtom.java | 5 +- .../poi/hslf/usermodel/TestPictures.java | 46 +++--- .../poi/hslf/usermodel/TestSoundData.java | 6 +- .../apache/poi/ddf/TestEscherBlipRecord.java | 36 ++--- .../apache/poi/ddf/TestEscherOptRecord.java | 10 +- .../poi/hssf/model/TestDrawingAggregate.java | 5 +- .../poi/hssf/model/TestFormulaParser.java | 42 +----- .../hssf/record/TestAutoFilterInfoRecord.java | 4 +- .../poi/hssf/record/TestBoolErrRecord.java | 5 +- .../poi/hssf/record/TestBoundSheetRecord.java | 9 +- .../poi/hssf/record/TestColumnInfoRecord.java | 9 +- .../poi/hssf/record/TestDrawingRecord.java | 7 +- .../TestEmbeddedObjectRefSubRecord.java | 7 +- .../poi/hssf/record/TestFtCblsSubRecord.java | 5 +- .../poi/hssf/record/TestHyperlinkRecord.java | 15 +- .../poi/hssf/record/TestLbsDataSubRecord.java | 30 ++-- .../poi/hssf/record/TestNoteRecord.java | 5 +- .../record/TestNoteStructureSubRecord.java | 5 +- .../apache/poi/hssf/record/TestObjRecord.java | 5 +- .../poi/hssf/record/TestRecalcIdRecord.java | 5 +- .../poi/hssf/record/TestRecordFactory.java | 5 +- .../record/TestRecordFactoryInputStream.java | 5 +- .../apache/poi/hssf/record/TestSSTRecord.java | 6 +- .../apache/poi/hssf/record/TestSubRecord.java | 7 +- .../poi/hssf/record/TestTextObjectRecord.java | 11 +- .../aggregates/TestPageSettingsBlock.java | 10 +- .../aggregates/TestValueRecordsAggregate.java | 5 +- .../record/chart/TestChartFormatRecord.java | 9 +- .../poi/hssf/usermodel/TestCloneSheet.java | 18 ++- .../poi/hssf/usermodel/TestHSSFPalette.java | 29 ++-- .../poi/hssf/usermodel/TestHSSFPicture.java | 63 ++++---- .../poi/hssf/usermodel/TestOLE2Embeding.java | 9 +- .../poi/hssf/usermodel/TestPolygon.java | 52 +++---- .../apache/poi/hssf/usermodel/TestText.java | 14 +- .../poi/ss/formula/ptg/TestArrayPtg.java | 5 +- .../poi/ss/formula/ptg/TestAttrPtg.java | 5 +- .../poi/ss/formula/ptg/TestReferencePtg.java | 5 +- .../BaseTestSheetUpdateArrayFormulas.java | 5 +- .../poi/util/TestLittleEndianStreams.java | 5 +- 56 files changed, 435 insertions(+), 427 deletions(-) diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java index 3d73d41a25..ecfd70eac2 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java @@ -16,11 +16,13 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import junit.framework.TestCase; -import org.apache.poi.xslf.XSLFTestDataSamples; +import static org.junit.Assert.assertArrayEquals; import java.awt.Color; -import java.util.Arrays; + +import junit.framework.TestCase; + +import org.apache.poi.xslf.XSLFTestDataSamples; /** * @author Yegor Kozlov @@ -157,7 +159,7 @@ public class TestXSLFSlide extends TestCase { XSLFPictureShape sh4 = (XSLFPictureShape)shapes2[1]; XSLFPictureShape srcPic = (XSLFPictureShape)src.getSlides()[4].getShapes()[1]; - assertTrue(Arrays.equals(sh4.getPictureData().getData(), srcPic.getPictureData().getData())); + assertArrayEquals(sh4.getPictureData().getData(), srcPic.getPictureData().getData()); } public void testMergeSlides(){ diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java index bdfd630e91..d69a62f48e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java @@ -16,9 +16,10 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel; +import static org.junit.Assert.assertArrayEquals; + import java.awt.Color; import java.io.IOException; -import java.util.Arrays; import java.util.List; import junit.framework.TestCase; @@ -223,9 +224,9 @@ public class TestXSSFDrawing extends TestCase { assertEquals(true, rPr.getB()); assertEquals(true, rPr.getI()); assertEquals(STTextUnderlineType.SNG, rPr.getU()); - assertTrue(Arrays.equals( + assertArrayEquals( new byte[]{0, (byte)128, (byte)128} , - rPr.getSolidFill().getSrgbClr().getVal())); + rPr.getSolidFill().getSrgbClr().getVal()); assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb)); } @@ -288,9 +289,9 @@ public class TestXSSFDrawing extends TestCase { CTTextCharacterProperties rPr = pr.getRArray(0).getRPr(); assertEquals("Arial", rPr.getLatin().getTypeface()); - assertTrue(Arrays.equals( + assertArrayEquals( new byte[]{0, (byte)128, (byte)128} , - rPr.getSolidFill().getSrgbClr().getVal())); + rPr.getSolidFill().getSrgbClr().getVal()); assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb)); } @@ -322,9 +323,9 @@ public class TestXSSFDrawing extends TestCase { assertEquals("Arial", runs.get(0).getFontFamily()); Color clr = runs.get(0).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 255, 255 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb)); } @@ -398,26 +399,26 @@ public class TestXSSFDrawing extends TestCase { assertEquals("Arial", runs.get(0).getFontFamily()); Color clr = runs.get(0).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 255, 255 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); // second run properties assertEquals("Rich Text", runs.get(1).getText()); assertEquals(XSSFFont.DEFAULT_FONT_NAME, runs.get(1).getFontFamily()); clr = runs.get(1).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 255, 0 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); // third run properties assertEquals(" String", runs.get(2).getText()); assertEquals("Arial", runs.get(2).getFontFamily()); clr = runs.get(2).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 255, 255 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb)); } @@ -547,19 +548,19 @@ public class TestXSSFDrawing extends TestCase { assertEquals(TextAlign.RIGHT, paras.get(2).getTextAlign()); Color clr = paras.get(0).getTextRuns().get(0).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 255, 0, 0 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); clr = paras.get(1).getTextRuns().get(0).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 255, 0 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); clr = paras.get(2).getTextRuns().get(0).getFontColor(); - assertTrue(Arrays.equals( + assertArrayEquals( new int[] { 0, 0, 255 } , - new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() })); + new int[] { clr.getRed(), clr.getGreen(), clr.getBlue() }); assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb)); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java index 0aa42349b7..f6b05586e6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java @@ -17,16 +17,17 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.usermodel.ClientAnchor; +import static org.junit.Assert.assertArrayEquals; + +import java.util.List; + import org.apache.poi.ss.usermodel.BaseTestPicture; +import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs; -import java.util.List; -import java.util.Arrays; - /** * @author Yegor Kozlov */ @@ -54,7 +55,7 @@ public final class TestXSSFPicture extends BaseTestPicture { int jpegIdx = wb.addPicture(jpegData, XSSFWorkbook.PICTURE_TYPE_JPEG); assertEquals(1, pictures.size()); assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension()); - assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData())); + assertArrayEquals(jpegData, pictures.get(jpegIdx).getData()); XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30); assertEquals(ClientAnchor.MOVE_AND_RESIZE, anchor.getAnchorType()); @@ -64,7 +65,7 @@ public final class TestXSSFPicture extends BaseTestPicture { XSSFPicture shape = drawing.createPicture(anchor, jpegIdx); assertTrue(anchor.equals(shape.getAnchor())); assertNotNull(shape.getPictureData()); - assertTrue(Arrays.equals(jpegData, shape.getPictureData().getData())); + assertArrayEquals(jpegData, shape.getPictureData().getData()); CTTwoCellAnchor ctShapeHolder = drawing.getCTDrawing().getTwoCellAnchorArray(0); // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE @@ -128,16 +129,16 @@ public final class TestXSSFPicture extends BaseTestPicture { sheet1 = wb.getSheetAt(0); drawing1 = sheet1.createDrawingPatriarch(); XSSFPicture shape11 = (XSSFPicture)drawing1.getShapes().get(0); - assertTrue(Arrays.equals(shape1.getPictureData().getData(), shape11.getPictureData().getData())); + assertArrayEquals(shape1.getPictureData().getData(), shape11.getPictureData().getData()); XSSFPicture shape22 = (XSSFPicture)drawing1.getShapes().get(1); - assertTrue(Arrays.equals(shape2.getPictureData().getData(), shape22.getPictureData().getData())); + assertArrayEquals(shape2.getPictureData().getData(), shape22.getPictureData().getData()); sheet2 = wb.getSheetAt(1); drawing2 = sheet2.createDrawingPatriarch(); XSSFPicture shape33 = (XSSFPicture)drawing2.getShapes().get(0); - assertTrue(Arrays.equals(shape3.getPictureData().getData(), shape33.getPictureData().getData())); + assertArrayEquals(shape3.getPictureData().getData(), shape33.getPictureData().getData()); XSSFPicture shape44 = (XSSFPicture)drawing2.getShapes().get(1); - assertTrue(Arrays.equals(shape4.getPictureData().getData(), shape44.getPictureData().getData())); + assertArrayEquals(shape4.getPictureData().getData(), shape44.getPictureData().getData()); } diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java index f604683bcf..34a47fdfbb 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java @@ -20,7 +20,6 @@ package org.apache.poi.xwpf.usermodel; import static org.junit.Assert.assertArrayEquals; import java.io.IOException; -import java.util.Arrays; import java.util.List; import junit.framework.TestCase; @@ -54,7 +53,7 @@ public class TestXWPFPictureData extends TestCase { assertEquals(num + 1,pictures.size()); XWPFPictureData pict = (XWPFPictureData) sampleDoc.getRelationById(relationId); assertEquals("jpeg",pict.suggestFileExtension()); - assertTrue(Arrays.equals(pictureData,pict.getData())); + assertArrayEquals(pictureData,pict.getData()); } public void testPictureInHeader() throws IOException @@ -103,7 +102,7 @@ public class TestXWPFPictureData extends TestCase { assertEquals(1,pictures.size()); XWPFPictureData jpgPicData = (XWPFPictureData) doc.getRelationById(relationId); assertEquals("jpeg",jpgPicData.suggestFileExtension()); - assertTrue(Arrays.equals(jpegData,jpgPicData.getData())); + assertArrayEquals(jpegData,jpgPicData.getData()); // Ensure it now has one assertEquals(14,doc.getPackagePart().getRelationships().size()); @@ -120,6 +119,7 @@ public class TestXWPFPictureData extends TestCase { assertNotNull("JPEG Relationship not found",jpegRel); // Check the details + assertNotNull(jpegRel); assertEquals(XWPFRelation.IMAGE_JPEG.getRelation(),jpegRel.getRelationshipType()); assertEquals("/word/document.xml",jpegRel.getSource().getPartName().toString()); assertEquals("/word/media/image1.jpeg",jpegRel.getTargetURI().getPath()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java index a6819388d1..8ecb14f7ad 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java @@ -17,12 +17,13 @@ package org.apache.poi.hslf.model; +import static org.junit.Assert.assertArrayEquals; + import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; -import java.util.Arrays; import junit.framework.TestCase; @@ -136,7 +137,7 @@ public final class TestOleEmbedding extends TestCase { poiData1.writeFilesystem(bos); byte expData[] = bos.toByteArray(); - assertTrue(Arrays.equals(expData, compData)); + assertArrayEquals(expData, compData); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java index c410e831c3..87d40fa160 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link HeadersFootersAtom} works properly @@ -65,7 +67,7 @@ public final class TestAnimationInfoAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -80,6 +82,6 @@ public final class TestAnimationInfoAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java index 81a939a4d0..6b4d7a21a4 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link org.apache.poi.hslf.record.ExControl} works properly @@ -93,7 +95,7 @@ public final class TestExControl extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -118,6 +120,6 @@ public final class TestExControl extends TestCase { byte[] b = baos.toByteArray(); assertEquals(data.length, b.length); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java index 3f63a42a22..05c0e678be 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly @@ -49,7 +51,7 @@ public final class TestExMediaAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -66,7 +68,7 @@ public final class TestExMediaAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testFlags() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java index cdd91b91cc..b69e5f40cc 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java @@ -17,9 +17,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link ExOleObjAtom} works properly @@ -51,7 +53,7 @@ public final class TestExOleObjAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -67,6 +69,6 @@ public final class TestExOleObjAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java index 8e5179c616..83d932fdea 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java @@ -18,14 +18,16 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.io.InputStream; import java.io.IOException; -import java.util.Arrays; +import java.io.InputStream; + +import junit.framework.TestCase; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.DocumentEntry; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** * Tests that {@link ExOleObjStg} works properly @@ -105,7 +107,7 @@ public final class TestExOleObjStg extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -123,7 +125,7 @@ public final class TestExOleObjStg extends TestCase { byte[] b = out.toByteArray(); assertEquals(data.length, b.length); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } private byte[] readAll(InputStream is) throws IOException { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java index d566a1f054..a16c8ed469 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link HeadersFootersAtom} works properly @@ -70,7 +72,7 @@ public final class TestExVideoContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -82,6 +84,6 @@ public final class TestExVideoContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java index d0d47b7d71..c005c023f9 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java @@ -17,10 +17,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests FontCollection and FontEntityAtom records @@ -76,6 +77,6 @@ public final class TestFontCollection extends TestCase { ByteArrayOutputStream out = new ByteArrayOutputStream(); fonts.writeOut(out); byte[] recdata = out.toByteArray(); - assertTrue(Arrays.equals(recdata, data)); + assertArrayEquals(recdata, data); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java index b391c06ed7..07a7b42d45 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link HeadersFootersAtom} works properly @@ -54,7 +56,7 @@ public final class TestHeadersFootersAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testNewRecord() throws Exception { @@ -67,7 +69,7 @@ public final class TestHeadersFootersAtom extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(data, b)); + assertArrayEquals(data, b); } public void testFlags() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java index 5ac5c22b48..ef6f31f7c7 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java @@ -18,9 +18,11 @@ package org.apache.poi.hslf.record; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; -import java.util.Arrays; + +import junit.framework.TestCase; /** * Tests that {@link HeadersFootersContainer} works properly @@ -75,7 +77,7 @@ public final class TestHeadersFootersContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(slideData, b)); + assertArrayEquals(slideData, b); } public void testNewSlideHeadersFootersContainer() throws Exception { @@ -100,7 +102,7 @@ public final class TestHeadersFootersContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(slideData, b)); + assertArrayEquals(slideData, b); } public void testReadNotesHeadersFootersContainer() { @@ -129,7 +131,7 @@ public final class TestHeadersFootersContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(notesData, b)); + assertArrayEquals(notesData, b); } public void testNewNotesHeadersFootersContainer() throws Exception { @@ -162,7 +164,7 @@ public final class TestHeadersFootersContainer extends TestCase { record.writeOut(baos); byte[] b = baos.toByteArray(); - assertTrue(Arrays.equals(notesData, b)); + assertArrayEquals(notesData, b); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java index 9e1668566b..630b355850 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java @@ -17,13 +17,12 @@ package org.apache.poi.hslf.record; -import java.util.Arrays; - +import static org.junit.Assert.assertArrayEquals; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.POIDataSamples; +import org.apache.poi.hslf.usermodel.SlideShow; /** * Tests Sound-related records: SoundCollection(2020), Sound(2022) and @@ -70,6 +69,6 @@ public final class TestSound extends TestCase { assertNotNull(sound.getSoundData()); byte[] ref_data = slTests.readFile("ringin.wav"); - assertTrue(Arrays.equals(ref_data, sound.getSoundData())); + assertArrayEquals(ref_data, sound.getSoundData()); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java index a95186c306..665c86e691 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java @@ -17,9 +17,10 @@ package org.apache.poi.hslf.record; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Arrays; import java.util.LinkedList; import junit.framework.TestCase; @@ -187,20 +188,20 @@ public final class TestStyleTextPropAtom extends TestCase { stpb.setParentTextSize(data_b_text_len); // 54 chars, 21 + 17 + 16 - LinkedList a_ch_l = stpa.getCharacterStyles(); - TextPropCollection a_ch_1 = (TextPropCollection)a_ch_l.get(0); - TextPropCollection a_ch_2 = (TextPropCollection)a_ch_l.get(1); - TextPropCollection a_ch_3 = (TextPropCollection)a_ch_l.get(2); + LinkedList a_ch_l = stpa.getCharacterStyles(); + TextPropCollection a_ch_1 = a_ch_l.get(0); + TextPropCollection a_ch_2 = a_ch_l.get(1); + TextPropCollection a_ch_3 = a_ch_l.get(2); assertEquals(21, a_ch_1.getCharactersCovered()); assertEquals(17, a_ch_2.getCharactersCovered()); assertEquals(16, a_ch_3.getCharactersCovered()); // 179 chars, 30 + 28 + 25 - LinkedList b_ch_l = stpb.getCharacterStyles(); - TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0); - TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1); - TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2); - TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3); + LinkedList b_ch_l = stpb.getCharacterStyles(); + TextPropCollection b_ch_1 = b_ch_l.get(0); + TextPropCollection b_ch_2 = b_ch_l.get(1); + TextPropCollection b_ch_3 = b_ch_l.get(2); + TextPropCollection b_ch_4 = b_ch_l.get(3); assertEquals(30, b_ch_1.getCharactersCovered()); assertEquals(28, b_ch_2.getCharactersCovered()); assertEquals(25, b_ch_3.getCharactersCovered()); @@ -212,25 +213,25 @@ public final class TestStyleTextPropAtom extends TestCase { StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); stpb.setParentTextSize(data_b_text_len); - LinkedList b_ch_l = stpb.getCharacterStyles(); - TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0); - TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1); - TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2); - TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3); + LinkedList b_ch_l = stpb.getCharacterStyles(); + TextPropCollection b_ch_1 = b_ch_l.get(0); + TextPropCollection b_ch_2 = b_ch_l.get(1); + TextPropCollection b_ch_3 = b_ch_l.get(2); + TextPropCollection b_ch_4 = b_ch_l.get(3); // In first set, we get a CharFlagsTextProp and a font.size assertEquals(2,b_ch_1.getTextPropList().size()); - TextProp tp_1_1 = (TextProp)b_ch_1.getTextPropList().get(0); - TextProp tp_1_2 = (TextProp)b_ch_1.getTextPropList().get(1); + TextProp tp_1_1 = b_ch_1.getTextPropList().get(0); + TextProp tp_1_2 = b_ch_1.getTextPropList().get(1); assertEquals(true, tp_1_1 instanceof CharFlagsTextProp); assertEquals("font.size", tp_1_2.getName()); assertEquals(20, tp_1_2.getValue()); // In second set, we get a CharFlagsTextProp and a font.size and a font.color assertEquals(3,b_ch_2.getTextPropList().size()); - TextProp tp_2_1 = (TextProp)b_ch_2.getTextPropList().get(0); - TextProp tp_2_2 = (TextProp)b_ch_2.getTextPropList().get(1); - TextProp tp_2_3 = (TextProp)b_ch_2.getTextPropList().get(2); + TextProp tp_2_1 = b_ch_2.getTextPropList().get(0); + TextProp tp_2_2 = b_ch_2.getTextPropList().get(1); + TextProp tp_2_3 = b_ch_2.getTextPropList().get(2); assertEquals(true, tp_2_1 instanceof CharFlagsTextProp); assertEquals("font.size", tp_2_2.getName()); assertEquals("font.color", tp_2_3.getName()); @@ -238,17 +239,17 @@ public final class TestStyleTextPropAtom extends TestCase { // In third set, it's just a font.size and a font.color assertEquals(2,b_ch_3.getTextPropList().size()); - TextProp tp_3_1 = (TextProp)b_ch_3.getTextPropList().get(0); - TextProp tp_3_2 = (TextProp)b_ch_3.getTextPropList().get(1); + TextProp tp_3_1 = b_ch_3.getTextPropList().get(0); + TextProp tp_3_2 = b_ch_3.getTextPropList().get(1); assertEquals("font.size", tp_3_1.getName()); assertEquals("font.color", tp_3_2.getName()); assertEquals(20, tp_3_1.getValue()); // In fourth set, we get a CharFlagsTextProp and a font.index and a font.size assertEquals(3,b_ch_4.getTextPropList().size()); - TextProp tp_4_1 = (TextProp)b_ch_4.getTextPropList().get(0); - TextProp tp_4_2 = (TextProp)b_ch_4.getTextPropList().get(1); - TextProp tp_4_3 = (TextProp)b_ch_4.getTextPropList().get(2); + TextProp tp_4_1 = b_ch_4.getTextPropList().get(0); + TextProp tp_4_2 = b_ch_4.getTextPropList().get(1); + TextProp tp_4_3 = b_ch_4.getTextPropList().get(2); assertEquals(true, tp_4_1 instanceof CharFlagsTextProp); assertEquals("font.index", tp_4_2.getName()); assertEquals("font.size", tp_4_3.getName()); @@ -259,16 +260,16 @@ public final class TestStyleTextPropAtom extends TestCase { StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); stpb.setParentTextSize(data_b_text_len); - LinkedList b_p_l = stpb.getParagraphStyles(); - TextPropCollection b_p_1 = (TextPropCollection)b_p_l.get(0); - TextPropCollection b_p_2 = (TextPropCollection)b_p_l.get(1); - TextPropCollection b_p_3 = (TextPropCollection)b_p_l.get(2); - TextPropCollection b_p_4 = (TextPropCollection)b_p_l.get(3); + LinkedList b_p_l = stpb.getParagraphStyles(); + TextPropCollection b_p_1 = b_p_l.get(0); + TextPropCollection b_p_2 = b_p_l.get(1); + TextPropCollection b_p_3 = b_p_l.get(2); + TextPropCollection b_p_4 = b_p_l.get(3); // 1st is left aligned + normal line spacing assertEquals(2,b_p_1.getTextPropList().size()); - TextProp tp_1_1 = (TextProp)b_p_1.getTextPropList().get(0); - TextProp tp_1_2 = (TextProp)b_p_1.getTextPropList().get(1); + TextProp tp_1_1 = b_p_1.getTextPropList().get(0); + TextProp tp_1_2 = b_p_1.getTextPropList().get(1); assertEquals("alignment", tp_1_1.getName()); assertEquals("linespacing", tp_1_2.getName()); assertEquals(0, tp_1_1.getValue()); @@ -276,14 +277,14 @@ public final class TestStyleTextPropAtom extends TestCase { // 2nd is centre aligned (default) + normal line spacing assertEquals(1,b_p_2.getTextPropList().size()); - TextProp tp_2_1 = (TextProp)b_p_2.getTextPropList().get(0); + TextProp tp_2_1 = b_p_2.getTextPropList().get(0); assertEquals("linespacing", tp_2_1.getName()); assertEquals(80, tp_2_1.getValue()); // 3rd is right aligned + normal line spacing assertEquals(2,b_p_3.getTextPropList().size()); - TextProp tp_3_1 = (TextProp)b_p_3.getTextPropList().get(0); - TextProp tp_3_2 = (TextProp)b_p_3.getTextPropList().get(1); + TextProp tp_3_1 = b_p_3.getTextPropList().get(0); + TextProp tp_3_2 = b_p_3.getTextPropList().get(1); assertEquals("alignment", tp_3_1.getName()); assertEquals("linespacing", tp_3_2.getName()); assertEquals(2, tp_3_1.getValue()); @@ -291,8 +292,8 @@ public final class TestStyleTextPropAtom extends TestCase { // 4st is left aligned + normal line spacing (despite differing font) assertEquals(2,b_p_4.getTextPropList().size()); - TextProp tp_4_1 = (TextProp)b_p_4.getTextPropList().get(0); - TextProp tp_4_2 = (TextProp)b_p_4.getTextPropList().get(1); + TextProp tp_4_1 = b_p_4.getTextPropList().get(0); + TextProp tp_4_2 = b_p_4.getTextPropList().get(1); assertEquals("alignment", tp_4_1.getName()); assertEquals("linespacing", tp_4_2.getName()); assertEquals(0, tp_4_1.getValue()); @@ -303,11 +304,11 @@ public final class TestStyleTextPropAtom extends TestCase { StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); stpb.setParentTextSize(data_b_text_len); - LinkedList b_ch_l = stpb.getCharacterStyles(); - TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0); - TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1); - TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2); - TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3); + LinkedList b_ch_l = stpb.getCharacterStyles(); + TextPropCollection b_ch_1 = b_ch_l.get(0); + TextPropCollection b_ch_2 = b_ch_l.get(1); + TextPropCollection b_ch_3 = b_ch_l.get(2); + TextPropCollection b_ch_4 = b_ch_l.get(3); // 1st is bold CharFlagsTextProp cf_1_1 = (CharFlagsTextProp)b_ch_1.getTextPropList().get(0); @@ -374,17 +375,17 @@ public final class TestStyleTextPropAtom extends TestCase { StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); stpb.setParentTextSize(data_b_text_len); - LinkedList b_p_l = stpb.getParagraphStyles(); - TextPropCollection b_p_1 = (TextPropCollection)b_p_l.get(0); - TextPropCollection b_p_2 = (TextPropCollection)b_p_l.get(1); - TextPropCollection b_p_3 = (TextPropCollection)b_p_l.get(2); - TextPropCollection b_p_4 = (TextPropCollection)b_p_l.get(3); + LinkedList b_p_l = stpb.getParagraphStyles(); + TextPropCollection b_p_1 = b_p_l.get(0); + TextPropCollection b_p_2 = b_p_l.get(1); + TextPropCollection b_p_3 = b_p_l.get(2); + TextPropCollection b_p_4 = b_p_l.get(3); - LinkedList b_ch_l = stpb.getCharacterStyles(); - TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0); - TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1); - TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2); - TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3); + LinkedList b_ch_l = stpb.getCharacterStyles(); + TextPropCollection b_ch_1 = b_ch_l.get(0); + TextPropCollection b_ch_2 = b_ch_l.get(1); + TextPropCollection b_ch_3 = b_ch_l.get(2); + TextPropCollection b_ch_4 = b_ch_l.get(3); // CharFlagsTextProp: 3 doesn't have, 4 does assertNull(b_ch_3.findByName("char_flags")); @@ -430,10 +431,10 @@ public final class TestStyleTextPropAtom extends TestCase { // Don't need to touch the paragraph styles // Add two more character styles - LinkedList cs = stpa.getCharacterStyles(); + LinkedList cs = stpa.getCharacterStyles(); // First char style is boring, and 21 long - TextPropCollection tpca = (TextPropCollection)cs.get(0); + TextPropCollection tpca = cs.get(0); tpca.updateTextSize(21); // Second char style is coloured, 00 00 00 05, and 17 long @@ -467,10 +468,10 @@ public final class TestStyleTextPropAtom extends TestCase { // Need 4 paragraph styles - LinkedList ps = stpa.getParagraphStyles(); + LinkedList ps = stpa.getParagraphStyles(); // First is 30 long, left aligned, normal spacing - TextPropCollection tppa = (TextPropCollection)ps.get(0); + TextPropCollection tppa = ps.get(0); tppa.updateTextSize(30); TextProp tp = tppa.addWithName("alignment"); @@ -502,10 +503,10 @@ public final class TestStyleTextPropAtom extends TestCase { // Now do 4 character styles - LinkedList cs = stpa.getCharacterStyles(); + LinkedList cs = stpa.getCharacterStyles(); // First is 30 long, bold and font size - TextPropCollection tpca = (TextPropCollection)cs.get(0); + TextPropCollection tpca = cs.get(0); tpca.updateTextSize(30); tp = tpca.addWithName("font.size"); @@ -567,16 +568,16 @@ public final class TestStyleTextPropAtom extends TestCase { // Compare in detail to b StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); stpb.setParentTextSize(data_b_text_len); - LinkedList psb = stpb.getParagraphStyles(); - LinkedList csb = stpb.getCharacterStyles(); + LinkedList psb = stpb.getParagraphStyles(); + LinkedList csb = stpb.getCharacterStyles(); assertEquals(psb.size(), ps.size()); assertEquals(csb.size(), cs.size()); // Ensure Paragraph Character styles match for(int z=0; z<2; z++) { - LinkedList lla = cs; - LinkedList llb = csb; + LinkedList lla = cs; + LinkedList llb = csb; int upto = 5; if(z == 1) { lla = ps; @@ -585,15 +586,15 @@ public final class TestStyleTextPropAtom extends TestCase { } for(int i=0; i lst2 = wb.getAllPictures(); assertEquals(2, lst2.size()); - assertTrue(Arrays.equals(data1, lst2.get(0).getData())); - assertTrue(Arrays.equals(data2, lst2.get(1).getData())); + assertArrayEquals(data1, lst2.get(0).getData()); + assertArrayEquals(data2, lst2.get(1).getData()); // confirm that the pictures are in the Sheet's drawing sh = wb.getSheet("Pictures"); dr = sh.createDrawingPatriarch(); assertEquals(2, dr.getChildren().size()); - assertTrue(Arrays.equals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData())); - assertTrue(Arrays.equals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData())); + assertArrayEquals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData()); + assertArrayEquals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData()); // add a third picture byte[] data3 = new byte[]{7, 8, 9}; @@ -111,20 +110,20 @@ public final class TestHSSFPicture extends BaseTestPicture { int idx3 = wb.addPicture(data3, Workbook.PICTURE_TYPE_JPEG); assertEquals(3, idx3); HSSFPicture p3 = dr.createPicture(anchor, idx3); - assertTrue(Arrays.equals(data3, p3.getPictureData().getData())); + assertArrayEquals(data3, p3.getPictureData().getData()); assertEquals(3, dr.getChildren().size()); - assertTrue(Arrays.equals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData())); - assertTrue(Arrays.equals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData())); - assertTrue(Arrays.equals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData())); + assertArrayEquals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData()); + assertArrayEquals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData()); + assertArrayEquals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData()); // write and read again wb = HSSFTestDataSamples.writeOutAndReadBack(wb); List lst3 = wb.getAllPictures(); // all three should be there assertEquals(3, lst3.size()); - assertTrue(Arrays.equals(data1, lst3.get(0).getData())); - assertTrue(Arrays.equals(data2, lst3.get(1).getData())); - assertTrue(Arrays.equals(data3, lst3.get(2).getData())); + assertArrayEquals(data1, lst3.get(0).getData()); + assertArrayEquals(data2, lst3.get(1).getData()); + assertArrayEquals(data3, lst3.get(2).getData()); sh = wb.getSheet("Pictures"); dr = sh.createDrawingPatriarch(); @@ -136,25 +135,25 @@ public final class TestHSSFPicture extends BaseTestPicture { assertEquals(4, idx4); dr.createPicture(anchor, idx4); assertEquals(4, dr.getChildren().size()); - assertTrue(Arrays.equals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData())); - assertTrue(Arrays.equals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData())); - assertTrue(Arrays.equals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData())); - assertTrue(Arrays.equals(data4, ((HSSFPicture)dr.getChildren().get(3)).getPictureData().getData())); + assertArrayEquals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData()); + assertArrayEquals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData()); + assertArrayEquals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData()); + assertArrayEquals(data4, ((HSSFPicture)dr.getChildren().get(3)).getPictureData().getData()); wb = HSSFTestDataSamples.writeOutAndReadBack(wb); List lst4 = wb.getAllPictures(); assertEquals(4, lst4.size()); - assertTrue(Arrays.equals(data1, lst4.get(0).getData())); - assertTrue(Arrays.equals(data2, lst4.get(1).getData())); - assertTrue(Arrays.equals(data3, lst4.get(2).getData())); - assertTrue(Arrays.equals(data4, lst4.get(3).getData())); + assertArrayEquals(data1, lst4.get(0).getData()); + assertArrayEquals(data2, lst4.get(1).getData()); + assertArrayEquals(data3, lst4.get(2).getData()); + assertArrayEquals(data4, lst4.get(3).getData()); sh = wb.getSheet("Pictures"); dr = sh.createDrawingPatriarch(); assertEquals(4, dr.getChildren().size()); - assertTrue(Arrays.equals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData())); - assertTrue(Arrays.equals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData())); - assertTrue(Arrays.equals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData())); - assertTrue(Arrays.equals(data4, ((HSSFPicture)dr.getChildren().get(3)).getPictureData().getData())); + assertArrayEquals(data1, ((HSSFPicture)dr.getChildren().get(0)).getPictureData().getData()); + assertArrayEquals(data2, ((HSSFPicture)dr.getChildren().get(1)).getPictureData().getData()); + assertArrayEquals(data3, ((HSSFPicture)dr.getChildren().get(2)).getPictureData().getData()); + assertArrayEquals(data4, ((HSSFPicture)dr.getChildren().get(3)).getPictureData().getData()); } public void testBSEPictureRef(){ @@ -256,12 +255,12 @@ public final class TestHSSFPicture extends BaseTestPicture { wb = HSSFTestDataSamples.writeOutAndReadBack(wb); byte pictureDataOut[] = wb.getAllPictures().get(0).getData(); - assertTrue(Arrays.equals(pictureDataEmf, pictureDataOut)); + assertArrayEquals(pictureDataEmf, pictureDataOut); byte wmfNoHeader[] = new byte[pictureDataWmf.length-22]; System.arraycopy(pictureDataWmf, 22, wmfNoHeader, 0, pictureDataWmf.length-22); pictureDataOut = wb.getAllPictures().get(2).getData(); - assertTrue(Arrays.equals(wmfNoHeader, pictureDataOut)); + assertArrayEquals(wmfNoHeader, pictureDataOut); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java b/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java index 22700b28cc..e425acc1e4 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java @@ -17,12 +17,13 @@ package org.apache.poi.hssf.usermodel; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.List; import junit.framework.TestCase; @@ -119,17 +120,17 @@ public final class TestOLE2Embeding extends TestCase { Ole10Native ole10 = Ole10Native.createFromEmbeddedOleObject((DirectoryNode)od.getDirectory()); bos.reset(); pptPoifs.writeFilesystem(bos); - assertTrue(Arrays.equals(ole10.getDataBuffer(), bos.toByteArray())); + assertArrayEquals(ole10.getDataBuffer(), bos.toByteArray()); od = wb.getAllEmbeddedObjects().get(1); ole10 = Ole10Native.createFromEmbeddedOleObject((DirectoryNode)od.getDirectory()); bos.reset(); xlsPoifs.writeFilesystem(bos); - assertTrue(Arrays.equals(ole10.getDataBuffer(), bos.toByteArray())); + assertArrayEquals(ole10.getDataBuffer(), bos.toByteArray()); od = wb.getAllEmbeddedObjects().get(2); ole10 = Ole10Native.createFromEmbeddedOleObject((DirectoryNode)od.getDirectory()); - assertTrue(Arrays.equals(ole10.getDataBuffer(), getSampleTXT())); + assertArrayEquals(ole10.getDataBuffer(), getSampleTXT()); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java b/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java index e677f97ec9..bcaf477493 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java @@ -17,7 +17,12 @@ package org.apache.poi.hssf.usermodel; +import static org.junit.Assert.assertArrayEquals; + +import java.io.IOException; + import junit.framework.TestCase; + import org.apache.poi.ddf.EscherArrayProperty; import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherProperties; @@ -27,9 +32,6 @@ import org.apache.poi.hssf.model.HSSFTestModelHelper; import org.apache.poi.hssf.model.PolygonShape; import org.apache.poi.hssf.record.ObjRecord; -import java.io.IOException; -import java.util.Arrays; - /** * @author Evgeniy Berlog * @date 28.06.12 @@ -55,19 +57,19 @@ public class TestPolygon extends TestCase{ byte[] actual = polygon.getEscherContainer().getChild(0).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); expected = polygonShape.getSpContainer().getChild(2).serialize(); actual = polygon.getEscherContainer().getChild(2).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); expected = polygonShape.getSpContainer().getChild(3).serialize(); actual = polygon.getEscherContainer().getChild(3).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); ObjRecord obj = polygon.getObjRecord(); ObjRecord objShape = polygonShape.getObjRecord(); @@ -76,7 +78,7 @@ public class TestPolygon extends TestCase{ actual = objShape.serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); } public void testPolygonPoints(){ @@ -98,8 +100,8 @@ public class TestPolygon extends TestCase{ assertEquals(verticesProp1.toXml(""), verticesProp2.toXml("")); polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6}); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6})); + assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3}); + assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6}); polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon); verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES); @@ -119,8 +121,8 @@ public class TestPolygon extends TestCase{ polygon.setPolygonDrawArea( 102, 101 ); polygon.setPoints( new int[]{1,2,3}, new int[]{4,5,6} ); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1,2,3})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6})); + assertArrayEquals(polygon.getXPoints(), new int[]{1,2,3}); + assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6}); assertEquals(polygon.getDrawAreaHeight(), 101); assertEquals(polygon.getDrawAreaWidth(), 102); @@ -129,16 +131,16 @@ public class TestPolygon extends TestCase{ patriarch = sh.getDrawingPatriarch(); polygon = (HSSFPolygon) patriarch.getChildren().get(0); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6})); + assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3}); + assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6}); assertEquals(polygon.getDrawAreaHeight(), 101); assertEquals(polygon.getDrawAreaWidth(), 102); polygon.setPolygonDrawArea( 1021, 1011 ); polygon.setPoints( new int[]{11,21,31}, new int[]{41,51,61} ); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{11, 21, 31})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{41, 51, 61})); + assertArrayEquals(polygon.getXPoints(), new int[]{11, 21, 31}); + assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61}); assertEquals(polygon.getDrawAreaHeight(), 1011); assertEquals(polygon.getDrawAreaWidth(), 1021); @@ -148,8 +150,8 @@ public class TestPolygon extends TestCase{ polygon = (HSSFPolygon) patriarch.getChildren().get(0); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{11, 21, 31})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{41, 51, 61})); + assertArrayEquals(polygon.getXPoints(), new int[]{11, 21, 31}); + assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61}); assertEquals(polygon.getDrawAreaHeight(), 1011); assertEquals(polygon.getDrawAreaWidth(), 1021); } @@ -187,18 +189,18 @@ public class TestPolygon extends TestCase{ polygon1 = (HSSFPolygon) patriarch.getChildren().get(1); polygon2 = (HSSFPolygon) patriarch.getChildren().get(2); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4,5,6})); + assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3}); + assertArrayEquals(polygon.getYPoints(), new int[]{4,5,6}); assertEquals(polygon.getDrawAreaHeight(), 101); assertEquals(polygon.getDrawAreaWidth(), 102); - assertTrue(Arrays.equals(polygon1.getXPoints(), new int[]{11,12,13})); - assertTrue(Arrays.equals(polygon1.getYPoints(), new int[]{14,15,16})); + assertArrayEquals(polygon1.getXPoints(), new int[]{11,12,13}); + assertArrayEquals(polygon1.getYPoints(), new int[]{14,15,16}); assertEquals(polygon1.getDrawAreaHeight(), 104); assertEquals(polygon1.getDrawAreaWidth(), 103); - assertTrue(Arrays.equals(polygon2.getXPoints(), new int[]{21,22,23})); - assertTrue(Arrays.equals(polygon2.getYPoints(), new int[]{24,25,26})); + assertArrayEquals(polygon2.getXPoints(), new int[]{21,22,23}); + assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26}); assertEquals(polygon2.getDrawAreaHeight(), 204); assertEquals(polygon2.getDrawAreaWidth(), 203); } @@ -212,8 +214,8 @@ public class TestPolygon extends TestCase{ HSSFPolygon polygon = (HSSFPolygon) drawing.getChildren().get(0); assertEquals(polygon.getDrawAreaHeight(), 2466975); assertEquals(polygon.getDrawAreaWidth(), 3686175); - assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502})); - assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18})); + assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502}); + assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18}); } public void testPolygonType(){ diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestText.java b/src/testcases/org/apache/poi/hssf/usermodel/TestText.java index 07c039edd3..7231330ee0 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestText.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestText.java @@ -17,15 +17,15 @@ package org.apache.poi.hssf.usermodel; +import static org.junit.Assert.assertArrayEquals; import junit.framework.TestCase; + import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.model.HSSFTestModelHelper; import org.apache.poi.hssf.model.TextboxShape; import org.apache.poi.hssf.record.ObjRecord; import org.apache.poi.hssf.record.TextObjectRecord; -import java.util.Arrays; - /** * @author Evgeniy Berlog * @date 25.06.12 @@ -47,25 +47,25 @@ public class TestText extends TestCase { byte[] actual = textbox.getEscherContainer().getChild(0).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); expected = textboxShape.getSpContainer().getChild(2).serialize(); actual = textbox.getEscherContainer().getChild(2).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); expected = textboxShape.getSpContainer().getChild(3).serialize(); actual = textbox.getEscherContainer().getChild(3).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); expected = textboxShape.getSpContainer().getChild(4).serialize(); actual = textbox.getEscherContainer().getChild(4).serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); ObjRecord obj = textbox.getObjRecord(); ObjRecord objShape = textboxShape.getObjRecord(); @@ -80,7 +80,7 @@ public class TestText extends TestCase { actual = torShape.serialize(); assertEquals(expected.length, actual.length); - assertTrue(Arrays.equals(expected, actual)); + assertArrayEquals(expected, actual); } public void testAddTextToExistingFile() { diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestArrayPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestArrayPtg.java index 386ba37f50..36783a4c50 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestArrayPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestArrayPtg.java @@ -17,8 +17,7 @@ package org.apache.poi.ss.formula.ptg; -import java.util.Arrays; - +import static org.junit.Assert.assertArrayEquals; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -77,7 +76,7 @@ public final class TestArrayPtg extends TestCase { if(outBuf[0] == 4) { throw new AssertionFailedError("Identified bug 42564b"); } - assertTrue(Arrays.equals(ENCODED_CONSTANT_DATA, outBuf)); + assertArrayEquals(ENCODED_CONSTANT_DATA, outBuf); } diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java index fb517a31d1..6146449fcc 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java @@ -17,8 +17,7 @@ package org.apache.poi.ss.formula.ptg; -import java.util.Arrays; - +import static org.junit.Assert.assertArrayEquals; import junit.framework.AssertionFailedError; import org.apache.poi.hssf.record.TestcaseRecordInputStream; @@ -45,6 +44,6 @@ public final class TestAttrPtg extends AbstractPtgTestCase { } catch (ArrayIndexOutOfBoundsException e) { throw new AssertionFailedError("incorrect re-serialization of tAttrChoose"); } - assertTrue(Arrays.equals(data, data2)); + assertArrayEquals(data, data2); } } diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java index db02279f39..7167c2ec09 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java @@ -17,8 +17,7 @@ package org.apache.poi.ss.formula.ptg; -import java.util.Arrays; - +import static org.junit.Assert.assertArrayEquals; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -101,7 +100,7 @@ public final class TestReferencePtg extends TestCase { if (outData[0] == 0x24) { throw new AssertionFailedError("Identified bug 45091"); } - assertTrue(Arrays.equals(tRefN_data, outData)); + assertArrayEquals(tRefN_data, outData); } /** diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index 3c177e6aff..4bea4a8c78 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -17,8 +17,7 @@ package org.apache.poi.ss.usermodel; -import java.util.Arrays; - +import static org.junit.Assert.assertArrayEquals; import junit.framework.TestCase; import org.apache.poi.ss.ITestDataProvider; @@ -179,7 +178,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas extends TestCase { // remove the formula cells in C4:C6 CellRange dcells = sheet.removeArrayFormula(cr.getTopLeftCell()); // removeArrayFormula should return the same cells as setArrayFormula - assertTrue(Arrays.equals(cr.getFlattenedCells(), dcells.getFlattenedCells())); + assertArrayEquals(cr.getFlattenedCells(), dcells.getFlattenedCells()); for(Cell acell : cr){ assertFalse(acell.isPartOfArrayFormulaGroup()); diff --git a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java index 26f9b4cf6b..6e7b30f741 100644 --- a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java +++ b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java @@ -17,9 +17,10 @@ package org.apache.poi.util; +import static org.junit.Assert.assertArrayEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.util.Arrays; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -73,7 +74,7 @@ public final class TestLittleEndianStreams extends TestCase { } byte[] expBuf = HexRead.readFromString("77 66 55 44"); - assertTrue(Arrays.equals(actBuf, expBuf)); + assertArrayEquals(actBuf, expBuf); assertEquals(0x33, lei.readUByte()); assertEquals(0, lei.available()); } -- 2.39.5