diff options
author | Josh Micich <josh@apache.org> | 2009-08-18 19:49:28 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-08-18 19:49:28 +0000 |
commit | 27b61f396a324f7e7882a7e9bbf80c60cef573a0 (patch) | |
tree | cb4869ab9298a8676d18d5385d8e84aa5e850a66 /src/testcases | |
parent | a2cd9a942e1cc575254690ea4b7e9053cade05b3 (diff) | |
download | poi-27b61f396a324f7e7882a7e9bbf80c60cef573a0.tar.gz poi-27b61f396a324f7e7882a7e9bbf80c60cef573a0.zip |
Fixed compiler warnings - unnecessary throws declaration
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805552 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
31 files changed, 400 insertions, 488 deletions
diff --git a/src/testcases/org/apache/poi/TestPOIDocumentMain.java b/src/testcases/org/apache/poi/TestPOIDocumentMain.java index 2e877acf12..47f2c0be97 100644 --- a/src/testcases/org/apache/poi/TestPOIDocumentMain.java +++ b/src/testcases/org/apache/poi/TestPOIDocumentMain.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -30,7 +29,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** * Tests that POIDocument correctly loads and saves the common * (hspf) Document Properties. - * + * * This is part 1 of 2 of the tests - it only does the POIDocuments * which are part of the Main (not scratchpad) * @@ -45,26 +44,26 @@ public final class TestPOIDocumentMain extends TestCase { * Set things up, two spreadsheets for our testing */ public void setUp() { - + doc = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls"); doc2 = HSSFTestDataSamples.openSampleWorkbook("StringFormulas.xls"); } - - public void testReadProperties() throws Exception { + + public void testReadProperties() { // We should have both sets assertNotNull(doc.getDocumentSummaryInformation()); assertNotNull(doc.getSummaryInformation()); - + // Check they are as expected for the test doc assertEquals("Administrator", doc.getSummaryInformation().getAuthor()); assertEquals(0, doc.getDocumentSummaryInformation().getByteCount()); } - - public void testReadProperties2() throws Exception { + + public void testReadProperties2() { // Check again on the word one assertNotNull(doc2.getDocumentSummaryInformation()); assertNotNull(doc2.getSummaryInformation()); - + assertEquals("Avik Sengupta", doc2.getSummaryInformation().getAuthor()); assertEquals(null, doc2.getSummaryInformation().getKeywords()); assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount()); @@ -75,7 +74,7 @@ public final class TestPOIDocumentMain extends TestCase { POIFSFileSystem outFS = new POIFSFileSystem(); doc.readProperties(); doc.writeProperties(outFS); - + // Should now hold them assertNotNull( outFS.createDocumentInputStream("\005SummaryInformation") @@ -87,21 +86,21 @@ public final class TestPOIDocumentMain extends TestCase { public void testWriteReadProperties() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - + // Write them out POIFSFileSystem outFS = new POIFSFileSystem(); doc.readProperties(); doc.writeProperties(outFS); outFS.writeFilesystem(baos); - + // Create a new version ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); POIFSFileSystem inFS = new POIFSFileSystem(bais); - + // Check they're still there doc.filesystem = inFS; doc.readProperties(); - + // Delegate test testReadProperties(); } diff --git a/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java index 8db7c4be38..3b947e693d 100644 --- a/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java +++ b/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java @@ -21,13 +21,11 @@ import junit.framework.TestCase; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; -public class TestEscherBlipWMFRecord extends TestCase -{ +public final class TestEscherBlipWMFRecord extends TestCase { private String dataStr; private byte[] data; - protected void setUp() throws Exception - { + protected void setUp() { dataStr = "2C 15 18 F0 34 00 00 00 01 01 01 01 01 01 01 01 " + "01 01 01 01 01 01 01 01 06 00 00 00 03 00 00 00 " + "01 00 00 00 04 00 00 00 02 00 00 00 0A 00 00 00 " + diff --git a/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java b/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java index 83161d5b45..f1713533aa 100644 --- a/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java +++ b/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,17 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; -public class TestEscherBoolProperty extends TestCase -{ - public void testToString() throws Exception - { +public final class TestEscherBoolProperty extends TestCase { + public void testToString() { EscherBoolProperty p = new EscherBoolProperty((short)1, 1); assertEquals("propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)", p.toString()); } - } diff --git a/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java index 9cf14e47b4..757972de9f 100644 --- a/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java +++ b/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java @@ -21,8 +21,7 @@ import junit.framework.TestCase; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; -public class TestEscherChildAnchorRecord extends TestCase -{ +public final class TestEscherChildAnchorRecord extends TestCase { public void testSerialize() { EscherChildAnchorRecord r = createRecord(); @@ -38,8 +37,7 @@ public class TestEscherChildAnchorRecord extends TestCase "04, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "01 00 " + "0F F0 " + "10 00 00 00 " + @@ -73,8 +71,7 @@ public class TestEscherChildAnchorRecord extends TestCase assertEquals( expected, createRecord().toString() ); } - private static EscherChildAnchorRecord createRecord() - { + private static EscherChildAnchorRecord createRecord() { EscherChildAnchorRecord r = new EscherChildAnchorRecord(); r.setRecordId( EscherChildAnchorRecord.RECORD_ID ); r.setOptions( (short) 0x0001 ); diff --git a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java index 3a189353d0..e05cbc6bad 100644 --- a/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java +++ b/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java @@ -14,41 +14,42 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ + package org.apache.poi.hpsf.extractor; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; + +import junit.framework.TestCase; import org.apache.poi.hssf.extractor.ExcelExtractor; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import junit.framework.TestCase; - -public class TestHPSFPropertiesExtractor extends TestCase { +public final class TestHPSFPropertiesExtractor extends TestCase { private String dir; - - protected void setUp() throws Exception { - dir = System.getProperty("HPSF.testdata.path"); - assertNotNull("HPSF.testdata.path not set", dir); + + protected void setUp() { + dir = System.getProperty("HPSF.testdata.path"); + assertNotNull("HPSF.testdata.path not set", dir); } - + public void testNormalProperties() throws Exception { - POIFSFileSystem fs = new POIFSFileSystem( - new FileInputStream(new File(dir, "TestMickey.doc")) - ); + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( + new File(dir, "TestMickey.doc"))); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); ext.getText(); - + // Check each bit in turn String sinfText = ext.getSummaryInformationText(); String dinfText = ext.getDocumentSummaryInformationText(); - + assertTrue(sinfText.indexOf("TEMPLATE = Normal") > -1); assertTrue(sinfText.indexOf("SUBJECT = sample subject") > -1); assertTrue(dinfText.indexOf("MANAGER = sample manager") > -1); assertTrue(dinfText.indexOf("COMPANY = sample company") > -1); - + // Now overall String text = ext.getText(); assertTrue(text.indexOf("TEMPLATE = Normal") > -1); @@ -56,22 +57,22 @@ public class TestHPSFPropertiesExtractor extends TestCase { assertTrue(text.indexOf("MANAGER = sample manager") > -1); assertTrue(text.indexOf("COMPANY = sample company") > -1); } + public void testNormalUnicodeProperties() throws Exception { - POIFSFileSystem fs = new POIFSFileSystem( - new FileInputStream(new File(dir, "TestUnicode.xls")) - ); + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(new File(dir, + "TestUnicode.xls"))); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); ext.getText(); - + // Check each bit in turn String sinfText = ext.getSummaryInformationText(); String dinfText = ext.getDocumentSummaryInformationText(); - + assertTrue(sinfText.indexOf("AUTHOR = marshall") > -1); assertTrue(sinfText.indexOf("TITLE = Titel: \u00c4h") > -1); assertTrue(dinfText.indexOf("COMPANY = Schreiner") > -1); assertTrue(dinfText.indexOf("SCALE = false") > -1); - + // Now overall String text = ext.getText(); assertTrue(text.indexOf("AUTHOR = marshall") > -1); @@ -79,37 +80,41 @@ public class TestHPSFPropertiesExtractor extends TestCase { assertTrue(text.indexOf("COMPANY = Schreiner") > -1); assertTrue(text.indexOf("SCALE = false") > -1); } + public void testCustomProperties() throws Exception { - POIFSFileSystem fs = new POIFSFileSystem( - new FileInputStream(new File(dir, "TestMickey.doc")) - ); + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( + new File(dir, "TestMickey.doc"))); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); // Custom properties are part of the document info stream String dinfText = ext.getDocumentSummaryInformationText(); assertTrue(dinfText.indexOf("Client = sample client") > -1); assertTrue(dinfText.indexOf("Division = sample division") > -1); - + String text = ext.getText(); assertTrue(text.indexOf("Client = sample client") > -1); assertTrue(text.indexOf("Division = sample division") > -1); } - - public void testConstructors() throws Exception { - POIFSFileSystem fs = new POIFSFileSystem( - new FileInputStream(new File(dir, "TestUnicode.xls")) - ); - HSSFWorkbook wb = new HSSFWorkbook(fs); + + public void testConstructors() { + POIFSFileSystem fs; + HSSFWorkbook wb; + try { + fs = new POIFSFileSystem(new FileInputStream(new File(dir, "TestUnicode.xls"))); + wb = new HSSFWorkbook(fs); + } catch (IOException e) { + throw new RuntimeException(e); + } ExcelExtractor excelExt = new ExcelExtractor(wb); - + String fsText = (new HPSFPropertiesExtractor(fs)).getText(); String hwText = (new HPSFPropertiesExtractor(wb)).getText(); String eeText = (new HPSFPropertiesExtractor(excelExt)).getText(); - + assertEquals(fsText, hwText); assertEquals(fsText, eeText); - + assertTrue(fsText.indexOf("AUTHOR = marshall") > -1); assertTrue(fsText.indexOf("TITLE = Titel: \u00c4h") > -1); - } + } } diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingManager.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager.java index 8557f2b4a1..138b80af8e 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingManager.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager.java @@ -14,16 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ + package org.apache.poi.hssf.model; import junit.framework.TestCase; import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherDgRecord; -public class TestDrawingManager extends TestCase -{ - public void testFindFreeSPIDBlock() throws Exception - { +public final class TestDrawingManager extends TestCase { + public void testFindFreeSPIDBlock() { EscherDggRecord dgg = new EscherDggRecord(); DrawingManager dm = new DrawingManager( dgg ); dgg.setShapeIdMax( 1024 ); @@ -34,8 +33,7 @@ public class TestDrawingManager extends TestCase assertEquals( 2048, dm.findFreeSPIDBlock() ); } - public void testFindNewDrawingGroupId() throws Exception - { + public void testFindNewDrawingGroupId() { EscherDggRecord dgg = new EscherDggRecord(); dgg.setDrawingsSaved( 1 ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{ @@ -48,8 +46,7 @@ public class TestDrawingManager extends TestCase assertEquals( 3, dm.findNewDrawingGroupId() ); } - public void testDrawingGroupExists() throws Exception - { + public void testDrawingGroupExists() { EscherDggRecord dgg = new EscherDggRecord(); dgg.setDrawingsSaved( 1 ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{ @@ -60,8 +57,7 @@ public class TestDrawingManager extends TestCase assertFalse( dm.drawingGroupExists( (short) 3 ) ); } - public void testCreateDgRecord() throws Exception - { + public void testCreateDgRecord() { EscherDggRecord dgg = new EscherDggRecord(); dgg.setDrawingsSaved( 0 ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} ); @@ -76,8 +72,7 @@ public class TestDrawingManager extends TestCase assertEquals( 0, dm.getDgg().getFileIdClusters()[0].getNumShapeIdsUsed() ); } - public void testAllocateShapeId() throws Exception - { + public void testAllocateShapeId() { EscherDggRecord dgg = new EscherDggRecord(); dgg.setDrawingsSaved( 0 ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} ); @@ -93,5 +88,4 @@ public class TestDrawingManager extends TestCase assertEquals( 1024, dg.getLastMSOSPID() ); assertEquals( 1, dg.getNumShapes() ); } - } diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java index f416ec941c..75a5980cf6 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java @@ -1,40 +1,37 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + package org.apache.poi.hssf.model; import junit.framework.TestCase; import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherDgRecord; -public class TestDrawingManager2 extends TestCase -{ +public final class TestDrawingManager2 extends TestCase { private DrawingManager2 drawingManager2; private EscherDggRecord dgg; - protected void setUp() throws Exception - { - super.setUp(); + protected void setUp() { dgg = new EscherDggRecord(); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[0] ); drawingManager2 = new DrawingManager2( dgg ); } - public void testCreateDgRecord() throws Exception - { + public void testCreateDgRecord() { EscherDgRecord dgRecord1 = drawingManager2.createDgRecord(); assertEquals( 1, dgRecord1.getDrawingGroupId() ); assertEquals( -1, dgRecord1.getLastMSOSPID() ); @@ -49,8 +46,7 @@ public class TestDrawingManager2 extends TestCase assertEquals( 0, dgg.getNumShapesSaved() ); } - public void testAllocateShapeId() throws Exception - { + public void testAllocateShapeId() { EscherDgRecord dgRecord1 = drawingManager2.createDgRecord(); EscherDgRecord dgRecord2 = drawingManager2.createDgRecord(); @@ -79,4 +75,4 @@ public class TestDrawingManager2 extends TestCase assertEquals( 4, dgg.getNumIdClusters() ); assertEquals( 1026, dgg.getNumShapesSaved() ); } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java index 415cca33f1..ae4245ec4b 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java @@ -41,11 +41,11 @@ public final class TestFormulaParserIf extends TestCase { private static Ptg[] parseFormula(String formula) { return TestFormulaParser.parseFormula(formula); } - - private static Ptg[] confirmTokenClasses(String formula, Class[] expectedClasses) { + + private static Ptg[] confirmTokenClasses(String formula, Class<?>[] expectedClasses) { return TestFormulaParser.confirmTokenClasses(formula, expectedClasses); } - + private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) { Ptg ptg = ptgs[i]; if (!(ptg instanceof AttrPtg)) { @@ -54,10 +54,10 @@ public final class TestFormulaParserIf extends TestCase { AttrPtg attrPtg = (AttrPtg) ptg; assertEquals(expectedData, attrPtg.getData()); } - + public void testSimpleIf() { - - Class[] expClss; + + Class<?>[] expClss; expClss = new Class[] { RefPtg.class, @@ -77,8 +77,8 @@ public final class TestFormulaParserIf extends TestCase { } public void testSimpleIfNoFalseParam() { - - Class[] expClss; + + Class<?>[] expClss; expClss = new Class[] { RefPtg.class, @@ -95,8 +95,8 @@ public final class TestFormulaParserIf extends TestCase { } public void testIfWithLargeParams() { - - Class[] expClss; + + Class<?>[] expClss; expClss = new Class[] { RefPtg.class, @@ -110,11 +110,11 @@ public final class TestFormulaParserIf extends TestCase { AddPtg.class, FuncPtg.class, AttrPtg.class, // tAttrSkip - + RefPtg.class, RefPtg.class, FuncPtg.class, - + AttrPtg.class, // tAttrSkip FuncVarPtg.class, }; @@ -125,10 +125,10 @@ public final class TestFormulaParserIf extends TestCase { confirmAttrData(ptgs, 9, 20); confirmAttrData(ptgs, 13, 3); } - + public void testNestedIf() { - - Class[] expClss; + + Class<?>[] expClss; expClss = new Class[] { @@ -164,7 +164,7 @@ public final class TestFormulaParserIf extends TestCase { confirmAttrData(ptgs, 15, 3); confirmAttrData(ptgs, 17, 3); } - + public void testEmbeddedIf() { Ptg[] ptgs = parseFormula("IF(3>=1,\"*\",IF(4<>1,\"first\",\"second\"))"); assertEquals(17, ptgs.length); diff --git a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java index f89297390c..c7939e33a5 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java @@ -28,37 +28,37 @@ import junit.framework.TestCase; * @author Glen Stampoultzis (glens at apache.org) */ public final class TestWorkbook extends TestCase { - public void testFontStuff() throws Exception { + public void testFontStuff() { Workbook wb = (new HW()).getWorkbook(); - + assertEquals(4, wb.getNumberOfFontRecords()); assertEquals(68, wb.getRecords().size()); - + FontRecord f1 = wb.getFontRecordAt(0); FontRecord f4 = wb.getFontRecordAt(3); - + assertEquals(0, wb.getFontIndex(f1)); assertEquals(3, wb.getFontIndex(f4)); - + assertEquals(f1, wb.getFontRecordAt(0)); assertEquals(f4, wb.getFontRecordAt(3)); - + // There is no 4! new ones go in at 5 - + FontRecord n = wb.createNewFont(); assertEquals(69, wb.getRecords().size()); assertEquals(5, wb.getNumberOfFontRecords()); assertEquals(5, wb.getFontIndex(n)); assertEquals(n, wb.getFontRecordAt(5)); - + // And another FontRecord n6 = wb.createNewFont(); assertEquals(70, wb.getRecords().size()); assertEquals(6, wb.getNumberOfFontRecords()); assertEquals(6, wb.getFontIndex(n6)); assertEquals(n6, wb.getFontRecordAt(6)); - - + + // Now remove the one formerly at 5 assertEquals(70, wb.getRecords().size()); wb.removeFontRecord(n); @@ -68,13 +68,13 @@ public final class TestWorkbook extends TestCase { assertEquals(5, wb.getNumberOfFontRecords()); assertEquals(5, wb.getFontIndex(n6)); assertEquals(n6, wb.getFontRecordAt(5)); - + // Check that the earlier ones are unchanged assertEquals(0, wb.getFontIndex(f1)); assertEquals(3, wb.getFontIndex(f4)); assertEquals(f1, wb.getFontRecordAt(0)); assertEquals(f4, wb.getFontRecordAt(3)); - + // Finally, add another one FontRecord n7 = wb.createNewFont(); assertEquals(70, wb.getRecords().size()); @@ -82,13 +82,13 @@ public final class TestWorkbook extends TestCase { assertEquals(6, wb.getFontIndex(n7)); assertEquals(n7, wb.getFontRecordAt(6)); } - - private class HW extends HSSFWorkbook { - private HW() { + + private static final class HW extends HSSFWorkbook { + public HW() { super(); } protected Workbook getWorkbook() { return super.getWorkbook(); } } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java index 00d5c8c111..6aaa509a55 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java @@ -21,38 +21,40 @@ import junit.framework.TestCase; /** */ public final class TestExtendedFormatRecord extends TestCase { - byte[] header = new byte[] { - 0xE0-256, 00, 0x14, 00 // sid=e0, 20 bytes long + + private static final byte[] data = new byte[] { + 00, 00, // Font 0 + 00, 00, // Format 0 + 0xF5 - 256, 0xFF - 256, // Cell opts ... + 0x20, 00, // Alignment 20 + 00, 00, // Ident 0 + 00, 00, // Border 0 + 00, 00, // Palette 0 + 00, 00, 00, 00, // ADTL Palette 0 + 0xC0 - 256, 0x20 // Fill Palette 20c0 }; - byte[] data = new byte[] { - 00, 00, // Font 0 - 00, 00, // Format 0 - 0xF5-256, 0xFF-256, // Cell opts ... - 0x20, 00, // Alignment 20 - 00, 00, // Ident 0 - 00, 00, // Border 0 - 00, 00, // Palette 0 - 00, 00, 00, 00, // ADTL Palette 0 - 0xC0-256, 0x20 // Fill Palette 20c0 - }; - - public void testLoad() { - ExtendedFormatRecord record = new ExtendedFormatRecord(TestcaseRecordInputStream.create(0xe0, data)); - assertEquals(0, record.getFontIndex()); - assertEquals(0, record.getFormatIndex()); - assertEquals(0xF5-256, record.getCellOptions()); - assertEquals(0x20, record.getAlignmentOptions()); - assertEquals(0, record.getIndentionOptions()); - assertEquals(0, record.getBorderOptions()); - assertEquals(0, record.getPaletteOptions()); - assertEquals(0, record.getAdtlPaletteOptions()); - assertEquals(0x20c0, record.getFillPaletteOptions()); - - assertEquals( 20 + 4, record.getRecordSize() ); - } - - public void testStore() - { + + private static ExtendedFormatRecord createEFR() { + return new ExtendedFormatRecord(TestcaseRecordInputStream.create(0x00E0, data)); + } + + public void testLoad() { + ExtendedFormatRecord record = createEFR(); + assertEquals(0, record.getFontIndex()); + assertEquals(0, record.getFormatIndex()); + assertEquals(0xF5 - 256, record.getCellOptions()); + assertEquals(0x20, record.getAlignmentOptions()); + assertEquals(0, record.getIndentionOptions()); + assertEquals(0, record.getBorderOptions()); + assertEquals(0, record.getPaletteOptions()); + assertEquals(0, record.getAdtlPaletteOptions()); + assertEquals(0x20c0, record.getFillPaletteOptions()); + + assertEquals(20 + 4, record.getRecordSize()); + } + + + public void testStore() { // .fontindex = 0 // .formatindex = 0 // .celloptions = fffffff5 @@ -96,35 +98,35 @@ public final class TestExtendedFormatRecord extends TestCase { // .foreground= 40 // .background= 41 - ExtendedFormatRecord record = new ExtendedFormatRecord(); - record.setFontIndex((short)0); - record.setFormatIndex((short)0); - - record.setLocked(true); - record.setHidden(false); - record.setXFType((short)1); - record.setParentIndex((short)0xfff); - - record.setVerticalAlignment((short)2); - - record.setFillForeground((short)0x40); - record.setFillBackground((short)0x41); - - 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]); - } - - public void testCloneOnto() throws Exception { - ExtendedFormatRecord base = new ExtendedFormatRecord(TestcaseRecordInputStream.create(0xe0, data)); - - ExtendedFormatRecord other = new ExtendedFormatRecord(); - other.cloneStyleFrom(base); - - byte [] recordBytes = other.serialize(); - assertEquals(recordBytes.length - 4, data.length); - for (int i = 0; i < data.length; i++) - assertEquals("At offset " + i, data[i], recordBytes[i+4]); - } + ExtendedFormatRecord record = new ExtendedFormatRecord(); + record.setFontIndex((short) 0); + record.setFormatIndex((short) 0); + + record.setLocked(true); + record.setHidden(false); + record.setXFType((short) 1); + record.setParentIndex((short) 0xfff); + + record.setVerticalAlignment((short) 2); + + record.setFillForeground((short) 0x40); + record.setFillBackground((short) 0x41); + + 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]); + } + + public void testCloneOnto() { + ExtendedFormatRecord base = createEFR(); + + ExtendedFormatRecord other = new ExtendedFormatRecord(); + other.cloneStyleFrom(base); + + byte[] recordBytes = other.serialize(); + assertEquals(recordBytes.length - 4, data.length); + for (int i = 0; i < data.length; i++) + assertEquals("At offset " + i, data[i], recordBytes[i + 4]); + } } diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java index a93bed20c2..48449f40f0 100644 --- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java @@ -27,12 +27,12 @@ import org.apache.poi.hssf.record.StringRecord; import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector; /** - * + * * @author avik */ public final class TestFormulaRecordAggregate extends TestCase { - public void testBasic() throws Exception { + public void testBasic() { FormulaRecord f = new FormulaRecord(); f.setCachedResultTypeString(); StringRecord s = new StringRecord(); @@ -56,7 +56,7 @@ public final class TestFormulaRecordAggregate extends TestCase { sr.setString("NA"); SharedValueManager svm = SharedValueManager.EMPTY; FormulaRecordAggregate fra; - + try { fra = new FormulaRecordAggregate(fr, sr, svm); } catch (RecordFormatException e) { diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestAreaErrPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestAreaErrPtg.java index 0dd5758479..61125ac46b 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestAreaErrPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestAreaErrPtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -25,17 +24,13 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestAreaErrPtg extends AbstractPtgTestCase -{ +public final class TestAreaErrPtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("AreaErrPtg.xls"); assertEquals("Wrong formula string for area error", "SUM(#REF!)", workbook.getSheetAt(0).getRow(0).getCell(2).getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestErrPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestErrPtg.java index a7d140cae2..1913e078a4 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestErrPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestErrPtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -26,18 +25,14 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestErrPtg extends AbstractPtgTestCase -{ +public final class TestErrPtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("ErrPtg.xls"); HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell(0); assertEquals("Wrong cell value", 4.0, cell.getNumericCellValue(), 0.0); assertEquals("Wrong cell formula", "ERROR.TYPE(#REF!)", cell.getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestIntersectionPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestIntersectionPtg.java index a80ce11837..f05b57f737 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestIntersectionPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestIntersectionPtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -26,18 +25,14 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestIntersectionPtg extends AbstractPtgTestCase -{ +public final class TestIntersectionPtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("IntersectionPtg.xls"); HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell(2); assertEquals("Wrong cell value", 5.0, cell.getNumericCellValue(), 0.0); assertEquals("Wrong cell formula", "SUM(A1:B2 B2:C3)", cell.getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestPercentPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestPercentPtg.java index e4b89abb31..93ab765339 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestPercentPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestPercentPtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -26,13 +25,11 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestPercentPtg extends AbstractPtgTestCase -{ +public final class TestPercentPtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("PercentPtg.xls"); HSSFSheet sheet = workbook.getSheetAt(0); @@ -44,5 +41,3 @@ public class TestPercentPtg extends AbstractPtgTestCase sheet.getRow(1).getCell(0).getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestRangePtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestRangePtg.java index 2131777f80..f017de980d 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestRangePtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestRangePtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -26,18 +25,14 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestRangePtg extends AbstractPtgTestCase -{ +public final class TestRangePtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("RangePtg.xls"); HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell(1); assertEquals("Wrong cell value", 10.0, cell.getNumericCellValue(), 0.0); assertEquals("Wrong cell formula", "SUM(pineapple:B2)", cell.getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestUnionPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestUnionPtg.java index 3c9f439752..3ca33a2e82 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestUnionPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestUnionPtg.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -26,18 +25,14 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * * @author Daniel Noll (daniel at nuix dot com dot au) */ -public class TestUnionPtg extends AbstractPtgTestCase -{ +public final class TestUnionPtg extends AbstractPtgTestCase { /** * Tests reading a file containing this ptg. */ - public void testReading() throws Exception - { + public void testReading() { HSSFWorkbook workbook = loadWorkbook("UnionPtg.xls"); HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell(2); assertEquals("Wrong cell value", 24.0, cell.getNumericCellValue(), 0.0); assertEquals("Wrong cell formula", "SUM(A1:B2,B2:C3)", cell.getCellFormula()); } } - - diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java index 2c2c2ea0c3..43ffd6cb1e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java @@ -29,24 +29,24 @@ import org.apache.poi.hssf.util.CellReference; import org.apache.poi.ss.usermodel.CellValue; /** - * + * */ public final class TestBug42464 extends TestCase { - public void testOKFile() throws Exception { + public void testOKFile() { HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("42464-ExpPtg-ok.xls"); process(wb); } - public void testExpSharedBadFile() throws Exception { + public void testExpSharedBadFile() { HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("42464-ExpPtg-bad.xls"); process(wb); } - + private static void process(HSSFWorkbook wb) { HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb); for(int i=0; i<wb.getNumberOfSheets(); i++) { HSSFSheet s = wb.getSheetAt(i); - + Iterator it = s.rowIterator(); while(it.hasNext()) { HSSFRow r = (HSSFRow)it.next(); @@ -54,7 +54,7 @@ public final class TestBug42464 extends TestCase { } } } - + private static void process(HSSFRow row, HSSFFormulaEvaluator eval) { Iterator it = row.cellIterator(); while(it.hasNext()) { @@ -65,7 +65,7 @@ public final class TestBug42464 extends TestCase { FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord(); FormulaRecord r = record.getFormulaRecord(); Ptg[] ptgs = r.getParsedExpression(); - + String cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex(), false, false).formatAsString(); if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts System.out.print(cellRef); @@ -76,7 +76,7 @@ public final class TestBug42464 extends TestCase { } System.out.println("-> " + cell.getCellFormula()); } - + CellValue evalResult = eval.evaluate(cell); assertNotNull(evalResult); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java index 266200b2d2..6ab59fa2df 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java @@ -25,15 +25,14 @@ import java.io.ByteArrayOutputStream; /** * Tests the capabilities of the EscherGraphics class. - * + * * All tests have two escher groups available to them, * one anchored at 0,0,1022,255 and another anchored - * at 20,30,500,200 + * at 20,30,500,200 * * @author Glen Stampoultzis (glens at apache.org) */ -public class TestEscherGraphics extends TestCase -{ +public final class TestEscherGraphics extends TestCase { private HSSFWorkbook workbook; private HSSFPatriarch patriarch; private HSSFShapeGroup escherGroupA; @@ -43,7 +42,7 @@ public class TestEscherGraphics extends TestCase protected void setUp() throws Exception { workbook = new HSSFWorkbook(); - + HSSFSheet sheet = workbook.createSheet("test"); patriarch = sheet.createDrawingPatriarch(); escherGroupA = patriarch.createGroup(new HSSFClientAnchor(0,0,1022,255,(short)0,0,(short) 0,0)); @@ -53,15 +52,13 @@ public class TestEscherGraphics extends TestCase super.setUp(); } - public void testGetFont() throws Exception - { + public void testGetFont() { Font f = graphics.getFont(); if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1) assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString()); } - public void testGetFontMetrics() throws Exception - { + public void testGetFontMetrics() { Font f = graphics.getFont(); if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1) return; @@ -70,21 +67,18 @@ public class TestEscherGraphics extends TestCase assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString()); } - public void testSetFont() throws Exception - { + public void testSetFont() { Font f = new Font("Helvetica", 0, 12); graphics.setFont(f); assertEquals(f, graphics.getFont()); } - public void testSetColor() throws Exception - { + public void testSetColor() { graphics.setColor(Color.red); assertEquals(Color.red, graphics.getColor()); } - public void testFillRect() throws Exception - { + public void testFillRect() { graphics.fillRect( 10, 10, 20, 20 ); HSSFSimpleShape s = (HSSFSimpleShape) escherGroupA.getChildren().get(0); assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType()); @@ -94,8 +88,7 @@ public class TestEscherGraphics extends TestCase assertEquals(30, s.getAnchor().getDx2()); } - public void testDrawString() throws Exception - { + public void testDrawString() { graphics.drawString("This is a test", 10, 10); HSSFTextbox t = (HSSFTextbox) escherGroupA.getChildren().get(0); assertEquals("This is a test", t.getString().getString().toString()); @@ -105,30 +98,30 @@ public class TestEscherGraphics extends TestCase HSSFSheet s; HSSFShapeGroup s1; HSSFShapeGroup s2; - + patriarch.setCoordinates(10, 20, 30, 40); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); workbook.write(baos); workbook = new HSSFWorkbook(new ByteArrayInputStream(baos.toByteArray())); s = workbook.getSheetAt(0); - + patriarch = s.getDrawingPatriarch(); - + assertNotNull(patriarch); assertEquals(10, patriarch.getX1()); assertEquals(20, patriarch.getY1()); assertEquals(30, patriarch.getX2()); assertEquals(40, patriarch.getY2()); - + // Check the two groups too assertEquals(2, patriarch.countOfAllChildren()); assertTrue(patriarch.getChildren().get(0) instanceof HSSFShapeGroup); assertTrue(patriarch.getChildren().get(1) instanceof HSSFShapeGroup); - + s1 = (HSSFShapeGroup)patriarch.getChildren().get(0); s2 = (HSSFShapeGroup)patriarch.getChildren().get(1); - + assertEquals(0, s1.getX1()); assertEquals(0, s1.getY1()); assertEquals(1023, s1.getX2()); @@ -137,7 +130,7 @@ public class TestEscherGraphics extends TestCase assertEquals(0, s2.getY1()); assertEquals(1023, s2.getX2()); assertEquals(255, s2.getY2()); - + assertEquals(0, s1.getAnchor().getDx1()); assertEquals(0, s1.getAnchor().getDy1()); assertEquals(1022, s1.getAnchor().getDx2()); @@ -146,29 +139,29 @@ public class TestEscherGraphics extends TestCase assertEquals(30, s2.getAnchor().getDy1()); assertEquals(500, s2.getAnchor().getDx2()); assertEquals(200, s2.getAnchor().getDy2()); - - + + // Write and re-load once more, to check that's ok baos = new ByteArrayOutputStream(); workbook.write(baos); workbook = new HSSFWorkbook(new ByteArrayInputStream(baos.toByteArray())); s = workbook.getSheetAt(0); patriarch = s.getDrawingPatriarch(); - + assertNotNull(patriarch); assertEquals(10, patriarch.getX1()); assertEquals(20, patriarch.getY1()); assertEquals(30, patriarch.getX2()); assertEquals(40, patriarch.getY2()); - + // Check the two groups too assertEquals(2, patriarch.countOfAllChildren()); assertTrue(patriarch.getChildren().get(0) instanceof HSSFShapeGroup); assertTrue(patriarch.getChildren().get(1) instanceof HSSFShapeGroup); - + s1 = (HSSFShapeGroup)patriarch.getChildren().get(0); s2 = (HSSFShapeGroup)patriarch.getChildren().get(1); - + assertEquals(0, s1.getX1()); assertEquals(0, s1.getY1()); assertEquals(1023, s1.getX2()); @@ -177,7 +170,7 @@ public class TestEscherGraphics extends TestCase assertEquals(0, s2.getY1()); assertEquals(1023, s2.getX2()); assertEquals(255, s2.getY2()); - + assertEquals(0, s1.getAnchor().getDx1()); assertEquals(0, s1.getAnchor().getDy1()); assertEquals(1022, s1.getAnchor().getDx2()); @@ -186,32 +179,32 @@ public class TestEscherGraphics extends TestCase assertEquals(30, s2.getAnchor().getDy1()); assertEquals(500, s2.getAnchor().getDx2()); assertEquals(200, s2.getAnchor().getDy2()); - + // Change the positions of the first groups, // but not of their anchors s1.setCoordinates(2, 3, 1021, 242); - + baos = new ByteArrayOutputStream(); workbook.write(baos); workbook = new HSSFWorkbook(new ByteArrayInputStream(baos.toByteArray())); s = workbook.getSheetAt(0); patriarch = s.getDrawingPatriarch(); - + assertNotNull(patriarch); assertEquals(10, patriarch.getX1()); assertEquals(20, patriarch.getY1()); assertEquals(30, patriarch.getX2()); assertEquals(40, patriarch.getY2()); - + // Check the two groups too assertEquals(2, patriarch.countOfAllChildren()); assertEquals(2, patriarch.getChildren().size()); assertTrue(patriarch.getChildren().get(0) instanceof HSSFShapeGroup); assertTrue(patriarch.getChildren().get(1) instanceof HSSFShapeGroup); - + s1 = (HSSFShapeGroup)patriarch.getChildren().get(0); s2 = (HSSFShapeGroup)patriarch.getChildren().get(1); - + assertEquals(2, s1.getX1()); assertEquals(3, s1.getY1()); assertEquals(1021, s1.getX2()); @@ -220,7 +213,7 @@ public class TestEscherGraphics extends TestCase assertEquals(0, s2.getY1()); assertEquals(1023, s2.getX2()); assertEquals(255, s2.getY2()); - + assertEquals(0, s1.getAnchor().getDx1()); assertEquals(0, s1.getAnchor().getDy1()); assertEquals(1022, s1.getAnchor().getDx2()); @@ -229,8 +222,8 @@ public class TestEscherGraphics extends TestCase assertEquals(30, s2.getAnchor().getDy1()); assertEquals(500, s2.getAnchor().getDx2()); assertEquals(200, s2.getAnchor().getDy2()); - - + + // Now add some text to one group, and some more // to the base, and check we can get it back again HSSFTextbox tbox1 = @@ -239,37 +232,37 @@ public class TestEscherGraphics extends TestCase HSSFTextbox tbox2 = s2.createTextbox(new HSSFChildAnchor(41,42,43,44)); tbox2.setString(new HSSFRichTextString("This is text box 2")); - + assertEquals(3, patriarch.getChildren().size()); - - + + baos = new ByteArrayOutputStream(); workbook.write(baos); workbook = new HSSFWorkbook(new ByteArrayInputStream(baos.toByteArray())); s = workbook.getSheetAt(0); - + patriarch = s.getDrawingPatriarch(); - + assertNotNull(patriarch); assertEquals(10, patriarch.getX1()); assertEquals(20, patriarch.getY1()); assertEquals(30, patriarch.getX2()); assertEquals(40, patriarch.getY2()); - + // Check the two groups and the text assertEquals(3, patriarch.countOfAllChildren()); assertEquals(2, patriarch.getChildren().size()); - + // Should be two groups and a text assertTrue(patriarch.getChildren().get(0) instanceof HSSFShapeGroup); assertTrue(patriarch.getChildren().get(1) instanceof HSSFTextbox); // assertTrue(patriarch.getChildren().get(2) instanceof HSSFShapeGroup); - + s1 = (HSSFShapeGroup)patriarch.getChildren().get(0); tbox1 = (HSSFTextbox)patriarch.getChildren().get(1); - + // s2 = (HSSFShapeGroup)patriarch.getChildren().get(1); - + assertEquals(2, s1.getX1()); assertEquals(3, s1.getY1()); assertEquals(1021, s1.getX2()); @@ -278,7 +271,7 @@ public class TestEscherGraphics extends TestCase assertEquals(0, s2.getY1()); assertEquals(1023, s2.getX2()); assertEquals(255, s2.getY2()); - + assertEquals(0, s1.getAnchor().getDx1()); assertEquals(0, s1.getAnchor().getDy1()); assertEquals(1022, s1.getAnchor().getDx2()); @@ -287,7 +280,7 @@ public class TestEscherGraphics extends TestCase assertEquals(30, s2.getAnchor().getDy1()); assertEquals(500, s2.getAnchor().getDx2()); assertEquals(200, s2.getAnchor().getDy2()); - + // Not working just yet //assertEquals("I am text box 1", tbox1.getString().getString()); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFontDetails.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFontDetails.java index 2535f64130..6dbd4bce87 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFontDetails.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFontDetails.java @@ -26,37 +26,30 @@ import java.util.Properties; * * @author Glen Stampoultzis (glens at apache.org) */ -public class TestFontDetails extends TestCase -{ +public final class TestFontDetails extends TestCase { private Properties properties; private FontDetails fontDetails; - protected void setUp() throws Exception - { + protected void setUp() { properties = new Properties(); properties.setProperty("font.Arial.height", "13"); properties.setProperty("font.Arial.characters", "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "); properties.setProperty("font.Arial.widths", "6, 6, 6, 6, 6, 3, 6, 6, 3, 4, 6, 3, 9, 6, 6, 6, 6, 4, 6, 3, 6, 7, 9, 6, 5, 5, 7, 7, 7, 7, 7, 6, 8, 7, 3, 6, 7, 6, 9, 7, 8, 7, 8, 7, 7, 5, 7, 7, 9, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, "); fontDetails = FontDetails.create("Arial", properties); - } - public void testCreate() throws Exception - { + public void testCreate() { assertEquals(13, fontDetails.getHeight()); assertEquals(6, fontDetails.getCharWidth('a')); assertEquals(3, fontDetails.getCharWidth('f')); } - public void testGetStringWidth() throws Exception - { + public void testGetStringWidth() { assertEquals(9, fontDetails.getStringWidth("af")); } - public void testGetCharWidth() throws Exception - { + public void testGetCharWidth() { assertEquals(6, fontDetails.getCharWidth('a')); assertEquals(9, fontDetails.getCharWidth('=')); } - } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java index ba791bf58a..d94cfd9a96 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java @@ -38,7 +38,7 @@ import org.apache.poi.ss.formula.WorkbookEvaluator; import org.apache.poi.ss.formula.WorkbookEvaluatorTestHelper; /** - * + * */ public final class TestFormulaEvaluatorBugs extends TestCase { @@ -53,7 +53,7 @@ public final class TestFormulaEvaluatorBugs extends TestCase { /** * An odd problem with evaluateFormulaCell giving the * right values when file is opened, but changes - * to the source data in some versions of excel + * to the source data in some versions of excel * doesn't cause them to be updated. However, other * versions of excel, and gnumeric, work just fine * WARNING - tedious bug where you actually have to @@ -252,7 +252,7 @@ public final class TestFormulaEvaluatorBugs extends TestCase { assertEquals(true, cell.getBooleanCellValue()); } - public void testClassCast_bug44861() throws Exception { + public void testClassCast_bug44861() { HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("44861.xls"); // Check direct @@ -291,7 +291,7 @@ public final class TestFormulaEvaluatorBugs extends TestCase { throw e; } } - + private static final class EvalListener extends EvaluationListener { private int _countCacheHits; private int _countCacheMisses; @@ -314,12 +314,12 @@ public final class TestFormulaEvaluatorBugs extends TestCase { _countCacheMisses++; } } - + /** * The HSSFFormula evaluator performance benefits greatly from caching of intermediate cell values */ public void testSlowEvaluate45376() { - + // Firstly set up a sequence of formula cells where each depends on the previous multiple // times. Without caching, each subsequent cell take about 4 times longer to evaluate. HSSFWorkbook wb = new HSSFWorkbook(); @@ -333,11 +333,11 @@ public final class TestFormulaEvaluatorBugs extends TestCase { String formula = "IF(DATE(YEAR(" + prevCell + "),MONTH(" + prevCell + ")+1,1)<=$D$3," + "DATE(YEAR(" + prevCell + "),MONTH(" + prevCell + ")+1,1),NA())"; cell.setCellFormula(formula); - + } Calendar cal = new GregorianCalendar(2000, 0, 1, 0, 0, 0); row.createCell(0).setCellValue(cal); - + // Choose cell A9, so that the failing test case doesn't take too long to execute. HSSFCell cell = row.getCell(8); EvalListener evalListener = new EvalListener(); @@ -351,9 +351,9 @@ public final class TestFormulaEvaluatorBugs extends TestCase { throw new AssertionFailedError("Identifed bug 45376 - Formula evaluator should cache values"); } // With caching, the evaluationCount is 8 which is a big improvement - // Note - these expected values may change if the WorkbookEvaluator is + // Note - these expected values may change if the WorkbookEvaluator is // ever optimised to short circuit 'if' functions. assertEquals(8, evalCount); assertEquals(24, evalListener.getCountCacheHits()); } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java index 98ccbf0394..3e2feaed02 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java @@ -874,7 +874,7 @@ public final class TestFormulas extends TestCase { } /** MissingArgPtg */ - public void testMissingArgPtg() throws Exception { + public void testMissingArgPtg() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFCell cell = wb.createSheet("Sheet1").createRow(4).createCell(0); cell.setCellFormula("IF(A1=\"A\",1,)"); @@ -929,10 +929,10 @@ public final class TestFormulas extends TestCase { //check that the formula evaluator returns the correct result HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); - assertEquals(3.0, evaluator.evaluate(sh1.getRow(0).getCell(1)).getNumberValue()); - assertEquals(6.0, evaluator.evaluate(sh1.getRow(0).getCell(2)).getNumberValue()); + assertEquals(3.0, evaluator.evaluate(sh1.getRow(0).getCell(1)).getNumberValue(), 0.0); + assertEquals(6.0, evaluator.evaluate(sh1.getRow(0).getCell(2)).getNumberValue(), 0.0); - assertEquals(5.0, evaluator.evaluate(sh2.getRow(0).getCell(1)).getNumberValue()); - assertEquals(15.0, evaluator.evaluate(sh2.getRow(0).getCell(2)).getNumberValue()); + assertEquals(5.0, evaluator.evaluate(sh2.getRow(0).getCell(1)).getNumberValue(), 0.0); + assertEquals(15.0, evaluator.evaluate(sh2.getRow(0).getCell(2)).getNumberValue(), 0.0); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java index 5de4fc787b..d24371de58 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java @@ -27,10 +27,8 @@ import org.apache.poi.hssf.model.ConvertAnchor; * @author Glen Stampoultzis (glens at apache.org) * @author Yegor Kozlov (yegor at apache.org) */ -public class TestHSSFClientAnchor extends TestCase -{ - public void testGetAnchorHeightInPoints() throws Exception - { +public final class TestHSSFClientAnchor extends TestCase { + public void testGetAnchorHeightInPoints() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("test"); HSSFClientAnchor a = new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short)0,0); @@ -63,11 +61,10 @@ public class TestHSSFClientAnchor extends TestCase /** * When HSSFClientAnchor is converted into EscherClientAnchorRecord - * check that dx1, dx2, dy1 and dy2 are writtem "as is". - * (Bug 42999 reported that dx1 ans dx2 are swapped if dx1>dx2. It doesn't make sense for client anchors.) + * check that dx1, dx2, dy1 and dy2 are written "as is". + * (Bug 42999 reported that dx1 and dx2 are swapped if dx1>dx2. It doesn't make sense for client anchors.) */ - public void testConvertAnchor() throws Exception - { + public void testConvertAnchor() { HSSFClientAnchor[] anchor = { new HSSFClientAnchor( 0 , 0 , 0 , 0 ,(short)0, 1,(short)1,3), new HSSFClientAnchor( 100 , 0 , 900 , 255 ,(short)0, 1,(short)1,3), @@ -101,7 +98,5 @@ public class TestHSSFClientAnchor extends TestCase float height = anchor[i].getAnchorHeightInPoints(sheet); assertEquals(ref[i], height, 0); } - } - } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java index 431fa2d7d5..8bbbc06d50 100755 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java @@ -34,7 +34,7 @@ public final class TestHSSFDataFormat extends BaseTestDataFormat { /** * Test setting and getting boolean values. */ - public void testBuiltinFormats() throws Exception { + public void testBuiltinFormats() { baseBuiltinFormats(); } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java index 454a297105..f863dd980d 100755 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java @@ -76,7 +76,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("WebLinks!A1", link.getAddress()); } - public void testModify() throws Exception { + public void testModify() { HSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("HyperlinksOnManySheets.xls"); HSSFSheet sheet; @@ -105,7 +105,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { * or * link.setAddress("'Target Sheet-1'!A1"); //common between XSSF and HSSF */ - public void testCreateDocumentLink() throws Exception { + public void testCreateDocumentLink() { HSSFWorkbook wb = getTestDataProvider().createWorkbook(); //link to a place in this workbook @@ -166,7 +166,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("http://poi.apache.org/hssf/", link.getAddress()); } - public void testCreate() throws Exception { + public void testCreate() { HSSFWorkbook wb = getTestDataProvider().createWorkbook(); HSSFHyperlink link; diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java index 3ce255a0e4..39050ccd8c 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java @@ -17,56 +17,44 @@ package org.apache.poi.hssf.usermodel; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; import java.util.Iterator; import java.util.Map; + import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.record.PaletteRecord; import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.util.TempFile; /** * @author Brian Sanders (bsanders at risklabs dot com) */ public final class TestHSSFPalette extends TestCase { - private PaletteRecord palette; - private HSSFPalette hssfPalette; - - + private PaletteRecord _palette; + private HSSFPalette _hssfPalette; + + public void setUp() { - palette = new PaletteRecord(); - hssfPalette = new HSSFPalette(palette); + _palette = new PaletteRecord(); + _hssfPalette = new HSSFPalette(_palette); } - + /** * Verifies that a custom palette can be created, saved, and reloaded */ - public void testCustomPalette() throws IOException - { + public void testCustomPalette() { //reading sample xls HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("Simple.xls"); - + //creating custom palette HSSFPalette palette = book.getCustomPalette(); palette.setColorAtIndex((short) 0x12, (byte) 101, (byte) 230, (byte) 100); palette.setColorAtIndex((short) 0x3b, (byte) 0, (byte) 255, (byte) 52); - + //writing to disk; reading in and verifying palette - File temp = TempFile.createTempFile("testCustomPalette", ".xls"); - FileOutputStream fos = new FileOutputStream(temp); - book.write(fos); - fos.close(); - - FileInputStream fis = new FileInputStream(temp); - book = new HSSFWorkbook(fis); - fis.close(); - + book = HSSFTestDataSamples.writeOutAndReadBack(book); + palette = book.getCustomPalette(); HSSFColor color = palette.getColor(HSSFColor.CORAL.index); //unmodified assertNotNull("Unexpected null in custom palette (unmodified index)", color); @@ -76,7 +64,7 @@ public final class TestHSSFPalette extends TestCase { assertEquals(msg, expectedRGB[0], actualRGB[0]); assertEquals(msg, expectedRGB[1], actualRGB[1]); assertEquals(msg, expectedRGB[2], actualRGB[2]); - + color = palette.getColor((short) 0x12); assertNotNull("Unexpected null in custom palette (modified)", color); actualRGB = color.getTriplet(); @@ -85,21 +73,21 @@ public final class TestHSSFPalette extends TestCase { assertEquals(msg, (short) 230, actualRGB[1]); assertEquals(msg, (short) 100, actualRGB[2]); } - + /** * Uses the palette from cell stylings */ public void testPaletteFromCellColours() { HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("SimpleWithColours.xls"); - + HSSFPalette p = book.getCustomPalette(); - + HSSFCell cellA = book.getSheetAt(0).getRow(0).getCell(0); HSSFCell cellB = book.getSheetAt(0).getRow(1).getCell(0); HSSFCell cellC = book.getSheetAt(0).getRow(2).getCell(0); HSSFCell cellD = book.getSheetAt(0).getRow(3).getCell(0); HSSFCell cellE = book.getSheetAt(0).getRow(4).getCell(0); - + // Plain assertEquals("I'm plain", cellA.getStringCellValue()); assertEquals(64, cellA.getCellStyle().getFillForegroundColor()); @@ -108,7 +96,7 @@ public final class TestHSSFPalette extends TestCase { assertEquals(0, cellA.getCellStyle().getFillPattern()); assertEquals("0:0:0", p.getColor((short)64).getHexString()); assertEquals(null, p.getColor((short)32767)); - + // Red assertEquals("I'm red", cellB.getStringCellValue()); assertEquals(64, cellB.getCellStyle().getFillForegroundColor()); @@ -117,7 +105,7 @@ public final class TestHSSFPalette extends TestCase { assertEquals(0, cellB.getCellStyle().getFillPattern()); assertEquals("0:0:0", p.getColor((short)64).getHexString()); assertEquals("FFFF:0:0", p.getColor((short)10).getHexString()); - + // Red + green bg assertEquals("I'm red with a green bg", cellC.getStringCellValue()); assertEquals(11, cellC.getCellStyle().getFillForegroundColor()); @@ -126,7 +114,7 @@ public final class TestHSSFPalette extends TestCase { assertEquals(1, cellC.getCellStyle().getFillPattern()); assertEquals("0:FFFF:0", p.getColor((short)11).getHexString()); assertEquals("FFFF:0:0", p.getColor((short)10).getHexString()); - + // Pink with yellow assertEquals("I'm pink with a yellow pattern (none)", cellD.getStringCellValue()); assertEquals(13, cellD.getCellStyle().getFillForegroundColor()); @@ -135,7 +123,7 @@ public final class TestHSSFPalette extends TestCase { assertEquals(0, cellD.getCellStyle().getFillPattern()); assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString()); assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString()); - + // Pink with yellow - full assertEquals("I'm pink with a yellow pattern (full)", cellE.getStringCellValue()); assertEquals(13, cellE.getCellStyle().getFillForegroundColor()); @@ -145,56 +133,55 @@ public final class TestHSSFPalette extends TestCase { assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString()); assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString()); } - - public void testFindSimilar() throws Exception { + + public void testFindSimilar() { HSSFWorkbook book = new HSSFWorkbook(); HSSFPalette p = book.getCustomPalette(); - - + + // Add a few edge colours in p.setColorAtIndex((short)8, (byte)-1, (byte)0, (byte)0); p.setColorAtIndex((short)9, (byte)0, (byte)-1, (byte)0); p.setColorAtIndex((short)10, (byte)0, (byte)0, (byte)-1); - + // And some near a few of them p.setColorAtIndex((short)11, (byte)-1, (byte)2, (byte)2); p.setColorAtIndex((short)12, (byte)-2, (byte)2, (byte)10); p.setColorAtIndex((short)13, (byte)-4, (byte)0, (byte)0); p.setColorAtIndex((short)14, (byte)-8, (byte)0, (byte)0); - + assertEquals( "FFFF:0:0", p.getColor((short)8).getHexString() ); - + // Now check we get the right stuff back assertEquals( - p.getColor((short)8).getHexString(), + p.getColor((short)8).getHexString(), p.findSimilarColor((byte)-1, (byte)0, (byte)0).getHexString() ); assertEquals( - p.getColor((short)8).getHexString(), + p.getColor((short)8).getHexString(), p.findSimilarColor((byte)-2, (byte)0, (byte)0).getHexString() ); assertEquals( - p.getColor((short)8).getHexString(), + p.getColor((short)8).getHexString(), p.findSimilarColor((byte)-1, (byte)1, (byte)0).getHexString() ); assertEquals( - p.getColor((short)11).getHexString(), + p.getColor((short)11).getHexString(), p.findSimilarColor((byte)-1, (byte)2, (byte)1).getHexString() ); assertEquals( - p.getColor((short)12).getHexString(), + p.getColor((short)12).getHexString(), p.findSimilarColor((byte)-1, (byte)2, (byte)10).getHexString() ); } - + /** * Verifies that the generated gnumeric-format string values match the * hardcoded values in the HSSFColor default color palette */ - public void testGnumericStrings() - { + public void testGnumericStrings() { compareToDefaults(new ColorComparator() { public void compare(HSSFColor expected, HSSFColor palette) { @@ -202,18 +189,17 @@ public final class TestHSSFPalette extends TestCase { } }); } - + /** * Verifies that the palette handles invalid palette indexes */ - public void testBadIndexes() - { + public void testBadIndexes() { //too small - hssfPalette.setColorAtIndex((short) 2, (byte) 255, (byte) 255, (byte) 255); + _hssfPalette.setColorAtIndex((short) 2, (byte) 255, (byte) 255, (byte) 255); //too large - hssfPalette.setColorAtIndex((short) 0x45, (byte) 255, (byte) 255, (byte) 255); - - //should still match defaults; + _hssfPalette.setColorAtIndex((short) 0x45, (byte) 255, (byte) 255, (byte) 255); + + //should still match defaults; compareToDefaults(new ColorComparator() { public void compare(HSSFColor expected, HSSFColor palette) { @@ -225,35 +211,30 @@ public final class TestHSSFPalette extends TestCase { } }); } - - private void compareToDefaults(ColorComparator c) - { + + private void compareToDefaults(ColorComparator c) { Map colors = HSSFColor.getIndexHash(); Iterator it = colors.keySet().iterator(); while (it.hasNext()) { Number index = (Number) it.next(); HSSFColor expectedColor = (HSSFColor) colors.get(index); - HSSFColor paletteColor = hssfPalette.getColor(index.shortValue()); + HSSFColor paletteColor = _hssfPalette.getColor(index.shortValue()); c.compare(expectedColor, paletteColor); } } - public void testAddColor() throws Exception - { + public void testAddColor() { try { - HSSFColor hssfColor = hssfPalette.addColor((byte)10,(byte)10,(byte)10); + _hssfPalette.addColor((byte)10,(byte)10,(byte)10); fail(); - } - catch ( RuntimeException e ) - { + } catch (RuntimeException e) { // Failing because by default there are no colours left in the palette. } } - private static interface ColorComparator - { + private static interface ColorComparator { void compare(HSSFColor expected, HSSFColor palette); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java index a14c2510b5..8ce707d9aa 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java @@ -19,10 +19,8 @@ package org.apache.poi.hssf.usermodel; import junit.framework.TestCase; -public class TestHSSFRichTextString extends TestCase -{ - public void testApplyFont() throws Exception - { +public final class TestHSSFRichTextString extends TestCase { + public void testApplyFont() { HSSFRichTextString r = new HSSFRichTextString("testing"); assertEquals(0,r.numFormattingRuns()); @@ -64,8 +62,7 @@ public class TestHSSFRichTextString extends TestCase } - public void testClearFormatting() throws Exception - { + public void testClearFormatting() { HSSFRichTextString r = new HSSFRichTextString("testing"); assertEquals(0, r.numFormattingRuns()); @@ -79,7 +76,7 @@ public class TestHSSFRichTextString extends TestCase /** * Test case proposed in Bug 40520: formated twice => will format whole String */ - public void test40520_1(){ + public void test40520_1() { short font = 3; @@ -96,7 +93,7 @@ public class TestHSSFRichTextString extends TestCase /** * Test case proposed in Bug 40520: overlapped range => will format whole String */ - public void test40520_2(){ + public void test40520_2() { short font = 3; HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890"); @@ -113,7 +110,7 @@ public class TestHSSFRichTextString extends TestCase /** * Test case proposed in Bug 40520: formated twice => will format whole String */ - public void test40520_3(){ + public void test40520_3() { short font = 3; HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890"); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java index ddd9101593..52b88d34ef 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java @@ -1,19 +1,19 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ package org.apache.poi.hssf.usermodel; @@ -43,7 +43,7 @@ public final class TestSheetHiding extends TestCase { * with the right text on them, no matter what * the hidden flags are */ - public void testTextSheets() throws Exception { + public void testTextSheets() { // Both should have two sheets assertEquals(2, wbH.getNumberOfSheets()); assertEquals(2, wbU.getNumberOfSheets()); @@ -71,7 +71,7 @@ public final class TestSheetHiding extends TestCase { * Check that we can get and set the hidden flags * as expected */ - public void testHideUnHideFlags() throws Exception { + public void testHideUnHideFlags() { assertTrue(wbH.isSheetHidden(0)); assertFalse(wbH.isSheetHidden(1)); assertFalse(wbU.isSheetHidden(0)); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java index a90aa29080..b0efff9c6d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java @@ -1,34 +1,33 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + package org.apache.poi.hssf.usermodel; import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; -public class TestUnicodeWorkbook extends TestCase { +public final class TestUnicodeWorkbook extends TestCase { - /** Tests Bug38230 + /** + * Tests Bug38230 * That a Umlat is written and then read back. * It should have been written as a compressed unicode. - * - * - * */ - public void testUmlatReadWrite() throws Exception { + public void testUmlatReadWrite() { HSSFWorkbook wb = new HSSFWorkbook(); //Create a unicode sheet name (euro symbol) @@ -50,5 +49,4 @@ public class TestUnicodeWorkbook extends TestCase { c = r.getCell(1); assertEquals(c.getRichStringCellValue().getString(), "\u00e4"); } - } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java index bfaed8d370..d5a929dd9e 100755 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java @@ -33,7 +33,7 @@ public abstract class BaseTestDataFormat extends TestCase { */ protected abstract ITestDataProvider getTestDataProvider(); - public void baseBuiltinFormats() throws Exception { + public void baseBuiltinFormats() { Workbook wb = getTestDataProvider().createWorkbook(); DataFormat df = wb.createDataFormat(); @@ -60,4 +60,4 @@ public abstract class BaseTestDataFormat extends TestCase { //read and verify the string representation assertEquals(customFmt, df.getFormat((short)customIdx)); } -}
\ No newline at end of file +} diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java index 98284df7c8..2a81023ed5 100755 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java @@ -71,7 +71,7 @@ public abstract class BaseTestSheet extends TestCase { assertTrue(it2.hasNext()); Row row2_ovrewritten_ref = it2.next(); assertSame(row2_ovrewritten, row2_ovrewritten_ref); - assertEquals(100.0, row2_ovrewritten_ref.getCell(0).getNumericCellValue()); + assertEquals(100.0, row2_ovrewritten_ref.getCell(0).getNumericCellValue(), 0.0); } @@ -91,7 +91,7 @@ public abstract class BaseTestSheet extends TestCase { assertEquals(0, sheet1.getFirstRowNum()); assertEquals(0, sheet1.getLastRowNum()); - Row row1 = sheet1.createRow(1); + sheet1.createRow(1); Row row2 = sheet1.createRow(2); assertEquals(2, sheet1.getPhysicalNumberOfRows()); assertEquals(1, sheet1.getFirstRowNum()); @@ -175,7 +175,7 @@ public abstract class BaseTestSheet extends TestCase { /** * Setting landscape and portrait stuff on new sheets */ - public void testPrintSetupLandscapeNew() throws Exception { + public void testPrintSetupLandscapeNew() { Workbook workbook = getTestDataProvider().createWorkbook(); Sheet sheetL = workbook.createSheet("LandscapeS"); Sheet sheetP = workbook.createSheet("LandscapeP"); @@ -244,7 +244,7 @@ public abstract class BaseTestSheet extends TestCase { ; } assertEquals(1, sheet.getNumMergedRegions()); - + } /** @@ -397,21 +397,21 @@ public abstract class BaseTestSheet extends TestCase { Sheet sheet = workbook.createSheet(); sheet.setDefaultRowHeightInPoints(15); assertEquals((short) 300, sheet.getDefaultRowHeight()); - assertEquals((float) 15, sheet.getDefaultRowHeightInPoints()); + assertEquals(15.0F, sheet.getDefaultRowHeightInPoints(), 0F); // Set a new default row height in twips and test getting the value in points sheet.setDefaultRowHeight((short) 360); - assertEquals(18.0f, sheet.getDefaultRowHeightInPoints()); + assertEquals(18.0f, sheet.getDefaultRowHeightInPoints(), 0F); assertEquals((short) 360, sheet.getDefaultRowHeight()); // Test that defaultRowHeight is a truncated short: E.G. 360inPoints -> 18; 361inPoints -> 18 sheet.setDefaultRowHeight((short) 361); - assertEquals((float)361/20, sheet.getDefaultRowHeightInPoints()); + assertEquals((float)361/20, sheet.getDefaultRowHeightInPoints(), 0F); assertEquals((short) 361, sheet.getDefaultRowHeight()); // Set a new default row height in points and test getting the value in twips sheet.setDefaultRowHeightInPoints(17.5f); - assertEquals(17.5f, sheet.getDefaultRowHeightInPoints()); + assertEquals(17.5f, sheet.getDefaultRowHeightInPoints(), 0F); assertEquals((short)(17.5f*20), sheet.getDefaultRowHeight()); } @@ -537,19 +537,19 @@ public abstract class BaseTestSheet extends TestCase { Workbook workbook = getTestDataProvider().createWorkbook(); Sheet sheet = workbook.createSheet("Sheet 1"); - assertEquals(marginLeft, sheet.getMargin(Sheet.LeftMargin)); + assertEquals(marginLeft, sheet.getMargin(Sheet.LeftMargin), 0.0); sheet.setMargin(Sheet.LeftMargin, 10.0); //left margin is custom, all others are default - assertEquals(10.0, sheet.getMargin(Sheet.LeftMargin)); - assertEquals(marginRight, sheet.getMargin(Sheet.RightMargin)); - assertEquals(marginTop, sheet.getMargin(Sheet.TopMargin)); - assertEquals(marginBottom, sheet.getMargin(Sheet.BottomMargin)); + assertEquals(10.0, sheet.getMargin(Sheet.LeftMargin), 0.0); + assertEquals(marginRight, sheet.getMargin(Sheet.RightMargin), 0.0); + assertEquals(marginTop, sheet.getMargin(Sheet.TopMargin), 0.0); + assertEquals(marginBottom, sheet.getMargin(Sheet.BottomMargin), 0.0); sheet.setMargin(Sheet.RightMargin, 11.0); - assertEquals(11.0, sheet.getMargin(Sheet.RightMargin)); + assertEquals(11.0, sheet.getMargin(Sheet.RightMargin), 0.0); sheet.setMargin(Sheet.TopMargin, 12.0); - assertEquals(12.0, sheet.getMargin(Sheet.TopMargin)); + assertEquals(12.0, sheet.getMargin(Sheet.TopMargin), 0.0); sheet.setMargin(Sheet.BottomMargin, 13.0); - assertEquals(13.0, sheet.getMargin(Sheet.BottomMargin)); + assertEquals(13.0, sheet.getMargin(Sheet.BottomMargin), 0.0); // incorrect margin constant try { @@ -618,9 +618,9 @@ public abstract class BaseTestSheet extends TestCase { public void testGetFirstLastRowNum() { Workbook workbook = getTestDataProvider().createWorkbook(); Sheet sheet = workbook.createSheet("Sheet 1"); - Row row10 = sheet.createRow(9); - Row row1 = sheet.createRow(0); - Row row2 = sheet.createRow(1); + sheet.createRow(9); + sheet.createRow(0); + sheet.createRow(1); assertEquals(0, sheet.getFirstRowNum()); assertEquals(9, sheet.getLastRowNum()); } @@ -639,6 +639,4 @@ public abstract class BaseTestSheet extends TestCase { sheet.setColumnHidden(2, true); assertTrue(sheet.isColumnHidden(2)); } - - -}
\ No newline at end of file +} |