==================================================================== */\r
package org.apache.poi.xslf.usermodel;\r
\r
-import junit.framework.TestCase;\r
-import org.apache.poi.xslf.XSLFTestDataSamples;\r
+import static org.junit.Assert.assertArrayEquals;\r
\r
import java.awt.Color;\r
-import java.util.Arrays;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import org.apache.poi.xslf.XSLFTestDataSamples;\r
\r
/**\r
* @author Yegor Kozlov\r
\r
XSLFPictureShape sh4 = (XSLFPictureShape)shapes2[1];\r
XSLFPictureShape srcPic = (XSLFPictureShape)src.getSlides()[4].getShapes()[1];\r
- assertTrue(Arrays.equals(sh4.getPictureData().getData(), srcPic.getPictureData().getData()));\r
+ assertArrayEquals(sh4.getPictureData().getData(), srcPic.getPictureData().getData());\r
}\r
\r
public void testMergeSlides(){\r
==================================================================== */
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;
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));
}
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));
}
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));
}
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));
}
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));
}
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
*/
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());
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
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());
}
import static org.junit.Assert.assertArrayEquals;
import java.io.IOException;
-import java.util.Arrays;
import java.util.List;
import junit.framework.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
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());
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());
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;
poiData1.writeFilesystem(bos);
byte expData[] = bos.toByteArray();
- assertTrue(Arrays.equals(expData, compData));
+ assertArrayEquals(expData, compData);
}
}
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
}
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
byte[] b = baos.toByteArray();
assertEquals(data.length, b.length);
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
}
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testFlags() {
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
}
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
byte[] b = out.toByteArray();
assertEquals(data.length, b.length);
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
private byte[] readAll(InputStream is) throws IOException {
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
}
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 <code>FontCollection</code> and <code>FontEntityAtom</code> records
ByteArrayOutputStream out = new ByteArrayOutputStream();
fonts.writeOut(out);
byte[] recdata = out.toByteArray();
- assertTrue(Arrays.equals(recdata, data));
+ assertArrayEquals(recdata, data);
}
}
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testNewRecord() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(data, b));
+ assertArrayEquals(data, b);
}
public void testFlags() {
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
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(slideData, b));
+ assertArrayEquals(slideData, b);
}
public void testNewSlideHeadersFootersContainer() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(slideData, b));
+ assertArrayEquals(slideData, b);
}
public void testReadNotesHeadersFootersContainer() {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(notesData, b));
+ assertArrayEquals(notesData, b);
}
public void testNewNotesHeadersFootersContainer() throws Exception {
record.writeOut(baos);
byte[] b = baos.toByteArray();
- assertTrue(Arrays.equals(notesData, b));
+ assertArrayEquals(notesData, b);
}
}
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
assertNotNull(sound.getSoundData());
byte[] ref_data = slTests.readFile("ringin.wav");
- assertTrue(Arrays.equals(ref_data, sound.getSoundData()));
+ assertArrayEquals(ref_data, sound.getSoundData());
}
}
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;
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<TextPropCollection> 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<TextPropCollection> 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());
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<TextPropCollection> 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());
// 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());
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<TextPropCollection> 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());
// 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());
// 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());
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<TextPropCollection> 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);
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<TextPropCollection> 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<TextPropCollection> 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"));
// Don't need to touch the paragraph styles
// Add two more character styles
- LinkedList cs = stpa.getCharacterStyles();
+ LinkedList<TextPropCollection> 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
// Need 4 paragraph styles
- LinkedList ps = stpa.getParagraphStyles();
+ LinkedList<TextPropCollection> 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");
// Now do 4 character styles
- LinkedList cs = stpa.getCharacterStyles();
+ LinkedList<TextPropCollection> 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");
// 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<TextPropCollection> psb = stpb.getParagraphStyles();
+ LinkedList<TextPropCollection> 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<TextPropCollection> lla = cs;
+ LinkedList<TextPropCollection> llb = csb;
int upto = 5;
if(z == 1) {
lla = ps;
}
for(int i=0; i<upto; i++) {
- TextPropCollection ca = (TextPropCollection)lla.get(i);
- TextPropCollection cb = (TextPropCollection)llb.get(i);
+ TextPropCollection ca = lla.get(i);
+ TextPropCollection cb = llb.get(i);
assertEquals(ca.getCharactersCovered(), cb.getCharactersCovered());
assertEquals(ca.getTextPropList().size(), cb.getTextPropList().size());
for(int j=0; j<ca.getTextPropList().size(); j++) {
- TextProp tpa = (TextProp)ca.getTextPropList().get(j);
- TextProp tpb = (TextProp)cb.getTextPropList().get(j);
+ TextProp tpa = ca.getTextPropList().get(j);
+ TextProp tpb = cb.getTextPropList().get(j);
//System.out.println("TP " + i + " " + j + " " + tpa.getName() + "\t" + tpa.getValue() );
assertEquals(tpa.getName(), tpb.getName());
assertEquals(tpa.getMask(), tpb.getMask());
assertEquals(data.length, bytes.length);
try {
- assertTrue(Arrays.equals(data, bytes));
+ assertArrayEquals(data, bytes);
} catch (Throwable e){
//print hex dump if failed
assertEquals(HexDump.toHex(data), HexDump.toHex(bytes));
StyleTextPropAtom atom = new StyleTextPropAtom(data_d, 0, data_d.length);
atom.setParentTextSize(data_d_text_len);
- TextPropCollection prprops = (TextPropCollection)atom.getParagraphStyles().getFirst();
+ TextPropCollection prprops = atom.getParagraphStyles().getFirst();
assertEquals(data_d_text_len+1, prprops.getCharactersCovered());
assertEquals(1, prprops.getTextPropList().size()); //1 property found
assertEquals(1, prprops.findByName("alignment").getValue());
- TextPropCollection chprops = (TextPropCollection)atom.getCharacterStyles().getFirst();
+ TextPropCollection chprops = atom.getCharacterStyles().getFirst();
assertEquals(data_d_text_len+1, chprops.getCharactersCovered());
assertEquals(5, chprops.getTextPropList().size()); //5 properties found
assertEquals(1, chprops.findByName("char_flags").getValue());
package org.apache.poi.hslf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
import junit.framework.TestCase;
assertNull(tabStops);
int[] textOffsets = ruler.getTextOffsets();
- assertTrue(Arrays.equals(new int[]{226, 451, 903, 1129, 1526}, textOffsets));
+ assertArrayEquals(new int[]{226, 451, 903, 1129, 1526}, textOffsets);
int[] bulletOffsets = ruler.getBulletOffsets();
- assertTrue(Arrays.equals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets));
+ assertArrayEquals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets);
}
ruler.writeOut(out);
byte[] result = out.toByteArray();
- assertTrue(Arrays.equals(result, data_1));
+ assertArrayEquals(result, data_1);
}
public void testRead2() throws Exception {
ruler.writeOut(out);
byte[] result = out.toByteArray();
- assertTrue(Arrays.equals(result, data_2));
+ assertArrayEquals(result, data_2);
}
}
package org.apache.poi.hslf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
import junit.framework.TestCase;
spec.writeOut(out);
byte[] result = out.toByteArray();
- assertTrue(Arrays.equals(result, data_1));
+ assertArrayEquals(result, data_1);
}
public void testReset() throws Exception {
package org.apache.poi.hslf.usermodel;
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.blip.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.POIDataSamples;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.net.URL;
-import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.blip.DIB;
+import org.apache.poi.hslf.blip.EMF;
+import org.apache.poi.hslf.blip.JPEG;
+import org.apache.poi.hslf.blip.PICT;
+import org.apache.poi.hslf.blip.PNG;
+import org.apache.poi.hslf.blip.WMF;
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.hslf.model.Shape;
+import org.apache.poi.hslf.model.Slide;
/**
* Test adding/reading pictures
System.arraycopy(src_bytes, 512, b1, 0, b1.length);
byte[] b2 = new byte[ppt_bytes.length-512];
System.arraycopy(ppt_bytes, 512, b2, 0, b2.length);
- assertTrue(Arrays.equals(b1, b2));
+ assertArrayEquals(b1, b2);
}
/**
System.arraycopy(src_bytes, 22, b1, 0, b1.length);
byte[] b2 = new byte[ppt_bytes.length-22];
System.arraycopy(ppt_bytes, 22, b2, 0, b2.length);
- assertTrue(Arrays.equals(b1, b2));
+ assertArrayEquals(b1, b2);
}
/**
assertTrue(pictures[0] instanceof EMF);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
}
/**
assertTrue(pictures[0] instanceof PNG);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
}
/**
assertTrue(pictures[0] instanceof JPEG);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
}
/**
assertTrue(pictures[0] instanceof DIB);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
}
/**
assertEquals(Picture.JPEG, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("clock.jpg");
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
pict = (Picture)slides[1].getShapes()[0]; //the second slide contains PNG
pdata = pict.getPictureData();
assertEquals(Picture.PNG, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("tomcat.png");
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
pict = (Picture)slides[2].getShapes()[0]; //the third slide contains WMF
pdata = pict.getPictureData();
System.arraycopy(src_bytes, 22, b1, 0, b1.length);
b2 = new byte[ppt_bytes.length-22];
System.arraycopy(ppt_bytes, 22, b2, 0, b2.length);
- assertTrue(Arrays.equals(b1, b2));
+ assertArrayEquals(b1, b2);
pict = (Picture)slides[3].getShapes()[0]; //the forth slide contains PICT
pdata = pict.getPictureData();
System.arraycopy(src_bytes, 512, b1, 0, b1.length);
b2 = new byte[ppt_bytes.length-512];
System.arraycopy(ppt_bytes, 512, b2, 0, b2.length);
- assertTrue(Arrays.equals(b1, b2));
+ assertArrayEquals(b1, b2);
pict = (Picture)slides[4].getShapes()[0]; //the fifth slide contains EMF
pdata = pict.getPictureData();
assertEquals(Picture.EMF, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("wrench.emf");
- assertTrue(Arrays.equals(src_bytes, ppt_bytes));
+ assertArrayEquals(src_bytes, ppt_bytes);
}
package org.apache.poi.hslf.usermodel;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.TestCase;
+
import org.apache.poi.POIDataSamples;
/**
SoundData[] sound = ppt.getSoundData();
assertEquals("Expected 1 sound", 1, sound.length);
- assertTrue(Arrays.equals(ref_data, sound[0].getData()));
+ assertArrayEquals(ref_data, sound[0].getData());
}
}
package org.apache.poi.ddf;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.Arrays;
import junit.framework.TestCase;
+
import org.apache.poi.POIDataSamples;
/**
EscherBSERecord bse1 = (EscherBSERecord)bstore.getChild(0);
assertEquals(EscherBSERecord.BT_PNG, bse1.getBlipTypeWin32());
assertEquals(EscherBSERecord.BT_PNG, bse1.getBlipTypeMacOS());
- assertTrue(Arrays.equals(new byte[]{
+ assertArrayEquals(new byte[]{
0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
- }, bse1.getUid()));
+ }, bse1.getUid());
assertEquals(255, bse1.getTag());
assertEquals(32308, bse1.getSize());
EscherBitmapBlip blip1 = (EscherBitmapBlip)bse1.getBlipRecord();
assertEquals(0x6E00, blip1.getOptions());
assertEquals(EscherBitmapBlip.RECORD_ID_PNG, blip1.getRecordId());
- assertTrue(Arrays.equals(new byte[]{
+ assertArrayEquals(new byte[]{
0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
- }, blip1.getUID()));
+ }, blip1.getUID());
//serialize and read again
byte[] ser = bse1.serialize();
assertEquals(bse1.getRecordId(), bse2.getRecordId());
assertEquals(bse1.getBlipTypeWin32(), bse2.getBlipTypeWin32());
assertEquals(bse1.getBlipTypeMacOS(), bse2.getBlipTypeMacOS());
- assertTrue(Arrays.equals(bse1.getUid(), bse2.getUid()));
+ assertArrayEquals(bse1.getUid(), bse2.getUid());
assertEquals(bse1.getTag(), bse2.getTag());
assertEquals(bse1.getSize(), bse2.getSize());
assertEquals(blip1.getRecordId(), blip2.getRecordId());
assertEquals(blip1.getUID(), blip2.getUID());
- assertTrue(Arrays.equals(blip1.getPicturedata(), blip1.getPicturedata()));
+ assertArrayEquals(blip1.getPicturedata(), blip1.getPicturedata());
}
//test reading/serializing of a PICT metafile
//System.out.println(bse1);
assertEquals(EscherBSERecord.BT_WMF, bse1.getBlipTypeWin32());
assertEquals(EscherBSERecord.BT_PICT, bse1.getBlipTypeMacOS());
- assertTrue(Arrays.equals(new byte[]{
+ assertArrayEquals(new byte[]{
(byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
- }, bse1.getUid()));
+ }, bse1.getUid());
assertEquals(255, bse1.getTag());
assertEquals(1133, bse1.getSize());
EscherMetafileBlip blip1 = (EscherMetafileBlip)bse1.getBlipRecord();
assertEquals(0x5430, blip1.getOptions());
assertEquals(EscherMetafileBlip.RECORD_ID_PICT, blip1.getRecordId());
- assertTrue(Arrays.equals(new byte[]{
+ assertArrayEquals(new byte[]{
0x57, 0x32, 0x7B, (byte)0x91, 0x23, 0x5D, (byte)0xDB, 0x36,
0x7A, (byte)0xDB, (byte)0xFF, 0x17, (byte)0xFE, (byte)0xF3, (byte)0xA7, 0x05
- }, blip1.getUID()));
- assertTrue(Arrays.equals(new byte[]{
+ }, blip1.getUID());
+ assertArrayEquals(new byte[]{
(byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
- }, blip1.getPrimaryUID()));
+ }, blip1.getPrimaryUID());
//serialize and read again
byte[] ser = bse1.serialize();
assertEquals(bse1.getOptions(), bse2.getOptions());
assertEquals(bse1.getBlipTypeWin32(), bse2.getBlipTypeWin32());
assertEquals(bse1.getBlipTypeMacOS(), bse2.getBlipTypeMacOS());
- assertTrue(Arrays.equals(bse1.getUid(), bse2.getUid()));
+ assertArrayEquals(bse1.getUid(), bse2.getUid());
assertEquals(bse1.getTag(), bse2.getTag());
assertEquals(bse1.getSize(), bse2.getSize());
assertEquals(blip1.getUID(), blip2.getUID());
assertEquals(blip1.getPrimaryUID(), blip2.getPrimaryUID());
- assertTrue(Arrays.equals(blip1.getPicturedata(), blip1.getPicturedata()));
+ assertArrayEquals(blip1.getPicturedata(), blip1.getPicturedata());
}
//integral test: check that the read-write-read round trip is consistent
record.fillFields(data, 0, new DefaultEscherRecordFactory());
byte[] ser = record.serialize();
- assertTrue(Arrays.equals(data, ser));
+ assertArrayEquals(data, ser);
}
private byte[] read(File file) {
assertNotNull(remaining);
byte[] ser = bse.serialize(); //serialize and assert against the source data
- assertTrue(Arrays.equals(data, ser));
+ assertArrayEquals(data, ser);
}
}
package org.apache.poi.ddf;
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.TestCase;
-import org.apache.poi.util.HexRead;
-import org.apache.poi.util.HexDump;
-import java.util.Arrays;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
public final class TestEscherOptRecord extends TestCase {
opt2.fillFields( data1, new DefaultEscherRecordFactory() );
byte[] data2 = opt2.serialize();
- assertTrue(Arrays.equals(data1, data2));
+ assertArrayEquals(data1, data2);
}
/**
assertEquals(0, p.getNumberOfElementsInArray());
byte[] data2 = opt2.serialize();
- assertTrue(Arrays.equals(data1, data2));
+ assertArrayEquals(data1, data2);
}
}
==================================================================== */\r
package org.apache.poi.hssf.model;\r
\r
+import static org.junit.Assert.assertArrayEquals;\r
+\r
import java.io.ByteArrayInputStream;\r
import java.io.ByteArrayOutputStream;\r
import java.io.File;\r
public void testAllTestSamples(){\r
File[] xls = new File(System.getProperty("POI.testdata.path"), "spreadsheet").listFiles(\r
new FilenameFilter() {\r
+ @Override\r
public boolean accept(File dir, String name) {\r
return name.endsWith(".xls");\r
}\r
assertEquals(r1.getRecordSize(), r2.getRecordSize());\r
if (r1 instanceof Record) {\r
assertEquals(((Record) r1).getSid(), ((Record) r2).getSid());\r
- assertTrue(Arrays.equals(((Record) r1).serialize(), ((Record) r2).serialize()));\r
+ assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());\r
}\r
}\r
}\r
package org.apache.poi.hssf.model;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.common.UnicodeString;
-import org.apache.poi.ss.formula.constant.ErrorConstant;
-import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg;
-import org.apache.poi.ss.formula.ptg.AddPtg;
-import org.apache.poi.ss.formula.ptg.Area3DPtg;
-import org.apache.poi.ss.formula.ptg.AreaI;
-import org.apache.poi.ss.formula.ptg.AreaPtg;
-import org.apache.poi.ss.formula.ptg.AreaPtgBase;
-import org.apache.poi.ss.formula.ptg.ArrayPtg;
-import org.apache.poi.ss.formula.ptg.AttrPtg;
-import org.apache.poi.ss.formula.ptg.BoolPtg;
-import org.apache.poi.ss.formula.ptg.ConcatPtg;
-import org.apache.poi.ss.formula.ptg.DividePtg;
-import org.apache.poi.ss.formula.ptg.EqualPtg;
-import org.apache.poi.ss.formula.ptg.ErrPtg;
-import org.apache.poi.ss.formula.ptg.FuncPtg;
-import org.apache.poi.ss.formula.ptg.FuncVarPtg;
-import org.apache.poi.ss.formula.ptg.IntPtg;
-import org.apache.poi.ss.formula.ptg.MemAreaPtg;
-import org.apache.poi.ss.formula.ptg.MemFuncPtg;
-import org.apache.poi.ss.formula.ptg.MissingArgPtg;
-import org.apache.poi.ss.formula.ptg.MultiplyPtg;
-import org.apache.poi.ss.formula.ptg.NamePtg;
-import org.apache.poi.ss.formula.ptg.NumberPtg;
-import org.apache.poi.ss.formula.ptg.ParenthesisPtg;
-import org.apache.poi.ss.formula.ptg.PercentPtg;
-import org.apache.poi.ss.formula.ptg.PowerPtg;
-import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.formula.ptg.RangePtg;
-import org.apache.poi.ss.formula.ptg.Ref3DPtg;
-import org.apache.poi.ss.formula.ptg.RefPtg;
-import org.apache.poi.ss.formula.ptg.StringPtg;
-import org.apache.poi.ss.formula.ptg.SubtractPtg;
-import org.apache.poi.ss.formula.ptg.UnaryMinusPtg;
-import org.apache.poi.ss.formula.ptg.UnaryPlusPtg;
-import org.apache.poi.ss.formula.ptg.UnionPtg;
import org.apache.poi.hssf.usermodel.FormulaExtractor;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.formula.constant.ErrorConstant;
+import org.apache.poi.ss.formula.ptg.*;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.util.HexRead;
+ "00 00 00 " // Array data: 1 col, 1 row
+ "02 01 00 00 35" // elem (type=string, len=1, "5")
);
- assertTrue(Arrays.equals(expData, data));
+ assertArrayEquals(expData, data);
int initSize = Ptg.getEncodedSizeWithoutArrayData(ptgs);
Ptg[] ptgs2 = Ptg.readTokens(initSize, new LittleEndianByteArrayInputStream(data));
confirmTokenClasses(ptgs2, ArrayPtg.class, IntPtg.class, FuncVarPtg.class);
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.TestCase;
-import java.util.Arrays;
/**
* Tests the AutoFilterInfoRecord class.
byte[] cln = cloned.serialize();
assertEquals(record.getDataSize(), cloned.getDataSize());
- assertTrue(Arrays.equals(src, cln));
+ assertArrayEquals(src, cln);
}
}
\ No newline at end of file
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
"00 00 00 00 0F 00 " +
"01 00 " // normal number of data bytes
);
- assertTrue(Arrays.equals(expData, outData));
+ assertArrayEquals(expData, outData);
}
}
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import org.apache.poi.util.HexRead;
-
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+
/**
* Tests BoundSheetRecord.
*
assertEquals("\u0421\u0442\u0440\u0430\u043D\u0438\u0447\u043A\u0430", bsr.getSheetname());
byte[] data2 = bsr.serialize();
- assertTrue(Arrays.equals(data, data2));
+ assertArrayEquals(data, data2);
}
public void testOrdering() {
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
assertEquals(true, cir.getHidden());
assertEquals(3, cir.getOutlineLevel());
assertEquals(true, cir.getCollapsed());
- assertTrue(Arrays.equals(data, cir.serialize()));
+ assertArrayEquals(data, cir.serialize());
}
/**
throw e;
}
assertEquals(0, in.remaining());
- assertTrue(Arrays.equals(outData, cir.serialize()));
+ assertArrayEquals(outData, cir.serialize());
}
/**
RecordInputStream in = TestcaseRecordInputStream.create(inpData);
ColumnInfoRecord cir = new ColumnInfoRecord(in);
assertEquals(0, in.remaining());
- assertTrue(Arrays.equals(outData, cir.serialize()));
+ assertArrayEquals(outData, cir.serialize());
}
}
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
* Check that RecordFactoryInputStream properly handles continued DrawingRecords
* See Bugzilla #47548
*/
+ @SuppressWarnings("deprecation")
public void testReadContinued() throws IOException {
//simulate a continues drawing record
assertTrue(rec.get(0) instanceof DrawingRecord);
assertTrue(rec.get(1) instanceof ContinueRecord);
- assertTrue(Arrays.equals(data1, ((DrawingRecord)rec.get(0)).getData()));
- assertTrue(Arrays.equals(data2, ((ContinueRecord)rec.get(1)).getData()));
+ assertArrayEquals(data1, ((DrawingRecord)rec.get(0)).getData());
+ assertArrayEquals(data2, ((ContinueRecord)rec.get(1)).getData());
}
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
assertEquals(record1.getOLEClassName(), record2.getOLEClassName());
byte[] ser2 = record1.serialize();
- assertTrue(Arrays.equals(ser, ser2));
+ assertArrayEquals(ser, ser2);
}
/**
assertEquals(record1.getStreamId(), record2.getStreamId());
byte[] ser2 = record1.serialize();
- assertTrue(Arrays.equals(ser, ser2));
+ assertArrayEquals(ser, ser2);
}
public void testCameraTool_bug45912() {
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.TestCase;
-import java.util.Arrays;
-
/**
* Tests the serialization and deserialization of the FtCblsSubRecord
* class works correctly.
byte[] cln = cloned.serialize();
assertEquals(record.getDataSize(), cloned.getDataSize());
- assertTrue(Arrays.equals(src, cln));
+ assertArrayEquals(src, cln);
}
}
\ No newline at end of file
==================================================================== */
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
link = new HyperlinkRecord(is);
byte[] bytes2 = link.serialize();
assertEquals(bytes1.length, bytes2.length);
- assertTrue(Arrays.equals(bytes1, bytes2));
+ assertArrayEquals(bytes1, bytes2);
}
public void testSerialize(){
byte[] ser = new byte[tmp.length-4];
System.arraycopy(tmp, 4, ser, 0, ser.length);
assertEquals(data1.length, ser.length);
- assertTrue(Arrays.equals(data1, ser));
+ assertArrayEquals(data1, ser);
}
public void testCreateFileRecord() {
byte[] ser = new byte[tmp.length-4];
System.arraycopy(tmp, 4, ser, 0, ser.length);
assertEquals(data2.length, ser.length);
- assertTrue(Arrays.equals(data2, ser));
+ assertArrayEquals(data2, ser);
}
public void testCreateDocumentRecord() {
byte[] ser = new byte[tmp.length-4];
System.arraycopy(tmp, 4, ser, 0, ser.length);
assertEquals(data4.length, ser.length);
- assertTrue(Arrays.equals(data4, ser));
+ assertArrayEquals(data4, ser);
}
public void testCreateEmailtRecord() {
byte[] ser = new byte[tmp.length-4];
System.arraycopy(tmp, 4, ser, 0, ser.length);
assertEquals(data3.length, ser.length);
- assertTrue(Arrays.equals(data3, ser));
+ assertArrayEquals(data3, ser);
}
public void testClone() {
RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data[i]);
HyperlinkRecord link = new HyperlinkRecord(is);
HyperlinkRecord clone = (HyperlinkRecord)link.clone();
- assertTrue(Arrays.equals(link.serialize(), clone.serialize()));
+ assertArrayEquals(link.serialize(), clone.serialize());
}
}
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
+import java.io.IOException;
import junit.framework.TestCase;
RecordInputStream in2 = TestcaseRecordInputStream.create(ser);
ObjRecord record2 = new ObjRecord(in2);
byte[] ser2 = record2.serialize();
- assertTrue(Arrays.equals(ser, ser2));
+ assertArrayEquals(ser, ser2);
}
- public void test_LbsDropData(){
+ public void test_LbsDropData() throws IOException{
byte[] data = HexRead.readFromString(
//LbsDropData
"0A, 00, " + //flags
"00"); //padding byte
LittleEndianInputStream in = new LittleEndianInputStream(new ByteArrayInputStream(data));
-
- LbsDataSubRecord.LbsDropData lbs = new LbsDataSubRecord.LbsDropData(in);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- lbs.serialize(new LittleEndianOutputStream(baos));
-
- assertTrue(Arrays.equals(data, baos.toByteArray()));
+ try {
+ LbsDataSubRecord.LbsDropData lbs = new LbsDataSubRecord.LbsDropData(in);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
+ try {
+ lbs.serialize(out);
+
+ assertArrayEquals(data, baos.toByteArray());
+ } finally {
+ out.close();
+ }
+ } finally {
+ in.close();
+ }
}
}
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import java.util.Arrays;
-
import org.apache.poi.util.HexRead;
/**
//finally check that the serialized data is the same
byte[] src = record.serialize();
byte[] cln = cloned.serialize();
- assertTrue(Arrays.equals(src, cln));
+ assertArrayEquals(src, cln);
}
public void testUnicodeAuthor() {
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.TestCase;
-import java.util.Arrays;
-
/**
* Tests the serialization and deserialization of the NoteRecord
* class works correctly. Test data taken directly from a real
byte[] cln = cloned.serialize();
assertEquals(record.getDataSize(), cloned.getDataSize());
- assertTrue(Arrays.equals(src, cln));
+ assertArrayEquals(src, cln);
}
}
package org.apache.poi.hssf.record;
-import java.util.Arrays;
+import static org.junit.Assert.assertArrayEquals;
+
import java.util.List;
import junit.framework.AssertionFailedError;
assertEquals(26, recordBytes.length - 4);
byte[] subData = new byte[recdata.length];
System.arraycopy(recordBytes, 4, subData, 0, subData.length);
- assertTrue(Arrays.equals(recdata, subData));
+ assertArrayEquals(recdata, subData);
}
public void testConstruct() {
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
throw e;
}
assertEquals(0, in.remaining());
- assertTrue(Arrays.equals(r.serialize(), goodData));
+ assertArrayEquals(r.serialize(), goodData);
}
}
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
byte[] ser = out.toByteArray();
assertEquals(data.length, ser.length);
- assertTrue(Arrays.equals(data, ser));
+ assertArrayEquals(data, ser);
}
public void testNonZeroPadding_bug46987() {
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 java.io.ByteArrayInputStream;
-import java.util.Arrays;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
private void confirmReadInitialRecords(RecordFactoryInputStream rfis) {
assertEquals(BOFRecord.class, rfis.nextRecord().getClass());
WindowOneRecord rec1 = (WindowOneRecord) rfis.nextRecord();
- assertTrue(Arrays.equals(HexRead.readFromString(SAMPLE_WINDOW1),rec1.serialize()));
+ assertArrayEquals(HexRead.readFromString(SAMPLE_WINDOW1),rec1.serialize());
}
private static RecordFactoryInputStream createRFIS(byte[] data) {
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
assertEquals( 688, record.getNumUniqueStrings() );
assertEquals( 688, record.countStrings() );
ser_output = record.serialize();
- assertTrue(Arrays.equals(origData, ser_output));
+ assertArrayEquals(origData, ser_output);
// testing based on new bug report
origData = concatHexDumps("BigSSTRecord2", "BigSSTRecord2CR1", "BigSSTRecord2CR2", "BigSSTRecord2CR3",
// TODO - trivial differences in ContinueRecord break locations
// Sample data should be checked against what most recent Excel version produces.
// maybe tweaks are required in ContinuableRecordOutput
- assertTrue(Arrays.equals(origData, ser_output));
+ assertArrayEquals(origData, ser_output);
}
}
package org.apache.poi.hssf.record;
-import java.util.Arrays;
-
+import static org.junit.Assert.assertArrayEquals;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
throw new AssertionFailedError("Identified bug 45778");
}
assertEquals(74, data2.length);
- assertTrue(Arrays.equals(dataAutoFilter, data2));
+ assertArrayEquals(dataAutoFilter, data2);
}
public void testReadManualComboWithFormula() {
throw new AssertionFailedError("Encoded data differs at index " + i);
}
}
- assertTrue(Arrays.equals(data, data2));
+ assertArrayEquals(data, data2);
}
/**
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.ByteArrayInputStream;
-import java.util.Arrays;
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.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.util.HexRead;
import org.apache.poi.util.LittleEndian;
byte [] ser = record.serialize();
assertEquals(ser.length , simpleData.length);
- assertTrue(Arrays.equals(simpleData, ser));
+ assertArrayEquals(simpleData, ser);
//read again
RecordInputStream is = TestcaseRecordInputStream.create(simpleData);
//finally check that the serialized data is the same
byte[] src = obj.serialize();
byte[] cln = cloned.serialize();
- assertTrue(Arrays.equals(src, cln));
+ assertArrayEquals(src, cln);
}
/** similar to {@link #simpleData} but with link formula at end of TXO rec*/
byte [] data2 = rec.serialize();
assertEquals(linkData.length, data2.length);
- assertTrue(Arrays.equals(linkData, data2));
+ assertArrayEquals(linkData, data2);
}
}
package org.apache.poi.hssf.record.aggregates;
+import static org.junit.Assert.assertArrayEquals;
+
import java.util.Arrays;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.RecordStream;
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.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFSheet;
Record[] outRecs = rc.getRecords();
// records were assembled in standard order, so this simple check is OK
- assertTrue(Arrays.equals(recs, outRecs));
+ assertArrayEquals(recs, outRecs);
}
public void testDuplicateHeaderFooter_bug48026() {
}
HeaderFooterRecord hd1 = (HeaderFooterRecord)expectedRecs[4];
//GUID is zero
- assertTrue(Arrays.equals(new byte[16], hd1.getGuid()));
+ assertArrayEquals(new byte[16], hd1.getGuid());
assertTrue(hd1.isCurrentSheet());
UserSViewBegin svb = (UserSViewBegin)expectedRecs[7];
HeaderFooterRecord hd2 = (HeaderFooterRecord)expectedRecs[9];
assertFalse(hd2.isCurrentSheet());
//GUIDs of HeaderFooterRecord and UserSViewBegin must be the same
- assertTrue(Arrays.equals(svb.getGuid(), hd2.getGuid()));
+ assertArrayEquals(svb.getGuid(), hd2.getGuid());
}
}
package org.apache.poi.hssf.record.aggregates;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.zip.CRC32;
valueRecord.visitCellsForRow(1, sv);
valueRecord.visitCellsForRow(2, sv);
assertEquals(actualArray.length, sv.getWriteIndex());
- assertTrue(Arrays.equals(expectedArray, actualArray));
+ assertArrayEquals(expectedArray, actualArray);
}
private static BlankRecord newBlankRecord() {
package org.apache.poi.hssf.record.chart;
-import java.util.Arrays;
+import static org.junit.Assert.assertArrayEquals;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.TestcaseRecordInputStream;
import org.apache.poi.util.HexRead;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
/**
* Tests for {@link ChartFormatRecord} Test data taken directly from a real
* Excel file.
assertEquals(24, record.getRecordSize());
byte[] data2 = record.serialize();
- assertTrue(Arrays.equals(data, data2));
+ assertArrayEquals(data, data2);
}
}
package org.apache.poi.hssf.usermodel;
+import static org.junit.Assert.assertArrayEquals;
+
+import java.io.IOException;
+import java.util.Arrays;
+
import junit.framework.TestCase;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.ss.util.CellRangeAddress;
-import java.io.IOException;
-import java.util.Arrays;
-
/**
* Test the ability to clone a sheet.
* If adding new records that belong to a sheet (as opposed to a book)
assertEquals(agg1.serialize().length, agg2.serialize().length);
assertEquals(agg1.toXml(""), agg2.toXml(""));
- assertTrue(Arrays.equals(agg1.serialize(), agg2.serialize()));
+ assertArrayEquals(agg1.serialize(), agg2.serialize());
}
public void testCloneComment() throws IOException {
HSSFPatriarch p2 = sh2.getDrawingPatriarch();
HSSFComment c2 = (HSSFComment) p2.getChildren().get(0);
- assertTrue(Arrays.equals(c2.getTextObjectRecord().serialize(), c.getTextObjectRecord().serialize()));
- assertTrue(Arrays.equals(c2.getObjRecord().serialize(), c.getObjRecord().serialize()));
- assertTrue(Arrays.equals(c2.getNoteRecord().serialize(), c.getNoteRecord().serialize()));
+ assertArrayEquals(c2.getTextObjectRecord().serialize(), c.getTextObjectRecord().serialize());
+ assertArrayEquals(c2.getObjRecord().serialize(), c.getObjRecord().serialize());
+ assertArrayEquals(c2.getNoteRecord().serialize(), c.getNoteRecord().serialize());
//everything except spRecord.shapeId must be the same
assertFalse(Arrays.equals(c2.getEscherContainer().serialize(), c.getEscherContainer().serialize()));
EscherSpRecord sp = (EscherSpRecord) c2.getEscherContainer().getChild(0);
sp.setShapeId(1025);
- assertTrue(Arrays.equals(c2.getEscherContainer().serialize(), c.getEscherContainer().serialize()));
+ assertArrayEquals(c2.getEscherContainer().serialize(), c.getEscherContainer().serialize());
}
}
package org.apache.poi.hssf.usermodel;
-import java.util.Arrays;
+import static org.junit.Assert.assertArrayEquals;
+
import java.util.Iterator;
import java.util.Map;
HSSFPalette p = book.getCustomPalette();
/* first test the defaults */
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 255, (short) 255, (short) 0}, // not [204, 255, 255]
p.findSimilarColor((byte) 204, (byte) 255, (byte) 0).getTriplet()
- )
);
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 153, (short) 204, (short) 0}, // not [128, 0, 0]
p.findSimilarColor((byte) 128, (byte) 255, (byte) 0).getTriplet()
- )
);
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 0, (short) 255, (short) 0}, // not [0, 51, 102]
p.findSimilarColor((byte) 0, (byte) 255, (byte) 102).getTriplet()
- )
);
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 0, (short) 102, (short) 204}, // not [255, 102, 0]
p.findSimilarColor((byte) 0, (byte) 102, (byte) 255).getTriplet()
- )
);
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 255, (short) 0, (short) 255}, // not [128, 0, 0]
p.findSimilarColor((byte) 128, (byte) 0, (byte) 255).getTriplet()
- )
);
- assertTrue(
- Arrays.equals(
+ assertArrayEquals(
new short[] {(short) 255, (short) 0, (short) 255}, // not [255, 255, 153]
p.findSimilarColor((byte) 255, (byte) 0, (byte) 153).getTriplet()
- )
);
*/
public void testGnumericStrings() {
compareToDefaults(new ColorComparator() {
+ @Override
public void compare(HSSFColor expected, HSSFColor palette)
{
assertEquals(expected.getHexString(), palette.getHexString());
//should still match defaults;
compareToDefaults(new ColorComparator() {
+ @Override
public void compare(HSSFColor expected, HSSFColor palette)
{
short[] s1 = expected.getTriplet();
package org.apache.poi.hssf.usermodel;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.IOException;
-import java.util.Arrays;
import java.util.List;
import org.apache.poi.POIDataSamples;
int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
assertEquals(1, idx1);
HSSFPicture p1 = dr.createPicture(anchor, idx1);
- assertTrue(Arrays.equals(data1, p1.getPictureData().getData()));
+ assertArrayEquals(data1, p1.getPictureData().getData());
// register another one
byte[] data2 = new byte[]{4, 5, 6};
assertEquals(2, idx2);
HSSFPicture p2 = dr.createPicture(anchor, idx2);
assertEquals(2, dr.getChildren().size());
- assertTrue(Arrays.equals(data2, p2.getPictureData().getData()));
+ assertArrayEquals(data2, p2.getPictureData().getData());
// confirm that HSSFPatriarch.getChildren() returns two picture shapes
- 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());
// write, read back and verify that our pictures are there
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
List<? extends PictureData> 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};
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<? extends PictureData> 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();
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<? extends PictureData> 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(){
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);
}
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;
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());
}
\r
package org.apache.poi.hssf.usermodel;\r
\r
+import static org.junit.Assert.assertArrayEquals;\r
+\r
+import java.io.IOException;\r
+\r
import junit.framework.TestCase;\r
+\r
import org.apache.poi.ddf.EscherArrayProperty;\r
import org.apache.poi.ddf.EscherOptRecord;\r
import org.apache.poi.ddf.EscherProperties;\r
import org.apache.poi.hssf.model.PolygonShape;\r
import org.apache.poi.hssf.record.ObjRecord;\r
\r
-import java.io.IOException;\r
-import java.util.Arrays;\r
-\r
/**\r
* @author Evgeniy Berlog\r
* @date 28.06.12\r
byte[] actual = polygon.getEscherContainer().getChild(0).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
expected = polygonShape.getSpContainer().getChild(2).serialize();\r
actual = polygon.getEscherContainer().getChild(2).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
expected = polygonShape.getSpContainer().getChild(3).serialize();\r
actual = polygon.getEscherContainer().getChild(3).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
ObjRecord obj = polygon.getObjRecord();\r
ObjRecord objShape = polygonShape.getObjRecord();\r
actual = objShape.serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
}\r
\r
public void testPolygonPoints(){\r
assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));\r
\r
polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});\r
\r
polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);\r
verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);\r
polygon.setPolygonDrawArea( 102, 101 );\r
polygon.setPoints( new int[]{1,2,3}, new int[]{4,5,6} );\r
\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1,2,3}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{1,2,3});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});\r
assertEquals(polygon.getDrawAreaHeight(), 101);\r
assertEquals(polygon.getDrawAreaWidth(), 102);\r
\r
patriarch = sh.getDrawingPatriarch();\r
\r
polygon = (HSSFPolygon) patriarch.getChildren().get(0);\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4, 5, 6}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});\r
assertEquals(polygon.getDrawAreaHeight(), 101);\r
assertEquals(polygon.getDrawAreaWidth(), 102);\r
\r
polygon.setPolygonDrawArea( 1021, 1011 );\r
polygon.setPoints( new int[]{11,21,31}, new int[]{41,51,61} );\r
\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{11, 21, 31}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{41, 51, 61}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{11, 21, 31});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});\r
assertEquals(polygon.getDrawAreaHeight(), 1011);\r
assertEquals(polygon.getDrawAreaWidth(), 1021);\r
\r
\r
polygon = (HSSFPolygon) patriarch.getChildren().get(0);\r
\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{11, 21, 31}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{41, 51, 61}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{11, 21, 31});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});\r
assertEquals(polygon.getDrawAreaHeight(), 1011);\r
assertEquals(polygon.getDrawAreaWidth(), 1021);\r
}\r
polygon1 = (HSSFPolygon) patriarch.getChildren().get(1);\r
polygon2 = (HSSFPolygon) patriarch.getChildren().get(2);\r
\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{1, 2, 3}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{4,5,6}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{4,5,6});\r
assertEquals(polygon.getDrawAreaHeight(), 101);\r
assertEquals(polygon.getDrawAreaWidth(), 102);\r
\r
- assertTrue(Arrays.equals(polygon1.getXPoints(), new int[]{11,12,13}));\r
- assertTrue(Arrays.equals(polygon1.getYPoints(), new int[]{14,15,16}));\r
+ assertArrayEquals(polygon1.getXPoints(), new int[]{11,12,13});\r
+ assertArrayEquals(polygon1.getYPoints(), new int[]{14,15,16});\r
assertEquals(polygon1.getDrawAreaHeight(), 104);\r
assertEquals(polygon1.getDrawAreaWidth(), 103);\r
\r
- assertTrue(Arrays.equals(polygon2.getXPoints(), new int[]{21,22,23}));\r
- assertTrue(Arrays.equals(polygon2.getYPoints(), new int[]{24,25,26}));\r
+ assertArrayEquals(polygon2.getXPoints(), new int[]{21,22,23});\r
+ assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26});\r
assertEquals(polygon2.getDrawAreaHeight(), 204);\r
assertEquals(polygon2.getDrawAreaWidth(), 203);\r
}\r
HSSFPolygon polygon = (HSSFPolygon) drawing.getChildren().get(0);\r
assertEquals(polygon.getDrawAreaHeight(), 2466975);\r
assertEquals(polygon.getDrawAreaWidth(), 3686175);\r
- assertTrue(Arrays.equals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502}));\r
- assertTrue(Arrays.equals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18}));\r
+ assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502});\r
+ assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18});\r
}\r
\r
public void testPolygonType(){\r
\r
package org.apache.poi.hssf.usermodel;\r
\r
+import static org.junit.Assert.assertArrayEquals;\r
import junit.framework.TestCase;\r
+\r
import org.apache.poi.hssf.HSSFTestDataSamples;\r
import org.apache.poi.hssf.model.HSSFTestModelHelper;\r
import org.apache.poi.hssf.model.TextboxShape;\r
import org.apache.poi.hssf.record.ObjRecord;\r
import org.apache.poi.hssf.record.TextObjectRecord;\r
\r
-import java.util.Arrays;\r
-\r
/**\r
* @author Evgeniy Berlog\r
* @date 25.06.12\r
byte[] actual = textbox.getEscherContainer().getChild(0).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
expected = textboxShape.getSpContainer().getChild(2).serialize();\r
actual = textbox.getEscherContainer().getChild(2).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
expected = textboxShape.getSpContainer().getChild(3).serialize();\r
actual = textbox.getEscherContainer().getChild(3).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
expected = textboxShape.getSpContainer().getChild(4).serialize();\r
actual = textbox.getEscherContainer().getChild(4).serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
\r
ObjRecord obj = textbox.getObjRecord();\r
ObjRecord objShape = textboxShape.getObjRecord();\r
actual = torShape.serialize();\r
\r
assertEquals(expected.length, actual.length);\r
- assertTrue(Arrays.equals(expected, actual));\r
+ assertArrayEquals(expected, actual);\r
}\r
\r
public void testAddTextToExistingFile() {\r
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;
if(outBuf[0] == 4) {
throw new AssertionFailedError("Identified bug 42564b");
}
- assertTrue(Arrays.equals(ENCODED_CONSTANT_DATA, outBuf));
+ assertArrayEquals(ENCODED_CONSTANT_DATA, outBuf);
}
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;
} catch (ArrayIndexOutOfBoundsException e) {
throw new AssertionFailedError("incorrect re-serialization of tAttrChoose");
}
- assertTrue(Arrays.equals(data, data2));
+ assertArrayEquals(data, data2);
}
}
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;
if (outData[0] == 0x24) {
throw new AssertionFailedError("Identified bug 45091");
}
- assertTrue(Arrays.equals(tRefN_data, outData));
+ assertArrayEquals(tRefN_data, outData);
}
/**
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;
// 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());
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;
}
byte[] expBuf = HexRead.readFromString("77 66 55 44");
- assertTrue(Arrays.equals(actBuf, expBuf));
+ assertArrayEquals(actBuf, expBuf);
assertEquals(0x33, lei.readUByte());
assertEquals(0, lei.available());
}