From 4241f26a136fb3040e2a5998b413244e50f7db3b Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 22 Nov 2015 12:30:42 +0000 Subject: [PATCH] fix unnecessary cast warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1715626 13f79535-47bb-0310-9956-ffa450edef68 --- .../examples/AddDimensionedImage.java | 20 +++++---- .../apache/poi/hssf/view/SVSheetTable.java | 2 +- .../poi/hssf/view/SVTableCellEditor.java | 32 ++++++++------ .../apache/poi/hssf/view/SVTableUtils.java | 2 +- .../poifs/poibrowser/TreeReaderListener.java | 4 +- .../usermodel/examples/CreatePivotTable.java | 3 +- .../apache/poi/hssf/record/CFRuleBase.java | 4 +- .../poi/hssf/record/cf/DataBarFormatting.java | 6 +-- .../poi/sl/draw/binding/CTSRgbColor.java | 2 +- .../poi/sl/draw/binding/CTSystemColor.java | 2 +- .../apache/poi/ss/format/SimpleFraction.java | 2 +- .../poi/xssf/streaming/TestOutlining.java | 37 ++++++++++------ .../poi/hwpf/model/OldSectionTable.java | 1 - .../apache/poi/hwpf/model/PAPBinTable.java | 1 - .../src/org/apache/poi/hwpf/model/Sttb.java | 2 +- .../hwpf/model/types/FSPAAbstractType.java | 2 +- .../hslf/extractor/TestCruddyExtractor.java | 2 +- .../poi/hwpf/usermodel/TestPictures.java | 42 +++++++++++++------ .../poi/hwpf/usermodel/TestRangeDelete.java | 8 ++-- .../apache/poi/hpsf/TestVariantSupport.java | 2 +- .../hssf/record/TestAutoFilterInfoRecord.java | 2 +- .../poi/hssf/record/TestCFRuleRecord.java | 2 +- .../poi/hssf/record/TestFtCblsSubRecord.java | 2 +- .../poi/hssf/record/TestHyperlinkRecord.java | 2 +- .../poi/hssf/record/TestMergeCellsRecord.java | 2 +- .../poi/hssf/record/TestNoteRecord.java | 2 +- .../record/TestNoteStructureSubRecord.java | 2 +- .../poi/poifs/filesystem/TestDocument.java | 5 +-- .../poi/ss/formula/functions/TestMathX.java | 10 ++--- 29 files changed, 119 insertions(+), 86 deletions(-) diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java index 6482f186c0..77a077582f 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java @@ -250,7 +250,6 @@ public class AddDimensionedImage { String imageFile, double reqImageWidthMM, double reqImageHeightMM, int resizeBehaviour) throws FileNotFoundException, IOException, IllegalArgumentException { - HSSFRow row = null; HSSFClientAnchor anchor = null; HSSFPatriarch patriarch = null; ClientAnchorDetail rowClientAnchorDetail = null; @@ -720,7 +719,6 @@ public class AddDimensionedImage { public static void main(String[] args) { String imageFile = null; String outputFile = null; - FileInputStream fis = null; FileOutputStream fos = null; HSSFWorkbook workbook = null; HSSFSheet sheet = null; @@ -753,14 +751,20 @@ public class AddDimensionedImage { ioEx.printStackTrace(System.out); } finally { - if(fos != null) { - try { + try { + if (workbook != null) { + workbook.close(); + } + } catch(IOException ioEx) { + // I G N O R E + } + try { + if(fos != null) { fos.close(); fos = null; } - catch(IOException ioEx) { - // I G N O R E - } + } catch(IOException ioEx) { + // I G N O R E } } } @@ -912,7 +916,7 @@ public class AddDimensionedImage { int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR) * UNIT_OFFSET_LENGTH; int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR; - pixels += Math.round((float) offsetWidthUnits / + pixels += Math.round(offsetWidthUnits / ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH)); return pixels; } diff --git a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java index 1739eb6160..caace28f7f 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java @@ -163,7 +163,7 @@ public class SVSheetTable extends JTable { Row row = sheet.getRow(i - sheet.getFirstRowNum()); if (row != null) { short h = row.getHeight(); - int height = (int)Math.round(Math.max(1., ((double)h) / (((double)res) / 70. * 20.) + 3.)); + int height = (int)Math.round(Math.max(1., h / (res / 70. * 20.) + 3.)); System.out.printf("%d: %d (%d @ %d)%n", i, height, h, res); setRowHeight(i, height); } diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java index b0c57b0fe0..9714b7e2b0 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java @@ -18,14 +18,25 @@ package org.apache.poi.hssf.view; -import java.awt.*; -import java.awt.event.*; -import java.util.*; - -import javax.swing.*; -import javax.swing.table.*; - -import org.apache.poi.hssf.usermodel.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.util.EventObject; +import java.util.Map; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.table.TableCellEditor; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; /** @@ -43,9 +54,6 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd private HSSFWorkbook wb; private JTextField editor; - private HSSFCell editorValue; - - public SVTableCellEditor(HSSFWorkbook wb) { this.wb = wb; this.editor = new JTextField(); @@ -191,7 +199,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd * */ private final Color getAWTColor(int index, Color deflt) { - HSSFColor clr = (HSSFColor)colors.get(Integer.valueOf(index)); + HSSFColor clr = colors.get(index); if (clr == null) return deflt; return getAWTColor(clr); } diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java b/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java index 23ffb851bd..395f1cdb8d 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java @@ -72,7 +72,7 @@ public class SVTableUtils { * @return The aWTColor value */ public final static Color getAWTColor(int index, Color deflt) { - HSSFColor clr = (HSSFColor) colors.get(Integer.valueOf(index)); + HSSFColor clr = colors.get(index); if (clr == null) { return deflt; } diff --git a/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java b/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java index a5435c0ce3..531e66b923 100644 --- a/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java +++ b/src/examples/src/org/apache/poi/poifs/poibrowser/TreeReaderListener.java @@ -182,7 +182,7 @@ public class TreeReaderListener implements POIFSReaderListener final String fsName, final MutableTreeNode root) { - MutableTreeNode n = (MutableTreeNode) pathToNode.get(path); + MutableTreeNode n = pathToNode.get(path); if (n != null) /* Node found in map, just return it. */ return n; @@ -193,7 +193,7 @@ public class TreeReaderListener implements POIFSReaderListener * the POI filesystem itself. This is a tree node with the * POI filesystem's name (this the operating system file's * name) as its key it the path-to-node map. */ - n = (MutableTreeNode) pathToNode.get(fsName); + n = pathToNode.get(fsName); if (n == null) { /* A tree node for the POI filesystem does not yet diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java index a2c61e2e26..518ec37f48 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java @@ -34,7 +34,7 @@ public class CreatePivotTable { public static void main(String[] args) throws FileNotFoundException, IOException, InvalidFormatException { XSSFWorkbook wb = new XSSFWorkbook(); - XSSFSheet sheet = (XSSFSheet) wb.createSheet(); + XSSFSheet sheet = wb.createSheet(); //Create some data to build the pivot table on setCellData(sheet); @@ -53,6 +53,7 @@ public class CreatePivotTable { FileOutputStream fileOut = new FileOutputStream("ooxml-pivottable.xlsx"); wb.write(fileOut); fileOut.close(); + wb.close(); } public static void setCellData(XSSFSheet sheet){ diff --git a/src/java/org/apache/poi/hssf/record/CFRuleBase.java b/src/java/org/apache/poi/hssf/record/CFRuleBase.java index a7bfb825c5..e8eece7cf8 100644 --- a/src/java/org/apache/poi/hssf/record/CFRuleBase.java +++ b/src/java/org/apache/poi/hssf/record/CFRuleBase.java @@ -440,10 +440,10 @@ public abstract class CFRuleBase extends StandardRecord implements Cloneable { rec.formatting_options = formatting_options; rec.formatting_not_used = formatting_not_used; if (containsFontFormattingBlock()) { - rec._fontFormatting = (FontFormatting) _fontFormatting.clone(); + rec._fontFormatting = _fontFormatting.clone(); } if (containsBorderFormattingBlock()) { - rec._borderFormatting = (BorderFormatting) _borderFormatting.clone(); + rec._borderFormatting = _borderFormatting.clone(); } if (containsPatternFormattingBlock()) { rec._patternFormatting = (PatternFormatting) _patternFormatting.clone(); diff --git a/src/java/org/apache/poi/hssf/record/cf/DataBarFormatting.java b/src/java/org/apache/poi/hssf/record/cf/DataBarFormatting.java index 3ca419553e..8810ef59c5 100644 --- a/src/java/org/apache/poi/hssf/record/cf/DataBarFormatting.java +++ b/src/java/org/apache/poi/hssf/record/cf/DataBarFormatting.java @@ -135,9 +135,9 @@ public final class DataBarFormatting implements Cloneable { rec.options = options; rec.percentMin = percentMin; rec.percentMax = percentMax; - rec.color = (ExtendedColor)color.clone(); - rec.thresholdMin = (DataBarThreshold)thresholdMin.clone(); - rec.thresholdMax = (DataBarThreshold)thresholdMax.clone(); + rec.color = color.clone(); + rec.thresholdMin = thresholdMin.clone(); + rec.thresholdMax = thresholdMax.clone(); return rec; } diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java b/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java index cd2f337fdb..36cefe532a 100644 --- a/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java +++ b/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java @@ -176,7 +176,7 @@ public class CTSRgbColor { * */ public void setVal(byte[] value) { - this.val = ((byte[]) value); + this.val = (value != null) ? value.clone() : null; } public boolean isSetVal() { diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java b/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java index e9c21832da..1300f87f56 100644 --- a/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java +++ b/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java @@ -209,7 +209,7 @@ public class CTSystemColor { * */ public void setLastClr(byte[] value) { - this.lastClr = ((byte[]) value); + this.lastClr = (value != null) ? value.clone() : null; } public boolean isSetLastClr() { diff --git a/src/java/org/apache/poi/ss/format/SimpleFraction.java b/src/java/org/apache/poi/ss/format/SimpleFraction.java index 41d0a2aa83..dec5a275f3 100644 --- a/src/java/org/apache/poi/ss/format/SimpleFraction.java +++ b/src/java/org/apache/poi/ss/format/SimpleFraction.java @@ -32,7 +32,7 @@ public class SimpleFraction { * @return a SimpleFraction with the given values set. */ public static SimpleFraction buildFractionExactDenominator(double val, int exactDenom){ - int num = (int)Math.round(val*(double)exactDenom); + int num = (int)Math.round(val*exactDenom); return new SimpleFraction(num,exactDenom); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java index bd8018fbff..7ce130d54e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java @@ -19,21 +19,27 @@ package org.apache.poi.xssf.streaming; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; -public final class TestOutlining extends TestCase { - public void testSetRowGroupCollapsed() throws Exception { +public final class TestOutlining { + @Test + public void testSetRowGroupCollapsed() throws IOException { SXSSFWorkbook wb2 = new SXSSFWorkbook(100); wb2.setCompressTempFiles(true); - SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet"); + SXSSFSheet sheet2 = wb2.createSheet("new sheet"); int rowCount = 20; for (int i = 0; i < rowCount; i++) { @@ -45,21 +51,22 @@ public final class TestOutlining extends TestCase { sheet2.setRowGroupCollapsed(4, true); - SXSSFRow r = (SXSSFRow) sheet2.getRow(8); + SXSSFRow r = sheet2.getRow(8); assertTrue(r.getHidden()); - r = (SXSSFRow) sheet2.getRow(10); + r = sheet2.getRow(10); assertTrue(r.getCollapsed()); - r = (SXSSFRow) sheet2.getRow(12); + r = sheet2.getRow(12); assertNull(r.getHidden()); wb2.dispose(); wb2.close(); } - public void testSetRowGroupCollapsedError() throws Exception { + @Test + public void testSetRowGroupCollapsedError() throws IOException { SXSSFWorkbook wb2 = new SXSSFWorkbook(100); wb2.setCompressTempFiles(true); - SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet"); + SXSSFSheet sheet2 = wb2.createSheet("new sheet"); int rowCount = 20; for (int i = 0; i < rowCount; i++) { @@ -98,18 +105,19 @@ public final class TestOutlining extends TestCase { e.getMessage().contains("Row does not exist")); } - SXSSFRow r = (SXSSFRow) sheet2.getRow(8); + SXSSFRow r = sheet2.getRow(8); assertNotNull(r); assertNull(r.getHidden()); - r = (SXSSFRow) sheet2.getRow(10); + r = sheet2.getRow(10); assertNull(r.getCollapsed()); - r = (SXSSFRow) sheet2.getRow(12); + r = sheet2.getRow(12); assertNull(r.getHidden()); wb2.dispose(); wb2.close(); } + @Test public void testOutlineGettersHSSF() throws IOException { HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); HSSFSheet hssfSheet = hssfWorkbook.createSheet(); @@ -129,6 +137,7 @@ public final class TestOutlining extends TestCase { hssfWorkbook.close(); } + @Test public void testOutlineGettersXSSF() throws IOException { XSSFWorkbook xssfWorkbook = new XSSFWorkbook(); XSSFSheet xssfSheet = xssfWorkbook.createSheet(); @@ -148,6 +157,7 @@ public final class TestOutlining extends TestCase { xssfWorkbook.close(); } + @Test public void testOutlineGettersSXSSF() throws IOException { SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(); Sheet sxssfSheet = sxssfWorkbook.createSheet(); @@ -190,6 +200,7 @@ public final class TestOutlining extends TestCase { sxssfWorkbook.close(); } + @Test public void testOutlineGettersSXSSFSetOutlineLevel() throws IOException { SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(); Sheet sxssfSheet = sxssfWorkbook.createSheet(); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java index 521e73e0ca..110a7ef565 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java @@ -37,7 +37,6 @@ public final class OldSectionTable extends SectionTable * @deprecated Use {@link #OldSectionTable(byte[],int,int)} instead */ @Deprecated - @SuppressWarnings( "unused" ) public OldSectionTable( byte[] documentStream, int offset, int size, int fcMin, TextPieceTable tpt ) { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java index 57fdaef1b2..cae8089c48 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java @@ -61,7 +61,6 @@ public class PAPBinTable * {@link #PAPBinTable(byte[], byte[], byte[], int, int, CharIndexTranslator)} * instead */ - @SuppressWarnings( "unused" ) public PAPBinTable( byte[] documentStream, byte[] tableStream, byte[] dataStream, int offset, int size, int fcMin, TextPieceTable tpt ) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java b/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java index 01c5d22e5d..11f7d2af4e 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java @@ -214,7 +214,7 @@ public class Sttb if ( _fExtend ) { - LittleEndian.putUShort( buffer, offset, (int) entry.length() ); + LittleEndian.putUShort( buffer, offset, entry.length() ); offset += LittleEndian.SHORT_SIZE; StringUtil.putUnicodeLE( entry, buffer, offset ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FSPAAbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FSPAAbstractType.java index a3a916d0b2..ee71c2bab7 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/types/FSPAAbstractType.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/types/FSPAAbstractType.java @@ -79,7 +79,7 @@ public abstract class FSPAAbstractType LittleEndian.putInt(data, 0x8 + offset, field_3_yaTop); LittleEndian.putInt(data, 0xc + offset, field_4_xaRight); LittleEndian.putInt(data, 0x10 + offset, field_5_yaBottom); - LittleEndian.putShort(data, 0x14 + offset, (short)field_6_flags); + LittleEndian.putShort(data, 0x14 + offset, field_6_flags); LittleEndian.putInt(data, 0x16 + offset, field_7_cTxbx); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java index 44263ace5c..8d737299a8 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java @@ -70,7 +70,7 @@ public final class TestCruddyExtractor extends TestCase { // Ensure they match assertEquals(allTheText.length,foundTextV.size()); for(int i=0; i pics = doc.getPicturesTable().getAllPictures(); @@ -43,7 +47,7 @@ public final class TestPictures extends TestCase { assertNotNull(pics); assertEquals(pics.size(), 2); for(int i=0; i pics = doc.getPicturesTable().getAllPictures(); assertNotNull(pics); assertEquals(7, pics.size()); - for(int i=0; i pics = doc.getPicturesTable().getAllPictures(); @@ -107,32 +112,37 @@ public final class TestPictures extends TestCase { } } - public void testPicturesWithTable() { + @Test + public void testPicturesWithTable() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug44603.doc"); List pics = doc.getPicturesTable().getAllPictures(); assertEquals(2, pics.size()); } - public void testPicturesInHeader() { + @Test + public void testPicturesInHeader() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("header_image.doc"); List pics = doc.getPicturesTable().getAllPictures(); assertEquals(2, pics.size()); } + @Test public void testFastSaved() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("rasp.doc"); doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception } + @Test public void testFastSaved2() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("o_kurs.doc"); doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception } + @Test public void testFastSaved3() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ob_is.doc"); @@ -146,7 +156,8 @@ public final class TestPictures extends TestCase { * then used as-is to speed things up. * Check that we can properly read one of these */ - public void testEmbededDocumentIcon() throws Exception { + @Test + public void testEmbededDocumentIcon() { // This file has two embeded excel files, an embeded powerpoint // file and an embeded word file, in that order HWPFDocument doc = HWPFTestDataSamples.openSampleFile("word_with_embeded.doc"); @@ -231,6 +242,7 @@ public final class TestPictures extends TestCase { assertEquals( "image/x-emf", picture.getMimeType() ); } + @Test public void testEquation() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "equation.doc" ); @@ -256,7 +268,8 @@ public final class TestPictures extends TestCase { * \u0001 which has the offset. More than one can * reference the same \u0001 */ - public void testFloatingPictures() throws Exception { + @Test + public void testFloatingPictures() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("FloatingPictures.doc"); PicturesTable pictures = doc.getPicturesTable(); @@ -290,6 +303,7 @@ public final class TestPictures extends TestCase { } @SuppressWarnings( "deprecation" ) + @Test public void testCroppedPictures() { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("testCroppedPictures.doc"); List pics = doc.getPicturesTable().getAllPictures(); @@ -323,7 +337,8 @@ public final class TestPictures extends TestCase { assertEquals(0, pic2.getDyaCropBottom()); } - public void testPictureDetectionWithPNG() throws Exception { + @Test + public void testPictureDetectionWithPNG() { HWPFDocument document = HWPFTestDataSamples.openSampleFile("PngPicture.doc"); PicturesTable pictureTable = document.getPicturesTable(); @@ -334,7 +349,8 @@ public final class TestPictures extends TestCase { assertEquals("png", p.suggestFileExtension()); } - public void testPictureWithAlternativeText() throws Exception { + @Test + public void testPictureWithAlternativeText() { HWPFDocument document = HWPFTestDataSamples.openSampleFile("Picture_Alternative_Text.doc"); PicturesTable pictureTable = document.getPicturesTable(); Picture picture = pictureTable.getAllPictures().get(0); diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java index 2e55486695..5e32812e8d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java @@ -17,12 +17,12 @@ package org.apache.poi.hwpf.usermodel; -import junit.framework.TestCase; - import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFTestDataSamples; import org.apache.poi.hwpf.model.PAPX; +import junit.framework.TestCase; + /** * Test to see if Range.delete() works even if the Range contains a * CharacterRun that uses Unicode characters. @@ -93,7 +93,7 @@ public final class TestRangeDelete extends TestCase { assertEquals(fillerText, para.text()); - paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(2); + paraDef = daDoc.getParagraphTable().getParagraphs().get(2); assertEquals(132, paraDef.getStart()); assertEquals(400, paraDef.getEnd()); @@ -102,7 +102,7 @@ public final class TestRangeDelete extends TestCase { assertEquals(originalText, para.text()); - paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(3); + paraDef = daDoc.getParagraphTable().getParagraphs().get(3); assertEquals(400, paraDef.getStart()); assertEquals(438, paraDef.getEnd()); diff --git a/src/testcases/org/apache/poi/hpsf/TestVariantSupport.java b/src/testcases/org/apache/poi/hpsf/TestVariantSupport.java index 963f657b96..3b6354e4da 100644 --- a/src/testcases/org/apache/poi/hpsf/TestVariantSupport.java +++ b/src/testcases/org/apache/poi/hpsf/TestVariantSupport.java @@ -62,7 +62,7 @@ public class TestVariantSupport extends TestCase { PropertySet ps = PropertySetFactory.create(new ByteArrayInputStream(bytes)); DocumentSummaryInformation dsi = (DocumentSummaryInformation) ps; - Section s = (Section) dsi.getSections().get(0); + Section s = dsi.getSections().get(0); Object hdrs = s.getProperty(PropertyIDMap.PID_HEADINGPAIR); diff --git a/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java b/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java index 8319657c69..8d69af8ba5 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java @@ -57,7 +57,7 @@ public final class TestAutoFilterInfoRecord extends TestCase { record.setNumEntries((short)3); byte[] src = record.serialize(); - AutoFilterInfoRecord cloned = (AutoFilterInfoRecord)record.clone(); + AutoFilterInfoRecord cloned = record.clone(); assertEquals(3, record.getNumEntries()); byte[] cln = cloned.serialize(); diff --git a/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java index c39e3e4048..3b2591e89c 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java @@ -437,7 +437,7 @@ public final class TestCFRuleRecord extends TestCase { CFRuleRecord record = CFRuleRecord.create(sheet, ComparisonOperator.BETWEEN, "2", "5"); - CFRuleRecord clone = (CFRuleRecord) record.clone(); + CFRuleRecord clone = record.clone(); byte [] serializedRecord = record.serialize(); byte [] serializedClone = clone.serialize(); diff --git a/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java index f158f86422..d8a1de9d03 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestFtCblsSubRecord.java @@ -56,7 +56,7 @@ public final class TestFtCblsSubRecord extends TestCase { FtCblsSubRecord record = new FtCblsSubRecord(); byte[] src = record.serialize(); - FtCblsSubRecord cloned = (FtCblsSubRecord)record.clone(); + FtCblsSubRecord cloned = record.clone(); byte[] cln = cloned.serialize(); assertEquals(record.getDataSize(), cloned.getDataSize()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java index d1e5631b9d..1bb3b1924c 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java @@ -432,7 +432,7 @@ public final class TestHyperlinkRecord { for (int i = 0; i < data.length; i++) { RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data[i]); HyperlinkRecord link = new HyperlinkRecord(is); - HyperlinkRecord clone = (HyperlinkRecord)link.clone(); + HyperlinkRecord clone = link.clone(); assertArrayEquals(link.serialize(), clone.serialize()); } diff --git a/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java b/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java index a203ae4c2b..1063c0c208 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java @@ -42,7 +42,7 @@ public final class TestMergeCellsRecord extends TestCase { public void testCloneReferences() { CellRangeAddress[] cras = { new CellRangeAddress(0, 1, 0, 2), }; MergeCellsRecord merge = new MergeCellsRecord(cras, 0, cras.length); - MergeCellsRecord clone = (MergeCellsRecord)merge.clone(); + MergeCellsRecord clone = merge.clone(); assertNotSame("Merged and cloned objects are the same", merge, clone); diff --git a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java index 427a48f935..4da04e014f 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java @@ -73,7 +73,7 @@ public final class TestNoteRecord extends TestCase { record.setShapeId((short)1026); record.setAuthor("Apache Software Foundation"); - NoteRecord cloned = (NoteRecord)record.clone(); + NoteRecord cloned = record.clone(); assertEquals(record.getRow(), cloned.getRow()); assertEquals(record.getColumn(), cloned.getColumn()); assertEquals(record.getFlags(), cloned.getFlags()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java index db3367a033..1b5fb008e3 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java @@ -58,7 +58,7 @@ public final class TestNoteStructureSubRecord extends TestCase { NoteStructureSubRecord record = new NoteStructureSubRecord(); byte[] src = record.serialize(); - NoteStructureSubRecord cloned = (NoteStructureSubRecord)record.clone(); + NoteStructureSubRecord cloned = record.clone(); byte[] cln = cloned.serialize(); assertEquals(record.getDataSize(), cloned.getDataSize()); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java index 21494b39ba..8153b53ea1 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java @@ -159,10 +159,7 @@ public final class TestDocument extends TestCase { } else { - copy = new OPOIFSDocument( - "test" + input.length, - ( SmallDocumentBlock [] ) document.getSmallBlocks(), - input.length); + copy = new OPOIFSDocument("test"+input.length, document.getSmallBlocks(), input.length); } return copy; } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java b/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java index eb1b570300..18268068f5 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java @@ -20,8 +20,6 @@ */ package org.apache.poi.ss.formula.functions; -import java.lang.reflect.Constructor; - import org.apache.poi.ss.formula.functions.XYNumericFunction.Accumulator; @@ -305,10 +303,10 @@ public class TestMathX extends AbstractNumericTestCase { assertEquals(0.0, MathX.mod(0, 2)); assertEquals(Double.NaN, MathX.mod(3, 0)); - assertEquals((double) 1.4, MathX.mod(3.4, 2)); - assertEquals((double) -1.4, MathX.mod(-3.4, -2)); - assertEquals((double) 0.6000000000000001, MathX.mod(-3.4, 2.0));// should actually be 0.6 - assertEquals((double) -0.6000000000000001, MathX.mod(3.4, -2.0));// should actually be -0.6 + assertEquals(1.4, MathX.mod(3.4, 2)); + assertEquals(-1.4, MathX.mod(-3.4, -2)); + assertEquals(0.6000000000000001, MathX.mod(-3.4, 2.0));// should actually be 0.6 + assertEquals(-0.6000000000000001, MathX.mod(3.4, -2.0));// should actually be -0.6 assertEquals(3.0, MathX.mod(3, Double.MAX_VALUE)); assertEquals(2.0, MathX.mod(Double.MAX_VALUE, 3)); -- 2.39.5