diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2017-01-15 23:08:47 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2017-01-15 23:08:47 +0000 |
commit | 3cf6c40004a3beb5d8855478fb202429c25a1555 (patch) | |
tree | 0119eff3108bb6799526a55c04568a99abee930b /src/testcases/org/apache | |
parent | d2d885990fea477e9efdae8858989350904e1c44 (diff) | |
download | poi-3cf6c40004a3beb5d8855478fb202429c25a1555.tar.gz poi-3cf6c40004a3beb5d8855478fb202429c25a1555.zip |
fix eclipse warnings - close resources / type generics
cleanup sources - add parenthesis to statements
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1778955 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
13 files changed, 147 insertions, 132 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java index c46867d2ed..659f769023 100644 --- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java +++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java @@ -52,7 +52,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel3() throws Exception { + public void testSimpleExcel3() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls"); // Check we can call getText without error @@ -78,7 +78,7 @@ public final class TestOldExcelExtractor { @Test - public void testSimpleExcel3NoReading() throws Exception { + public void testSimpleExcel3NoReading() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls"); assertNotNull(extractor); @@ -86,7 +86,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel4() throws Exception { + public void testSimpleExcel4() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); // Check we can call getText without error @@ -108,7 +108,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel5() throws Exception { + public void testSimpleExcel5() throws IOException { for (String ver : new String[] {"5", "95"}) { OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls"); @@ -135,7 +135,7 @@ public final class TestOldExcelExtractor { } @Test - public void testStrings() throws Exception { + public void testStrings() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); String text = extractor.getText(); @@ -156,7 +156,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFormattedNumbersExcel4() throws Exception { + public void testFormattedNumbersExcel4() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); String text = extractor.getText(); @@ -177,7 +177,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFormattedNumbersExcel5() throws Exception { + public void testFormattedNumbersExcel5() throws IOException { for (String ver : new String[] {"5", "95"}) { OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls"); String text = extractor.getText(); @@ -204,7 +204,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFromFile() throws Exception { + public void testFromFile() throws IOException { for (String ver : new String[] {"4", "5", "95"}) { String filename = "testEXCEL_"+ver+".xls"; File f = HSSFTestDataSamples.getSampleFile(filename); @@ -218,47 +218,39 @@ public final class TestOldExcelExtractor { } } - @Test - public void testOpenInvalidFile() throws Exception { + @Test(expected=OfficeXmlFileException.class) + public void testOpenInvalidFile1() throws IOException { // a file that exists, but is a different format - try { - createExtractor("WithVariousData.xlsx"); - fail("Should catch Exception here"); - } catch (OfficeXmlFileException e) { - // expected here - } - + createExtractor("WithVariousData.xlsx"); + } + + + @Test(expected=RecordFormatException.class) + public void testOpenInvalidFile2() throws IOException { // a completely different type of file - try { - createExtractor("48936-strings.txt"); - fail("Should catch Exception here"); - } catch (RecordFormatException e) { - // expected here - } + createExtractor("48936-strings.txt"); + } + @Test(expected=FileNotFoundException.class) + public void testOpenInvalidFile3() throws IOException { // a POIFS file which is not a Workbook + InputStream is = POIDataSamples.getDocumentInstance().openResourceAsStream("47304.doc"); try { - new OldExcelExtractor(POIDataSamples.getDocumentInstance().getFile("47304.doc")); - fail("Should catch Exception here"); - } catch (FileNotFoundException e) { - // expected here + new OldExcelExtractor(is).close(); + } finally { + is.close(); } } - @Test - public void testOpenNonExistingFile() throws Exception { + @Test(expected=EmptyFileException.class) + public void testOpenNonExistingFile() throws IOException { // a file that exists, but is a different format - try { - OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls")); - extractor.close(); - fail("Should catch Exception here"); - } catch (EmptyFileException e) { - // expected here - } + OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls")); + extractor.close(); } @Test - public void testInputStream() throws Exception { + public void testInputStream() throws IOException { File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls"); InputStream stream = new FileInputStream(file); try { @@ -272,7 +264,7 @@ public final class TestOldExcelExtractor { } @Test - public void testInputStreamNPOIHeader() throws Exception { + public void testInputStreamNPOIHeader() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); InputStream stream = new FileInputStream(file); try { @@ -284,7 +276,7 @@ public final class TestOldExcelExtractor { } @Test - public void testNPOIFSFileSystem() throws Exception { + public void testNPOIFSFileSystem() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -296,7 +288,7 @@ public final class TestOldExcelExtractor { } @Test - public void testDirectoryNode() throws Exception { + public void testDirectoryNode() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -308,7 +300,7 @@ public final class TestOldExcelExtractor { } @Test - public void testDirectoryNodeInvalidFile() throws Exception { + public void testDirectoryNodeInvalidFile() throws IOException { File file = POIDataSamples.getDocumentInstance().getFile("test.doc"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -324,7 +316,7 @@ public final class TestOldExcelExtractor { @Ignore("Calls System.exit()") @Test - public void testMainUsage() throws Exception { + public void testMainUsage() throws IOException { PrintStream save = System.err; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -341,7 +333,7 @@ public final class TestOldExcelExtractor { } @Test - public void testMain() throws Exception { + public void testMain() throws IOException { File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls"); PrintStream save = System.out; try { @@ -362,7 +354,7 @@ public final class TestOldExcelExtractor { } @Test - public void testEncryptionException() throws Exception { + public void testEncryptionException() throws IOException { //test file derives from Common Crawl File file = HSSFTestDataSamples.getSampleFile("60284.xls"); OldExcelExtractor ex = new OldExcelExtractor(file); diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java index 70e7c7db63..2f929a06ff 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java @@ -16,6 +16,7 @@ ==================================================================== */
package org.apache.poi.hssf.model;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -32,9 +33,6 @@ import java.util.Arrays; import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-import javax.xml.bind.DatatypeConverter;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -59,7 +57,6 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFTestHelper;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.HexDump;
-import org.apache.poi.util.IOUtils;
import org.junit.Test;
public class TestDrawingAggregate {
@@ -946,32 +943,4 @@ public class TestDrawingAggregate { assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));
}
-
-
- /**
- * Decompress previously gziped/base64ed data
- *
- * @param data the gziped/base64ed data
- * @return the raw bytes
- * @throws IOException if you copy and pasted the data wrong
- */
- public static byte[] decompress(String data) throws IOException {
- byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
- return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
- }
-
- /**
- * Compress raw data for test runs - usually called while debugging :)
- *
- * @param data the raw data
- * @return the gziped/base64ed data as String
- * @throws IOException usually not ...
- */
- public static String compress(byte[] data) throws IOException {
- java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
- java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);
- gz.write(data);
- gz.finish();
- return DatatypeConverter.printBase64Binary(bos.toByteArray());
- }
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java b/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java index ec7b84c693..c73493cb32 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java @@ -18,22 +18,22 @@ package org.apache.poi.hssf.record; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; + import org.apache.poi.util.HexRead; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianByteArrayInputStream; -import org.apache.poi.util.LittleEndianInput; - -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; +import org.junit.Test; /** * Tests the serialization and deserialization of the StringRecord * class works correctly. Test data taken directly from a real * Excel file. - * - * @author Glen Stampoultzis (glens at apache.org) */ -public final class TestStringRecord extends TestCase { +public final class TestStringRecord { private static final byte[] data = HexRead.readFromString( "0B 00 " + // length "00 " + // option @@ -41,6 +41,7 @@ public final class TestStringRecord extends TestCase { "46 61 68 72 7A 65 75 67 74 79 70" ); + @Test public void testLoad() { StringRecord record = new StringRecord(TestcaseRecordInputStream.create(0x207, data)); @@ -49,17 +50,20 @@ public final class TestStringRecord extends TestCase { assertEquals( 18, record.getRecordSize() ); } - public void testStore() { + @Test + public void testStore() { StringRecord record = new StringRecord(); record.setString("Fahrzeugtyp"); byte [] recordBytes = record.serialize(); assertEquals(recordBytes.length - 4, data.length); - for (int i = 0; i < data.length; i++) - assertEquals("At offset " + i, data[i], recordBytes[i+4]); + for (int i = 0; i < data.length; i++) { + assertEquals("At offset " + i, data[i], recordBytes[i+4]); + } } - public void testContinue() { + @Test + public void testContinue() throws IOException { int MAX_BIFF_DATA = RecordInputStream.MAX_RECORD_DATA_SIZE; int TEXT_LEN = MAX_BIFF_DATA + 1000; // deliberately over-size String textChunk = "ABCDEGGHIJKLMNOP"; // 16 chars @@ -74,15 +78,14 @@ public final class TestStringRecord extends TestCase { byte[] ser = sr.serialize(); assertEquals(StringRecord.sid, LittleEndian.getUShort(ser, 0)); if (LittleEndian.getUShort(ser, 2) > MAX_BIFF_DATA) { - throw new AssertionFailedError( - "StringRecord should have been split with a continue record"); + fail("StringRecord should have been split with a continue record"); } // Confirm expected size of first record, and ushort strLen. assertEquals(MAX_BIFF_DATA, LittleEndian.getUShort(ser, 2)); assertEquals(TEXT_LEN, LittleEndian.getUShort(ser, 4)); // Confirm first few bytes of ContinueRecord - LittleEndianInput crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4)); + LittleEndianByteArrayInputStream crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4)); int nCharsInFirstRec = MAX_BIFF_DATA - (2 + 1); // strLen, optionFlags int nCharsInSecondRec = TEXT_LEN - nCharsInFirstRec; assertEquals(ContinueRecord.sid, crIn.readUShort()); @@ -95,5 +98,6 @@ public final class TestStringRecord extends TestCase { RecordInputStream in = TestcaseRecordInputStream.create(ser); StringRecord sr2 = new StringRecord(in); assertEquals(sb.toString(), sr2.getString()); + crIn.close(); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java index 9e40695b4b..f8162fcf28 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.hssf.usermodel; -import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress; +import static org.apache.poi.poifs.storage.RawDataUtil.decompress; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -41,6 +41,7 @@ import org.apache.poi.ss.usermodel.Drawing; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; /** @@ -102,7 +103,7 @@ public final class TestHSSFComment extends BaseTestCellComment { public void testBug56380InsertComments() throws Exception { HSSFWorkbook workbook = new HSSFWorkbook(); Sheet sheet = workbook.createSheet(); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); int noOfRows = 1025; String comment = "c"; @@ -139,7 +140,7 @@ public final class TestHSSFComment extends BaseTestCellComment { HSSFWorkbook workbook = new HSSFWorkbook(); try { Sheet sheet = workbook.createSheet(); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); String comment = "c"; for(int rowNum = 0;rowNum < 258;rowNum++) { @@ -179,7 +180,7 @@ public final class TestHSSFComment extends BaseTestCellComment { } } - private Comment insertComment(Drawing drawing, Cell cell, String message) { + private Comment insertComment(Drawing<?> drawing, Cell cell, String message) { CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper(); ClientAnchor anchor = factory.createClientAnchor(); @@ -272,7 +273,7 @@ public final class TestHSSFComment extends BaseTestCellComment { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sh = wb.createSheet(); HSSFPatriarch patriarch = sh.createDrawingPatriarch(); - int idx = wb.addPicture(new byte[]{1,2,3}, HSSFWorkbook.PICTURE_TYPE_PNG); + int idx = wb.addPicture(new byte[]{1,2,3}, Workbook.PICTURE_TYPE_PNG); HSSFComment comment = patriarch.createCellComment(new HSSFClientAnchor()); comment.setColumn(5); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java b/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java index 6174a5ff30..1b9ad1ffa6 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.usermodel;
-import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestText.java b/src/testcases/org/apache/poi/hssf/usermodel/TestText.java index c8203d8d49..cb8f1d4bd5 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestText.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestText.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.usermodel;
-import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
diff --git a/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java b/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java index 487c8eb804..f3ae3b0877 100644 --- a/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java +++ b/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java @@ -16,11 +16,17 @@ ==================================================================== */ package org.apache.poi.poifs.storage; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.Arrays; +import java.util.zip.GZIPInputStream; + +import javax.xml.bind.DatatypeConverter; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; +import org.apache.poi.util.IOUtils; /** * Test utility class.<br/> @@ -81,4 +87,31 @@ public final class RawDataUtil { throw new RuntimeException("different"); } } + + /** + * Decompress previously gziped/base64ed data + * + * @param data the gziped/base64ed data + * @return the raw bytes + * @throws IOException if you copy and pasted the data wrong + */ + public static byte[] decompress(String data) throws IOException { + byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data); + return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes))); + } + + /** + * Compress raw data for test runs - usually called while debugging :) + * + * @param data the raw data + * @return the gziped/base64ed data as String + * @throws IOException usually not ... + */ + public static String compress(byte[] data) throws IOException { + java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); + java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos); + gz.write(data); + gz.finish(); + return DatatypeConverter.printBase64Binary(bos.toByteArray()); + } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index a1f296355f..52f8b72b21 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -17,6 +17,23 @@ package org.apache.poi.ss.usermodel; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +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 java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.text.AttributedString; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; @@ -30,18 +47,6 @@ import org.junit.Assume; import org.junit.Ignore; import org.junit.Test; -import java.awt.font.FontRenderContext; -import java.awt.font.TextAttribute; -import java.awt.font.TextLayout; -import java.awt.geom.Rectangle2D; -import java.io.IOException; -import java.text.AttributedString; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.*; - /** * A base class for bugzilla issues that can be described in terms of common ss interfaces. * @@ -70,8 +75,9 @@ public abstract class BaseTestBugzillaIssues { public static void assertAlmostEquals(double expected, double actual, float factor) { double diff = Math.abs(expected - actual); double fuzz = expected * factor; - if (diff > fuzz) + if (diff > fuzz) { fail(actual + " not within " + fuzz + " of " + expected); + } } /** @@ -359,7 +365,9 @@ public abstract class BaseTestBugzillaIssues { fmla.append(name); fmla.append("("); for(int i=0; i < maxArgs; i++){ - if(i > 0) fmla.append(','); + if(i > 0) { + fmla.append(','); + } fmla.append("A1"); } fmla.append(")"); @@ -512,9 +520,15 @@ public abstract class BaseTestBugzillaIssues { private static void copyAttributes(Font font, AttributedString str, int endIdx) { str.addAttribute(TextAttribute.FAMILY, font.getFontName(), 0, endIdx); str.addAttribute(TextAttribute.SIZE, (float)font.getFontHeightInPoints()); - if (font.getBold()) str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 0, endIdx); - if (font.getItalic() ) str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, 0, endIdx); - if (font.getUnderline() == Font.U_SINGLE ) str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 0, endIdx); + if (font.getBold()) { + str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 0, endIdx); + } + if (font.getItalic() ) { + str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, 0, endIdx); + } + if (font.getUnderline() == Font.U_SINGLE ) { + str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 0, endIdx); + } } /** @@ -1063,7 +1077,7 @@ public abstract class BaseTestBugzillaIssues { CreationHelper factory = wb.getCreationHelper(); Sheet sheet = wb.createSheet(); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); Cell cell0 = sheet.createRow(0).createCell(0); @@ -1513,7 +1527,7 @@ public abstract class BaseTestBugzillaIssues { CreationHelper helper = wb.getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); Row row = sheet.createRow(0); @@ -1677,7 +1691,7 @@ public abstract class BaseTestBugzillaIssues { assertEquals(10, row.getRowNum()); for (Cell cell : row) { - String cellValue = null; + String cellValue; switch (cell.getCellTypeEnum()) { case STRING: cellValue = cell.getRichStringCellValue().getString(); @@ -1685,6 +1699,9 @@ public abstract class BaseTestBugzillaIssues { case FORMULA: cellValue = cell.getCellFormula(); break; + default: + fail("unexpected cell type"); + return; } assertNotNull(cellValue); cellValue = cellValue.isEmpty() ? null : cellValue; diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index be097d3482..0bec60deda 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -253,7 +253,7 @@ public abstract class BaseTestCell { Font f = wb1.createFont(); f.setFontHeightInPoints((short) 20); f.setColor(IndexedColors.RED.getIndex()); - f.setBoldweight(Font.BOLDWEIGHT_BOLD); + f.setBold(true); f.setFontName("Arial Unicode MS"); cs.setFillBackgroundColor((short)3); cs.setFont(f); @@ -718,7 +718,7 @@ public abstract class BaseTestCell { assertFalse(style.getHidden()); assertEquals(0, style.getIndention()); assertEquals(0, style.getFontIndex()); - assertEquals(0, style.getAlignment()); + assertEquals(HorizontalAlignment.GENERAL, style.getAlignmentEnum()); assertEquals(0, style.getDataFormat()); assertEquals(false, style.getWrapText()); @@ -1004,7 +1004,7 @@ public abstract class BaseTestCell { anchor.setRow1(row.getRowNum()); anchor.setRow2(row.getRowNum()+3); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); Comment comment = drawing.createCellComment(anchor); RichTextString str = factory.createRichTextString("Hello, World!"); comment.setString(str); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java index 17de8cf4a9..535094ff05 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java @@ -77,7 +77,7 @@ public abstract class BaseTestCellComment { assertNull(cell.getCellComment()); assertNull(sheet.getCellComment(new CellAddress(cellRow, cellColumn))); - Drawing patr = sheet.createDrawingPatriarch(); + Drawing<?> patr = sheet.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); anchor.setCol1(2); anchor.setCol2(5); @@ -261,7 +261,7 @@ public abstract class BaseTestCellComment { Cell cell = sheet.createRow(3).createCell(5); cell.setCellValue("F4"); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = factory.createClientAnchor(); Comment comment = drawing.createCellComment(anchor); @@ -294,7 +294,7 @@ public abstract class BaseTestCellComment { Cell cell = row.createCell(5); CreationHelper factory = wb.getCreationHelper(); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); double r_mul, c_mul; if (sheet instanceof HSSFSheet) { @@ -365,7 +365,7 @@ public abstract class BaseTestCellComment { Workbook wb = _testDataProvider.createWorkbook(); Sheet sh = wb.createSheet(); CreationHelper factory = wb.getCreationHelper(); - Drawing patriarch = sh.createDrawingPatriarch(); + Drawing<?> patriarch = sh.createDrawingPatriarch(); patriarch.createCellComment(factory.createClientAnchor()); try { @@ -388,7 +388,7 @@ public abstract class BaseTestCellComment { Workbook wb = _testDataProvider.createWorkbook(); Sheet sh = wb.createSheet(); CreationHelper factory = wb.getCreationHelper(); - Drawing patriarch = sh.createDrawingPatriarch(); + Drawing<?> patriarch = sh.createDrawingPatriarch(); Comment comment = patriarch.createCellComment(factory.createClientAnchor()); assertEquals(CellAddress.A1, comment.getAddress()); @@ -402,7 +402,7 @@ public abstract class BaseTestCellComment { Workbook wb = _testDataProvider.createWorkbook(); Sheet sh = wb.createSheet(); CreationHelper factory = wb.getCreationHelper(); - Drawing patriarch = sh.createDrawingPatriarch(); + Drawing<?> patriarch = sh.createDrawingPatriarch(); Comment comment = patriarch.createCellComment(factory.createClientAnchor()); assertEquals(CellAddress.A1, comment.getAddress()); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java index e573e79aef..d7c68940ce 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java @@ -105,7 +105,7 @@ public abstract class BaseTestPicture { private void handleResize(Workbook wb, Sheet sheet, Row row) throws IOException { - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); CreationHelper createHelper = wb.getCreationHelper(); final byte[] bytes = HSSFITestDataProvider.instance.getTestDataFileContent("logoKarmokar4.png"); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 65db968861..4e7179109b 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -1141,7 +1141,7 @@ public abstract class BaseTestSheet { public void getCellComment() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); - Drawing dg = sheet.createDrawingPatriarch(); + Drawing<?> dg = sheet.createDrawingPatriarch(); Comment comment = dg.createCellComment(workbook.getCreationHelper().createClientAnchor()); Cell cell = sheet.createRow(9).createCell(2); comment.setAuthor("test C10 author"); @@ -1165,7 +1165,7 @@ public abstract class BaseTestSheet { // a sheet with no cell comments should return an empty map (not null or raise NPE). assertEquals(Collections.emptyMap(), sheet.getCellComments()); - Drawing dg = sheet.createDrawingPatriarch(); + Drawing<?> dg = sheet.createDrawingPatriarch(); ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor(); int nRows = 5; diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java index e6e7f676e1..9222f60430 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java @@ -33,7 +33,6 @@ import java.io.OutputStream; import java.util.ConcurrentModificationException; import java.util.Iterator; -import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; @@ -908,7 +907,7 @@ public abstract class BaseTestWorkbook { Sheet sheet = wb.createSheet("Main Sheet"); Row row0 = sheet.createRow(0); Row row1 = sheet.createRow(1); - Cell cell = row1.createCell(0); + row1.createCell(0); row0.createCell(1); row1.createCell(0); row1.createCell(1); @@ -916,7 +915,7 @@ public abstract class BaseTestWorkbook { byte[] pictureData = _testDataProvider.getTestDataFileContent("logoKarmokar4.png"); int handle = wb.addPicture(pictureData, Workbook.PICTURE_TYPE_PNG); - Drawing drawing = sheet.createDrawingPatriarch(); + Drawing<?> drawing = sheet.createDrawingPatriarch(); CreationHelper helper = wb.getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE); |