]> source.dussan.org Git - poi.git/commitdiff
Fixed compiler warnings - unnecessary throws declaration
authorJosh Micich <josh@apache.org>
Tue, 18 Aug 2009 19:49:28 +0000 (19:49 +0000)
committerJosh Micich <josh@apache.org>
Tue, 18 Aug 2009 19:49:28 +0000 (19:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805552 13f79535-47bb-0310-9956-ffa450edef68

122 files changed:
src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
src/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java
src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java
src/java/org/apache/poi/util/TempFile.java
src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePartOutputStream.java
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
src/ooxml/java/org/apache/poi/util/PackageHelper.java
src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java
src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java
src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java
src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java
src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
src/ooxml/testcases/org/apache/poi/xssf/model/TestMapInfo.java
src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java
src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java
src/scratchpad/src/org/apache/poi/hdf/extractor/NewOleFile.java
src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java
src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java
src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBLongHandler.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBShortHandler.java
src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java
src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TextPublisherTextExtractor.java
src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java
src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java
src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfo.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextBytesAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java
src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java
src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBug46610.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHeaderStories.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeInsertion.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeProperties.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
src/testcases/org/apache/poi/TestPOIDocumentMain.java
src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java
src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java
src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java
src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
src/testcases/org/apache/poi/hssf/model/TestDrawingManager.java
src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java
src/testcases/org/apache/poi/hssf/model/TestWorkbook.java
src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java
src/testcases/org/apache/poi/hssf/record/formula/TestAreaErrPtg.java
src/testcases/org/apache/poi/hssf/record/formula/TestErrPtg.java
src/testcases/org/apache/poi/hssf/record/formula/TestIntersectionPtg.java
src/testcases/org/apache/poi/hssf/record/formula/TestPercentPtg.java
src/testcases/org/apache/poi/hssf/record/formula/TestRangePtg.java
src/testcases/org/apache/poi/hssf/record/formula/TestUnionPtg.java
src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java
src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
src/testcases/org/apache/poi/hssf/usermodel/TestFontDetails.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java
src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java

index ca1cfb46dd62a4ee8543645bd34a68bd7d357245..1a6b12614529e919e113c61730c1b23587e9c8b9 100644 (file)
@@ -14,9 +14,9 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpsf.extractor;
 
-import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Iterator;
 
@@ -33,7 +33,7 @@ import org.apache.poi.util.LittleEndian;
 
 /**
  * Extracts all of the HPSF properties, both
- *  build in and custom, returning them in 
+ *  build in and custom, returning them in
  *  textual form.
  */
 public class HPSFPropertiesExtractor extends POITextExtractor {
@@ -46,14 +46,14 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
        public HPSFPropertiesExtractor(POIFSFileSystem fs) {
                super(new PropertiesOnlyDocument(fs));
        }
-       
+
        public String getDocumentSummaryInformationText() {
                DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
                StringBuffer text = new StringBuffer();
 
                // Normal properties
                text.append( getPropertiesText(dsi) );
-               
+
                // Now custom ones
                CustomProperties cps = dsi.getCustomProperties();
                if(cps != null) {
@@ -64,38 +64,38 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
                                text.append(key + " = " + val + "\n");
                        }
                }
-               
+
                // All done
                return text.toString();
        }
        public String getSummaryInformationText() {
                SummaryInformation si = document.getSummaryInformation();
-               
+
                // Just normal properties
                return getPropertiesText(si);
        }
-       
+
        private static String getPropertiesText(SpecialPropertySet ps) {
                if(ps == null) {
                        // Not defined, oh well
                        return "";
                }
-               
+
                StringBuffer text = new StringBuffer();
-               
+
                PropertyIDMap idMap = ps.getPropertySetIDMap();
                Property[] props = ps.getProperties();
                for(int i=0; i<props.length; i++) {
-                       String type = Long.toString( props[i].getID() ); 
+                       String type = Long.toString( props[i].getID() );
                        Object typeObj = idMap.get(props[i].getID());
                        if(typeObj != null) {
                                type = typeObj.toString();
                        }
-                       
+
                        String val = getPropertyValueText( props[i].getValue() );
                        text.append(type + " = " + val + "\n");
                }
-               
+
                return text.toString();
        }
        private static String getPropertyValueText(Object val) {
@@ -123,13 +123,13 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
        }
 
        /**
-        * Return the text of all the properties defined in
+        * @return the text of all the properties defined in
         *  the document.
         */
        public String getText() {
                return getSummaryInformationText() + getDocumentSummaryInformationText();
        }
-       
+
        /**
         * Prevent recursion!
         */
@@ -138,15 +138,15 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
        }
 
        /**
-        * So we can get at the properties of any 
+        * So we can get at the properties of any
         *  random OLE2 document.
         */
-       private static class PropertiesOnlyDocument extends POIDocument {
-               private PropertiesOnlyDocument(POIFSFileSystem fs) {
+       private static final class PropertiesOnlyDocument extends POIDocument {
+               public PropertiesOnlyDocument(POIFSFileSystem fs) {
                        super(fs);
                }
 
-               public void write(OutputStream out) throws IOException {
+               public void write(OutputStream out) {
                        throw new IllegalStateException("Unable to write, only for properties!");
                }
        }
index 4e669a869b9c9a84b1965b9feda0e8937b617bcd..fd1ffa9a5e96cb5aff3e82e5674ef5cb4d2e1e10 100644 (file)
@@ -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,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.filesystem;
 
@@ -30,12 +28,10 @@ import java.util.*;
  * @author Marc Johnson (mjohnson at apache dot org)
  */
 
-public class DocumentOutputStream
-    extends OutputStream
-{
-    private OutputStream stream;
-    private int          limit;
-    private int          written;
+public final class DocumentOutputStream extends OutputStream {
+    private final OutputStream _stream;
+    private final int          _limit;
+    private int          _written;
 
     /**
      * Create a DocumentOutputStream
@@ -44,12 +40,10 @@ public class DocumentOutputStream
      *               read
      * @param limit the maximum number of bytes that can be written
      */
-
-    DocumentOutputStream(final OutputStream stream, final int limit)
-    {
-        this.stream  = stream;
-        this.limit   = limit;
-        this.written = 0;
+    DocumentOutputStream(OutputStream stream, int limit) {
+        _stream  = stream;
+        _limit   = limit;
+        _written = 0;
     }
 
     /**
@@ -64,12 +58,11 @@ public class DocumentOutputStream
      *                        output stream has been closed, or if the
      *                        writer tries to write too much data.
      */
-
-    public void write(final int b)
+    public void write(int b)
         throws IOException
     {
         limitCheck(1);
-        stream.write(b);
+        _stream.write(b);
     }
 
     /**
@@ -79,8 +72,7 @@ public class DocumentOutputStream
      * @param b the data.
      * @exception IOException if an I/O error occurs.
      */
-
-    public void write(final byte b[])
+    public void write(byte b[])
         throws IOException
     {
         write(b, 0, b.length);
@@ -106,12 +98,11 @@ public class DocumentOutputStream
      *                        output stream is closed or if the writer
      *                        tries to write too many bytes.
      */
-
-    public void write(final byte b[], final int off, final int len)
+    public void write(byte b[], int off, int len)
         throws IOException
     {
         limitCheck(len);
-        stream.write(b, off, len);
+        _stream.write(b, off, len);
     }
 
     /**
@@ -120,11 +111,10 @@ public class DocumentOutputStream
      *
      * @exception IOException if an I/O error occurs.
      */
-
     public void flush()
         throws IOException
     {
-        stream.flush();
+        _stream.flush();
     }
 
     /**
@@ -135,10 +125,7 @@ public class DocumentOutputStream
      *
      * @exception IOException if an I/O error occurs.
      */
-
-    public void close()
-        throws IOException
-    {
+    public void close() {
 
         // ignore this call
     }
@@ -152,27 +139,25 @@ public class DocumentOutputStream
      *
      * @exception IOException on I/O error
      */
-
-    void writeFiller(final int totalLimit, final byte fill)
+    void writeFiller(int totalLimit, byte fill)
         throws IOException
     {
-        if (totalLimit > written)
+        if (totalLimit > _written)
         {
-            byte[] filler = new byte[ totalLimit - written ];
+            byte[] filler = new byte[ totalLimit - _written ];
 
             Arrays.fill(filler, fill);
-            stream.write(filler);
+            _stream.write(filler);
         }
     }
 
-    private void limitCheck(final int toBeWritten)
+    private void limitCheck(int toBeWritten)
         throws IOException
     {
-        if ((written + toBeWritten) > limit)
+        if ((_written + toBeWritten) > _limit)
         {
             throw new IOException("tried to write too much data");
         }
-        written += toBeWritten;
+        _written += toBeWritten;
     }
-}   // end public class DocumentOutputStream
-
+}
index 5ae4f1ff03814221f15a9f856321c302c9af5169..d0ecb1f19ae4e617692d00e8d6c1f0314324d92a 100644 (file)
@@ -64,9 +64,8 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      * @return an array of SmallDocumentBlock instances, filled from
      *         the array
      */
-
-    public static SmallDocumentBlock [] convert(final byte [] array,
-                                                final int size)
+    public static SmallDocumentBlock [] convert(byte [] array,
+                                                int size)
     {
         SmallDocumentBlock[] rval   =
             new SmallDocumentBlock[ (size + _block_size - 1) / _block_size ];
@@ -103,8 +102,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      *
      * @return number of big blocks the list encompasses
      */
-
-    public static int fill(final List blocks)
+    public static int fill(List blocks)
     {
         int count           = blocks.size();
         int big_block_count = (count + _blocks_per_big_block - 1)
@@ -130,9 +128,8 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      * @exception ArrayIndexOutOfBoundsException if, somehow, the store
      *            contains less data than size indicates
      */
-
-    public static SmallDocumentBlock [] convert(final BlockWritable [] store,
-                                                final int size)
+    public static SmallDocumentBlock [] convert(BlockWritable [] store,
+                                                int size)
         throws IOException, ArrayIndexOutOfBoundsException
     {
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -159,10 +156,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      *               data
      *
      * @return a List of SmallDocumentBlock's extracted from the input
-     *
-     * @exception IOException
      */
-
     public static List extract(ListManagedBlock [] blocks)
         throws IOException
     {
@@ -193,7 +187,6 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      *
      * @return total size
      */
-
     public static int calcSize(int size)
     {
         return size * _block_size;
@@ -207,13 +200,11 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
         return block;
     }
 
-    private static int convertToBlockCount(final int size)
+    private static int convertToBlockCount(int size)
     {
         return (size + _block_size - 1) / _block_size;
     }
 
-    /* ********** START implementation of BlockWritable ********** */
-
     /**
      * Write the storage to an OutputStream
      *
@@ -223,16 +214,12 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      * @exception IOException on problems writing to the specified
      *            stream
      */
-
-    public void writeBlocks(final OutputStream stream)
+    public void writeBlocks(OutputStream stream)
         throws IOException
     {
         stream.write(_data);
     }
 
-    /* **********  END  implementation of BlockWritable ********** */
-    /* ********** START implementation of ListManagedBlock ********** */
-
     /**
      * Get the data from the block
      *
@@ -240,13 +227,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
      *
      * @exception IOException if there is no data
      */
-
-    public byte [] getData()
-        throws IOException
-    {
+    public byte [] getData() {
         return _data;
     }
-
-    /* **********  END  implementation of ListManagedBlock ********** */
-}   // end public class SmallDocumentBlock
-
+}
index 751847c0548791fea37abcf9c287ffb49034456d..d9489fb8ad5e76f5238b8495f8631fcc42a47607 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.util;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Random;
 
 /**
@@ -25,20 +25,18 @@ import java.util.Random;
  *
  * @author Glen Stampoultzis
  */
-public class TempFile
-{
-    static File dir;
-    static Random rnd = new Random();
+public final class TempFile {
+    private static File dir;
+    private static final Random rnd = new Random();
 
     /**
      * Creates a temporary file.  Files are collected into one directory and by default are
      * deleted on exit from the VM.  Files can be kept by defining the system property
      * <code>poi.keep.tmp.files</code>.
      * <p>
-     * Dont forget to close all files or it might not be possible to delete them.
+     * Don't forget to close all files or it might not be possible to delete them.
      */
-    public static File createTempFile(String prefix, String suffix) throws IOException
-    {
+    public static File createTempFile(String prefix, String suffix) {
         if (dir == null)
         {
             dir = new File(System.getProperty("java.io.tmpdir"), "poifiles");
@@ -52,7 +50,4 @@ public class TempFile
             newFile.deleteOnExit();
         return newFile;
     }
-
-
-
 }
index a394f5958318735988584e9419db7def2ae71341..b890ad725d9892a7ff607fc05f07066fcea9a772 100755 (executable)
@@ -94,7 +94,7 @@ public final class ZipPackage extends Package {
         * @throws InvalidFormatException
         *             If the content type part parsing encounters an error.
         */
-       ZipPackage(String path, PackageAccess access) throws InvalidFormatException {
+       ZipPackage(String path, PackageAccess access) {
                super(access);
 
                ZipFile zipFile = ZipHelper.openZipFile(path);
index ed0bc6a74a3c5d969a3577bbd62645e9b6d52887..cf809d66780e9459348cb52c574f6b4c23ff168e 100755 (executable)
@@ -25,22 +25,21 @@ import java.io.OutputStream;
  * Build an output stream for MemoryPackagePart.
  *
  * @author Julien Chable
- * @version 1.0
  */
 public final class MemoryPackagePartOutputStream extends OutputStream {
 
-       private MemoryPackagePart part;
+       private MemoryPackagePart _part;
 
-       private ByteArrayOutputStream buff;
+       private ByteArrayOutputStream _buff;
 
        public MemoryPackagePartOutputStream(MemoryPackagePart part) {
-               this.part = part;
-               buff = new ByteArrayOutputStream();
+               this._part = part;
+               _buff = new ByteArrayOutputStream();
        }
 
        @Override
-       public void write(int b) throws IOException {
-               buff.write(b);
+       public void write(int b) {
+               _buff.write(b);
        }
 
        /**
@@ -59,38 +58,38 @@ public final class MemoryPackagePartOutputStream extends OutputStream {
         */
        @Override
        public void flush() throws IOException {
-               buff.flush();
-               if (part.data != null) {
-                       byte[] newArray = new byte[part.data.length + buff.size()];
+               _buff.flush();
+               if (_part.data != null) {
+                       byte[] newArray = new byte[_part.data.length + _buff.size()];
                        // copy the previous contents of part.data in newArray
-                       System.arraycopy(part.data, 0, newArray, 0, part.data.length);
+                       System.arraycopy(_part.data, 0, newArray, 0, _part.data.length);
 
                        // append the newly added data
-                       byte[] buffArr = buff.toByteArray();
-                       System.arraycopy(buffArr, 0, newArray, part.data.length,
+                       byte[] buffArr = _buff.toByteArray();
+                       System.arraycopy(buffArr, 0, newArray, _part.data.length,
                                        buffArr.length);
 
                        // save the result as new data
-                       part.data = newArray;
+                       _part.data = newArray;
                } else {
                        // was empty, just fill it
-                       part.data = buff.toByteArray();
+                       _part.data = _buff.toByteArray();
                }
 
                /*
                 * Clear this streams buffer, in case flush() is called a second time
                 * Fix bug 1921637 - provided by Rainer Schwarze
                 */
-               buff.reset();
+               _buff.reset();
        }
 
        @Override
-       public void write(byte[] b, int off, int len) throws IOException {
-               buff.write(b, off, len);
+       public void write(byte[] b, int off, int len) {
+               _buff.write(b, off, len);
        }
 
        @Override
        public void write(byte[] b) throws IOException {
-               buff.write(b);
+               _buff.write(b);
        }
 }
index aeea4dccbca98c48edded1dbbd99ca3f3c4edd0f..76bb424376489b05446ee7d49ff44d0e2c3fb67c 100755 (executable)
@@ -25,7 +25,6 @@ import java.util.Date;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.ContentTypes;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
index 3fefe53a0382f5871c79adc767cf8318bd7ececa..5d8d9ade757daad228dda4fcf51abfbebc549fb5 100755 (executable)
@@ -97,7 +97,7 @@ public final class PackageHelper {
     /**
      * Creates an empty file in the default temporary-file directory,
      */
-    public static File createTempFile() throws IOException {
+    public static File createTempFile() {
         File file = TempFile.createTempFile("poi-ooxml-", ".tmp");
         //there is no way to pass an existing file to Package.create(file),
         //delete first, the file will be re-created in Packe.create(file)
index e6644a5634814b1934bd9e520e2192d8b31e6b0d..8843f609334cd5dcd7c12be11a225b2d807f61b2 100755 (executable)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.FileOutputStream;
-import java.util.List;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
 
-import org.apache.poi.util.TempFile;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
-
-import junit.framework.TestCase;
+import org.apache.poi.util.TempFile;
 
 /**
  * Test recursive read and write of OPC packages
  */
-public class TestPOIXMLDocument extends TestCase
-{
+public final class TestPOIXMLDocument extends TestCase {
     private static class OPCParser extends POIXMLDocument {
 
-        public OPCParser(OPCPackage pkg) throws IOException {
+        public OPCParser(OPCPackage pkg) {
             super(pkg);
         }
 
@@ -49,13 +45,16 @@ public class TestPOIXMLDocument extends TestCase
             throw new RuntimeException("not supported");
         }
 
-        public void parse(POIXMLFactory factory) throws OpenXML4JException, IOException{
+        public void parse(POIXMLFactory factory) throws IOException{
             load(factory);
         }
     }
 
-    private static class TestFactory extends POIXMLFactory  {
+    private static final class TestFactory extends POIXMLFactory {
 
+        public TestFactory() {
+            //
+        }
         public POIXMLDocumentPart createDocumentPart(PackageRelationship rel, PackagePart part){
             return new POIXMLDocumentPart(part, rel);
         }
@@ -70,16 +69,16 @@ public class TestPOIXMLDocument extends TestCase
      * Recursively traverse a OOXML document and assert that same logical parts have the same physical instances
      */
     private static void traverse(POIXMLDocumentPart part, HashMap<String,POIXMLDocumentPart> context) throws IOException{
-       context.put(part.getPackageRelationship().getTargetURI().toString(), part);
-       for(POIXMLDocumentPart p : part.getRelations()){
+        context.put(part.getPackageRelationship().getTargetURI().toString(), part);
+        for(POIXMLDocumentPart p : part.getRelations()){
             String uri = p.getPackageRelationship().getTargetURI().toString();
             if (!context.containsKey(uri)) {
-                       traverse(p, context);
-               } else {
+                traverse(p, context);
+            } else {
                 POIXMLDocumentPart prev = context.get(uri);
                 assertSame("Duplicate POIXMLDocumentPart instance for targetURI=" + uri, prev, p);
             }
-       }
+        }
     }
 
     public void assertReadWrite(String path) throws Exception {
@@ -138,4 +137,4 @@ public class TestPOIXMLDocument extends TestCase
         File file = new File(System.getProperty("OOXML.testdata.path"), "WordWithAttachments.docx");
         assertReadWrite(file.getAbsolutePath());
     }
-}
\ No newline at end of file
+}
index 75d87105a6fddb39189d1bee1aff637349562e6e..7d0128618b9ca327fbdcc16b27260cbecf393bd1 100755 (executable)
@@ -32,10 +32,10 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
 /**
  * Test setting extended and custom OOXML properties
  */
-public class TestPOIXMLProperties extends TestCase {
-       POIXMLProperties props;
-       CoreProperties coreProperties;
-       
+public final class TestPOIXMLProperties extends TestCase {
+       private POIXMLProperties _props;
+       private CoreProperties _coreProperties;
+
        public void setUp() throws Exception{
                File sampleFile = new File(
                                System.getProperty("HWPF.testdata.path") +
@@ -46,139 +46,139 @@ public class TestPOIXMLProperties extends TestCase {
                sampleDoc = new XWPFDocument(
                                POIXMLDocument.openPackage(sampleFile.toString())
                );
-               props = sampleDoc.getProperties();
-               coreProperties = props.getCoreProperties();
-               assertNotNull(props);
+               _props = sampleDoc.getProperties();
+               _coreProperties = _props.getCoreProperties();
+               assertNotNull(_props);
        }
-       
-    public void testWorkbookExtendedProperties() throws Exception {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        POIXMLProperties props = workbook.getProperties();
-        assertNotNull(props);
 
-        org.apache.poi.POIXMLProperties.ExtendedProperties properties =
-                props.getExtendedProperties();
+       public void testWorkbookExtendedProperties() {
+               XSSFWorkbook workbook = new XSSFWorkbook();
+               POIXMLProperties props = workbook.getProperties();
+               assertNotNull(props);
+
+               org.apache.poi.POIXMLProperties.ExtendedProperties properties =
+                               props.getExtendedProperties();
 
-        org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
-                ctProps = properties.getUnderlyingProperties();
+               org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
+                               ctProps = properties.getUnderlyingProperties();
 
 
-        String appVersion = "3.5 beta";
-        String application = "POI";
+               String appVersion = "3.5 beta";
+               String application = "POI";
 
-        ctProps.setApplication(application);
-        ctProps.setAppVersion(appVersion);
+               ctProps.setApplication(application);
+               ctProps.setAppVersion(appVersion);
 
-        ctProps = null;
-        properties = null;
-        props = null;
+               ctProps = null;
+               properties = null;
+               props = null;
 
-        XSSFWorkbook newWorkbook =
-                XSSFTestDataSamples.writeOutAndReadBack(workbook);
+               XSSFWorkbook newWorkbook =
+                               XSSFTestDataSamples.writeOutAndReadBack(workbook);
 
-        assertTrue(workbook != newWorkbook);
+               assertTrue(workbook != newWorkbook);
 
 
-        POIXMLProperties newProps = newWorkbook.getProperties();
-        assertNotNull(newProps);
-        org.apache.poi.POIXMLProperties.ExtendedProperties newProperties =
-                newProps.getExtendedProperties();
+               POIXMLProperties newProps = newWorkbook.getProperties();
+               assertNotNull(newProps);
+               org.apache.poi.POIXMLProperties.ExtendedProperties newProperties =
+                               newProps.getExtendedProperties();
 
-        org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
-                newCtProps = newProperties.getUnderlyingProperties();
+               org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
+                               newCtProps = newProperties.getUnderlyingProperties();
 
-        assertEquals(application, newCtProps.getApplication());
-        assertEquals(appVersion, newCtProps.getAppVersion());
+               assertEquals(application, newCtProps.getApplication());
+               assertEquals(appVersion, newCtProps.getAppVersion());
 
 
-    }
+       }
 
 
-    public void testWorkbookCustomProperties() throws Exception {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        POIXMLProperties props = workbook.getProperties();
-        assertNotNull(props);
+       public void testWorkbookCustomProperties() {
+               XSSFWorkbook workbook = new XSSFWorkbook();
+               POIXMLProperties props = workbook.getProperties();
+               assertNotNull(props);
 
-        org.apache.poi.POIXMLProperties.CustomProperties properties =
-                props.getCustomProperties();
+               org.apache.poi.POIXMLProperties.CustomProperties properties =
+                               props.getCustomProperties();
 
-        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
-                ctProps = properties.getUnderlyingProperties();
+               org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
+                               ctProps = properties.getUnderlyingProperties();
 
 
-        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
-                property = ctProps.addNewProperty();
+               org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
+                               property = ctProps.addNewProperty();
 
 
-        String fmtid =
-                "{A1A1A1A1A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1A1A1A1A1}";
-        int pId = 1;
-        String name = "testProperty";
-        String stringValue = "testValue";
+               String fmtid =
+                               "{A1A1A1A1A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1A1A1A1A1}";
+               int pId = 1;
+               String name = "testProperty";
+               String stringValue = "testValue";
 
 
-        property.setFmtid(fmtid);
-        property.setPid(pId);
-        property.setName(name);
-        property.setBstr(stringValue);
+               property.setFmtid(fmtid);
+               property.setPid(pId);
+               property.setName(name);
+               property.setBstr(stringValue);
 
 
-        property = null;
-        ctProps = null;
-        properties = null;
-        props = null;
+               property = null;
+               ctProps = null;
+               properties = null;
+               props = null;
 
-        XSSFWorkbook newWorkbook =
-                XSSFTestDataSamples.writeOutAndReadBack(workbook);
+               XSSFWorkbook newWorkbook =
+                               XSSFTestDataSamples.writeOutAndReadBack(workbook);
 
-        assertTrue(workbook != newWorkbook);
+               assertTrue(workbook != newWorkbook);
 
 
-        POIXMLProperties newProps = newWorkbook.getProperties();
-        assertNotNull(newProps);
-        org.apache.poi.POIXMLProperties.CustomProperties newProperties =
-                newProps.getCustomProperties();
+               POIXMLProperties newProps = newWorkbook.getProperties();
+               assertNotNull(newProps);
+               org.apache.poi.POIXMLProperties.CustomProperties newProperties =
+                               newProps.getCustomProperties();
 
-        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
-                newCtProps = newProperties.getUnderlyingProperties();
+               org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
+                               newCtProps = newProperties.getUnderlyingProperties();
 
-        assertEquals(1, newCtProps.getPropertyArray().length);
+               assertEquals(1, newCtProps.getPropertyArray().length);
 
 
-        org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
-                newpProperty = newCtProps.getPropertyArray()[0];
+               org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
+                               newpProperty = newCtProps.getPropertyArray()[0];
 
-        assertEquals(fmtid, newpProperty.getFmtid());
-        assertEquals(pId, newpProperty.getPid());
-        assertEquals(name, newpProperty.getName());
-        assertEquals(stringValue, newpProperty.getBstr());
+               assertEquals(fmtid, newpProperty.getFmtid());
+               assertEquals(pId, newpProperty.getPid());
+               assertEquals(name, newpProperty.getName());
+               assertEquals(stringValue, newpProperty.getBstr());
 
 
-    }
-    
-    public void testDocumentProperties() {
-               String category = coreProperties.getCategory();
+       }
+
+       public void testDocumentProperties() {
+               String category = _coreProperties.getCategory();
                assertEquals("test", category);
                String contentStatus = "Draft";
-               coreProperties.setContentStatus(contentStatus);
+               _coreProperties.setContentStatus(contentStatus);
                assertEquals("Draft", contentStatus);
-               Date created = coreProperties.getCreated();
+               Date created = _coreProperties.getCreated();
                SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy");
                assertEquals("Mon, Jul 20, '09", formatter.format(created));
-               String creator = coreProperties.getCreator();
+               String creator = _coreProperties.getCreator();
                assertEquals("Paolo Mottadelli", creator);
-               String subject = coreProperties.getSubject();
+               String subject = _coreProperties.getSubject();
                assertEquals("Greetings", subject);
-               String title = coreProperties.getTitle();
+               String title = _coreProperties.getTitle();
                assertEquals("Hello World", title);
-    }
-    
-    public void testGetSetRevision() {
-               String revision = coreProperties.getRevision();
-               assertTrue("Revision number is 1", new Integer(coreProperties.getRevision()).intValue() > 1);
-               coreProperties.setRevision("20");
-               assertEquals("20", coreProperties.getRevision());
-               coreProperties.setRevision("20xx");
-               assertEquals("20", coreProperties.getRevision());
-    }
-}
\ No newline at end of file
+       }
+
+       public void testGetSetRevision() {
+               String revision = _coreProperties.getRevision();
+               assertTrue("Revision number is 1", new Integer(_coreProperties.getRevision()).intValue() > 1);
+               _coreProperties.setRevision("20");
+               assertEquals("20", _coreProperties.getRevision());
+               _coreProperties.setRevision("20xx");
+               assertEquals("20", _coreProperties.getRevision());
+       }
+}
index aa854944914034aa4ae875214b760609b548d8fe..2c0c5b5513983cbd48d8690a1853c710d933e64d 100644 (file)
@@ -24,14 +24,14 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
 
 import junit.framework.TestCase;
 
-public class TestXMLPropertiesTextExtractor extends TestCase {
+public final class TestXMLPropertiesTextExtractor extends TestCase {
        private String dirname;
-       
-       protected void setUp() throws Exception {
+
+       protected void setUp() {
                dirname = System.getProperty("OOXML.testdata.path");
                assertTrue( (new File(dirname)).exists() );
        }
-       
+
        public void testGetFromMainExtractor() throws Exception {
                OPCPackage pkg = OPCPackage.open(
                                (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
@@ -40,15 +40,15 @@ public class TestXMLPropertiesTextExtractor extends TestCase {
 
                XSSFExcelExtractor ext = new XSSFExcelExtractor(wb);
                POIXMLPropertiesTextExtractor textExt = ext.getMetadataTextExtractor();
-               
+
                // Check basics
                assertNotNull(textExt);
                assertTrue(textExt.getText().length() > 0);
-               
+
                // Check some of the content
                String text = textExt.getText();
                String cText = textExt.getCorePropertiesText();
-               
+
                assertTrue(text.contains("LastModifiedBy = Yury Batrakov"));
                assertTrue(cText.contains("LastModifiedBy = Yury Batrakov"));
        }
@@ -58,38 +58,38 @@ public class TestXMLPropertiesTextExtractor extends TestCase {
                                (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
                );
                XSSFWorkbook wb = new XSSFWorkbook(pkg);
-               
+
                POIXMLPropertiesTextExtractor ext = new POIXMLPropertiesTextExtractor(wb);
                ext.getText();
-               
+
                // Now check
                String text = ext.getText();
                String cText = ext.getCorePropertiesText();
-               
+
                assertTrue(text.contains("LastModifiedBy = Yury Batrakov"));
                assertTrue(cText.contains("LastModifiedBy = Yury Batrakov"));
        }
-       
+
        public void testExtended() throws Exception {
                OPCPackage pkg = OPCPackage.open(
                                (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
                );
                XSSFWorkbook wb = new XSSFWorkbook(pkg);
-               
+
                POIXMLPropertiesTextExtractor ext = new POIXMLPropertiesTextExtractor(wb);
                ext.getText();
-               
+
                // Now check
                String text = ext.getText();
                String eText = ext.getExtendedPropertiesText();
-               
+
                assertTrue(text.contains("Application = Microsoft Excel"));
                assertTrue(text.contains("Company = Mera"));
                assertTrue(eText.contains("Application = Microsoft Excel"));
                assertTrue(eText.contains("Company = Mera"));
        }
-       
-       public void testCustom() throws Exception {
+
+       public void testCustom() {
                // TODO!
        }
 }
index c43d951d88aeef8a1810cfe098107c14f0a0bfe4..955bf265c99820d70c868123abd4698c15bc70a1 100755 (executable)
@@ -19,7 +19,13 @@ package org.apache.poi.openxml4j.opc.internal;
 
 import junit.framework.TestCase;
 
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
+import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 
 public final class TestContentTypeManager extends TestCase {
@@ -27,25 +33,21 @@ public final class TestContentTypeManager extends TestCase {
        /**
         * Test the properties part content parsing.
         */
-       public void testContentType() throws Exception {
-               // File originalFile = new File(testCore.getTestRootPath() +
-               // File.separator +
-               // "sample.docx");
-               //
-               // // Retrieves core properties part
-               // Package p = Package.open(originalFile.getAbsolutePath(),
-               // PackageAccess.READ);
-               // PackageRelationship corePropertiesRelationship = p
-               // .getRelationshipsByType(
-               // PackageRelationshipTypes.CORE_PROPERTIES)
-               // .getRelationship(0);
-               // PackagePart coreDocument = p.getPart(corePropertiesRelationship);
-               //
-               // ContentTypeManager ctm = new ZipContentTypeManager(coreDocument
-               // .getInputStream());
-               //
-               // // TODO
-               //fail();
+       public void disabled_testContentType() throws Exception {
+               String filepath =  OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
+
+                // Retrieves core properties part
+                OPCPackage p = OPCPackage.open(filepath, PackageAccess.READ);
+                PackageRelationship corePropertiesRelationship = p
+                .getRelationshipsByType(
+                PackageRelationshipTypes.CORE_PROPERTIES)
+                .getRelationship(0);
+                PackagePart coreDocument = p.getPart(corePropertiesRelationship);
+
+                ContentTypeManager ctm = new ZipContentTypeManager(coreDocument.getInputStream(), p);
+
+                // TODO - finish writing this test
+               fail();
        }
 
        /**
@@ -54,14 +56,10 @@ public final class TestContentTypeManager extends TestCase {
        public void testContentTypeAddition() throws Exception {
                ContentTypeManager ctm = new ZipContentTypeManager(null, null);
 
-               PackagePartName name1 = PackagingURIHelper
-                               .createPartName("/foo/foo.XML");
-               PackagePartName name2 = PackagingURIHelper
-                               .createPartName("/foo/foo2.xml");
-               PackagePartName name3 = PackagingURIHelper
-                               .createPartName("/foo/doc.rels");
-               PackagePartName name4 = PackagingURIHelper
-                               .createPartName("/foo/doc.RELS");
+               PackagePartName name1 = PackagingURIHelper.createPartName("/foo/foo.XML");
+               PackagePartName name2 = PackagingURIHelper.createPartName("/foo/foo2.xml");
+               PackagePartName name3 = PackagingURIHelper.createPartName("/foo/doc.rels");
+               PackagePartName name4 = PackagingURIHelper.createPartName("/foo/doc.RELS");
 
                // Add content types
                ctm.addContentType(name1, "foo-type1");
@@ -81,14 +79,10 @@ public final class TestContentTypeManager extends TestCase {
        public void testContentTypeRemoval() throws Exception {
                ContentTypeManager ctm = new ZipContentTypeManager(null, null);
 
-               PackagePartName name1 = PackagingURIHelper
-                               .createPartName("/foo/foo.xml");
-               PackagePartName name2 = PackagingURIHelper
-                               .createPartName("/foo/foo2.xml");
-               PackagePartName name3 = PackagingURIHelper
-                               .createPartName("/foo/doc.rels");
-               PackagePartName name4 = PackagingURIHelper
-                               .createPartName("/foo/doc.RELS");
+               PackagePartName name1 = PackagingURIHelper.createPartName("/foo/foo.xml");
+               PackagePartName name2 = PackagingURIHelper.createPartName("/foo/foo2.xml");
+               PackagePartName name3 = PackagingURIHelper.createPartName("/foo/doc.rels");
+               PackagePartName name4 = PackagingURIHelper.createPartName("/foo/doc.RELS");
 
                // Add content types
                ctm.addContentType(name1, "foo-type1");
@@ -110,7 +104,7 @@ public final class TestContentTypeManager extends TestCase {
        /**
         * Test the addition then removal of content types in a package.
         */
-       public void testContentTypeRemovalPackage() throws Exception {
+       public void testContentTypeRemovalPackage() {
                // TODO
        }
 }
index af93ba9aa544ceb164ef0a61af32416188ab0298..0cebd764103f8351ae9dafd65a8251de91ccafac 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.ss;
 
 import java.io.File;
@@ -28,12 +29,12 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
 
 import junit.framework.TestCase;
 
-public class TestWorkbookFactory extends TestCase {
+public final class TestWorkbookFactory extends TestCase {
        private File xls;
        private File xlsx;
        private File txt;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                xls = new File(
                                System.getProperty("HSSF.testdata.path") +
                                File.separator + "SampleSS.xls"
@@ -50,17 +51,17 @@ public class TestWorkbookFactory extends TestCase {
                assertTrue(xlsx.exists());
                assertTrue(txt.exists());
        }
-       
+
        public void testCreateNative() throws Exception {
                Workbook wb;
-               
+
                // POIFS -> hssf
                wb = WorkbookFactory.create(
                                new POIFSFileSystem(new FileInputStream(xls))
                );
                assertNotNull(wb);
                assertTrue(wb instanceof HSSFWorkbook);
-               
+
                // Package -> xssf
                wb = WorkbookFactory.create(
                                OPCPackage.open(xlsx.toString())
@@ -68,7 +69,7 @@ public class TestWorkbookFactory extends TestCase {
                assertNotNull(wb);
                assertTrue(wb instanceof XSSFWorkbook);
        }
-               
+
        /**
         * Creates the appropriate kind of Workbook, but
         *  checking the mime magic at the start of the
@@ -76,20 +77,20 @@ public class TestWorkbookFactory extends TestCase {
         */
        public void testCreateGeneric() throws Exception {
                Workbook wb;
-               
+
                // InputStream -> either
                wb = WorkbookFactory.create(
                                new FileInputStream(xls)
                );
                assertNotNull(wb);
                assertTrue(wb instanceof HSSFWorkbook);
-               
+
                wb = WorkbookFactory.create(
                                new FileInputStream(xlsx)
                );
                assertNotNull(wb);
                assertTrue(wb instanceof XSSFWorkbook);
-               
+
                try {
                        wb = WorkbookFactory.create(
                                        new FileInputStream(txt)
@@ -99,4 +100,4 @@ public class TestWorkbookFactory extends TestCase {
                        // Good
                }
        }
-}
\ No newline at end of file
+}
index ab74042927930e2a4f029f91cb72f6fcafe29364..3bbb861f4203c450d19ae27135eaf5f37fee09a8 100755 (executable)
@@ -30,191 +30,150 @@ import org.apache.poi.xssf.usermodel.XSSFMap;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
- * 
  * @author Roberto Manicardi
- *
  */
-public class TestXSSFExportToXML extends TestCase{
-       
-       
-       
-       
-       
-       public void testExportToXML() throws Exception{
-       
-               
-                XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
-                 
-                
-                
-                 MapInfo mapInfo = null;
-                 
-                 for(POIXMLDocumentPart p : wb.getRelations()){
-                         
-                         
-                         if(p instanceof MapInfo){
-                                 mapInfo = (MapInfo) p;
-                                 
-                                 
-                                 XSSFMap map = mapInfo.getXSSFMapById(1);
-                                 XSSFExportToXml exporter = new XSSFExportToXml(map);
-                                 ByteArrayOutputStream os = new ByteArrayOutputStream();
-                                 exporter.exportToXML(os,true);
-                                 String xml = os.toString("UTF-8");
-                                 
-                                 assertNotNull(xml);
-                                 assertTrue(!xml.equals(""));
-                                 
-                                 
-                                 String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
-                                 String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
-                                 String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim();
-                                 String cdl = xml.split("<CDL>")[1].split("</CDL>")[0].trim();
-                                 String durata = xml.split("<DURATA>")[1].split("</DURATA>")[0].trim();
-                                 String argomento = xml.split("<ARGOMENTO>")[1].split("</ARGOMENTO>")[0].trim();
-                                 String progetto = xml.split("<PROGETTO>")[1].split("</PROGETTO>")[0].trim();
-                                 String crediti = xml.split("<CREDITI>")[1].split("</CREDITI>")[0].trim();
-                                 
-                                 assertEquals("ro",docente);
-                                 assertEquals("ro",nome);
-                                 assertEquals("ds",tutor);
-                                 assertEquals("gs",cdl);
-                                 assertEquals("g",durata);
-                                 assertEquals("gvvv",argomento);
-                                 assertEquals("aaaa",progetto);
-                                 assertEquals("aa",crediti);
-                                 
-                         }
-                        
-                 }
-               
-       }
-       
-       
-       public void testExportToXMLInverseOrder() throws Exception{
-               
-       
-               
-                XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
-        
-                 MapInfo mapInfo = null;
-                 
-                 for(POIXMLDocumentPart p : wb.getRelations()){
-                         
-                         
-                         if(p instanceof MapInfo){
-                                 mapInfo = (MapInfo) p;
-                                 
-                                 
-                                 XSSFMap map = mapInfo.getXSSFMapById(1);
-                                 XSSFExportToXml exporter = new XSSFExportToXml(map);
-                                 ByteArrayOutputStream os = new ByteArrayOutputStream();
-                                 exporter.exportToXML(os,true);
-                                 String xml = os.toString("UTF-8");
-                                 
-                                 assertNotNull(xml);
-                                 assertTrue(!xml.equals(""));
-                                 
-                                 String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
-                                 String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
-                                 String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim();
-                                 String cdl = xml.split("<CDL>")[1].split("</CDL>")[0].trim();
-                                 String durata = xml.split("<DURATA>")[1].split("</DURATA>")[0].trim();
-                                 String argomento = xml.split("<ARGOMENTO>")[1].split("</ARGOMENTO>")[0].trim();
-                                 String progetto = xml.split("<PROGETTO>")[1].split("</PROGETTO>")[0].trim();
-                                 String crediti = xml.split("<CREDITI>")[1].split("</CREDITI>")[0].trim();
-                                 
-                                 assertEquals("aa",nome);
-                                 assertEquals("aaaa",docente);
-                                 assertEquals("gvvv",tutor);
-                                 assertEquals("g",cdl);
-                                 assertEquals("gs",durata);
-                                 assertEquals("ds",argomento);
-                                 assertEquals("ro",progetto);
-                                 assertEquals("ro",crediti);
-                                 
-                         }
-                        
-                 }
-                 
-               
-               
-               
-               
+public final class TestXSSFExportToXML extends TestCase {
+
+       public void testExportToXML() throws Exception {
+
+               XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
+
+               for (POIXMLDocumentPart p : wb.getRelations()) {
+
+                       if (!(p instanceof MapInfo)) {
+                               continue;
+                       }
+                       MapInfo mapInfo = (MapInfo) p;
+
+                       XSSFMap map = mapInfo.getXSSFMapById(1);
+                       XSSFExportToXml exporter = new XSSFExportToXml(map);
+                       ByteArrayOutputStream os = new ByteArrayOutputStream();
+                       exporter.exportToXML(os, true);
+                       String xml = os.toString("UTF-8");
+
+                       assertNotNull(xml);
+                       assertTrue(!xml.equals(""));
+
+                       String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
+                       String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
+                       String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim();
+                       String cdl = xml.split("<CDL>")[1].split("</CDL>")[0].trim();
+                       String durata = xml.split("<DURATA>")[1].split("</DURATA>")[0].trim();
+                       String argomento = xml.split("<ARGOMENTO>")[1].split("</ARGOMENTO>")[0].trim();
+                       String progetto = xml.split("<PROGETTO>")[1].split("</PROGETTO>")[0].trim();
+                       String crediti = xml.split("<CREDITI>")[1].split("</CREDITI>")[0].trim();
+
+                       assertEquals("ro", docente);
+                       assertEquals("ro", nome);
+                       assertEquals("ds", tutor);
+                       assertEquals("gs", cdl);
+                       assertEquals("g", durata);
+                       assertEquals("gvvv", argomento);
+                       assertEquals("aaaa", progetto);
+                       assertEquals("aa", crediti);
+               }
        }
-       
-       public void testXPathOrdering() throws Exception{
-               
-               XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
-               
-                MapInfo mapInfo = null;
-                 
-                 for(POIXMLDocumentPart p : wb.getRelations()){
-                         
-                         
-                         if(p instanceof MapInfo){
-                                 mapInfo = (MapInfo) p;
-                                 
-                                 XSSFMap map = mapInfo.getXSSFMapById(1);
-                                 XSSFExportToXml exporter = new XSSFExportToXml(map);
-                                 
-                                 assertEquals(1,exporter.compare("/CORSO/DOCENTE", "/CORSO/NOME"));
-                                 
-                                 assertEquals(-1,exporter.compare("/CORSO/NOME", "/CORSO/DOCENTE"));
-                                 
-                                 
-                         }
-                 }
+
+       public void testExportToXMLInverseOrder() throws Exception {
+
+               XSSFWorkbook wb = XSSFTestDataSamples
+                               .openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
+
+               MapInfo mapInfo = null;
+
+               for (POIXMLDocumentPart p : wb.getRelations()) {
+
+                       if (!(p instanceof MapInfo)) {
+                               continue;
+                       }
+                       mapInfo = (MapInfo) p;
+
+                       XSSFMap map = mapInfo.getXSSFMapById(1);
+                       XSSFExportToXml exporter = new XSSFExportToXml(map);
+                       ByteArrayOutputStream os = new ByteArrayOutputStream();
+                       exporter.exportToXML(os, true);
+                       String xml = os.toString("UTF-8");
+
+                       assertNotNull(xml);
+                       assertTrue(!xml.equals(""));
+
+                       String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
+                       String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
+                       String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim();
+                       String cdl = xml.split("<CDL>")[1].split("</CDL>")[0].trim();
+                       String durata = xml.split("<DURATA>")[1].split("</DURATA>")[0].trim();
+                       String argomento = xml.split("<ARGOMENTO>")[1].split("</ARGOMENTO>")[0].trim();
+                       String progetto = xml.split("<PROGETTO>")[1].split("</PROGETTO>")[0].trim();
+                       String crediti = xml.split("<CREDITI>")[1].split("</CREDITI>")[0].trim();
+
+                       assertEquals("aa", nome);
+                       assertEquals("aaaa", docente);
+                       assertEquals("gvvv", tutor);
+                       assertEquals("g", cdl);
+                       assertEquals("gs", durata);
+                       assertEquals("ds", argomento);
+                       assertEquals("ro", progetto);
+                       assertEquals("ro", crediti);
+               }
        }
-       
-       
-
-       
-       public void testMultiTable() throws Exception{
-               
-               
-               XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings-complex-type.xlsx");         
-                 
-                 for(POIXMLDocumentPart p : wb.getRelations()){
-                         
-                         
-                         if(p instanceof MapInfo){
-                                 MapInfo mapInfo = (MapInfo) p;
-                                 
-                                 XSSFMap map = mapInfo.getXSSFMapById(2);
-                                 
-                                 assertNotNull(map);
-                                 
-                                 XSSFExportToXml exporter = new XSSFExportToXml(map);
-                                 ByteArrayOutputStream os = new ByteArrayOutputStream();
-                                 exporter.exportToXML(os,true);
-                                 String xml = os.toString("UTF-8");
-                                 
-                                 assertNotNull(xml);
-                                 
-                                 String[] regexConditions = {  "<MapInfo",
-                                                                                               "</MapInfo>",
-                                                                                               "<Schema ID=\"1\" Namespace=\"\" SchemaRef=\"\"/>",
-                                                                                               "<Schema ID=\"4\" Namespace=\"\" SchemaRef=\"\"/>",
-                                                                                               "DataBinding",
-                                                                                               "Map Append=\"false\" AutoFit=\"false\" ID=\"1\"",
-                                                                                               "Map Append=\"false\" AutoFit=\"false\" ID=\"5\""
-                                                                                               
-                                                                                    };
-                                 
-                                 for(String condition : regexConditions){
-                                         Pattern pattern = Pattern.compile(condition);
-                                         Matcher matcher = pattern.matcher(xml);
-                                         assertTrue(matcher.find());
-                                 }
-                                 
-                                 
-                         }
-                 }
-               
-               
+
+       public void testXPathOrdering() {
+
+               XSSFWorkbook wb = XSSFTestDataSamples
+                               .openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
+
+               MapInfo mapInfo = null;
+
+               for (POIXMLDocumentPart p : wb.getRelations()) {
+
+                       if (p instanceof MapInfo) {
+                               mapInfo = (MapInfo) p;
+
+                               XSSFMap map = mapInfo.getXSSFMapById(1);
+                               XSSFExportToXml exporter = new XSSFExportToXml(map);
+
+                               assertEquals(1, exporter.compare("/CORSO/DOCENTE", "/CORSO/NOME"));
+                               assertEquals(-1, exporter.compare("/CORSO/NOME", "/CORSO/DOCENTE"));
+                       }
+               }
        }
-       
-       
 
+       public void testMultiTable() throws Exception {
+
+               XSSFWorkbook wb = XSSFTestDataSamples
+                               .openSampleWorkbook("CustomXMLMappings-complex-type.xlsx");
+
+               for (POIXMLDocumentPart p : wb.getRelations()) {
+
+                       if (p instanceof MapInfo) {
+                               MapInfo mapInfo = (MapInfo) p;
+
+                               XSSFMap map = mapInfo.getXSSFMapById(2);
+
+                               assertNotNull(map);
+
+                               XSSFExportToXml exporter = new XSSFExportToXml(map);
+                               ByteArrayOutputStream os = new ByteArrayOutputStream();
+                               exporter.exportToXML(os, true);
+                               String xml = os.toString("UTF-8");
+
+                               assertNotNull(xml);
+
+                               String[] regexConditions = {
+                                               "<MapInfo", "</MapInfo>",
+                                               "<Schema ID=\"1\" Namespace=\"\" SchemaRef=\"\"/>",
+                                               "<Schema ID=\"4\" Namespace=\"\" SchemaRef=\"\"/>",
+                                               "DataBinding",
+                                               "Map Append=\"false\" AutoFit=\"false\" ID=\"1\"",
+                                               "Map Append=\"false\" AutoFit=\"false\" ID=\"5\"",
+                               };
+
+                               for (String condition : regexConditions) {
+                                       Pattern pattern = Pattern.compile(condition);
+                                       Matcher matcher = pattern.matcher(xml);
+                                       assertTrue(matcher.find());
+                               }
+                       }
+               }
+       }
 }
index 191b3283cb8399bc2753da3fa35d866eb789cc22..32ff49c9f7930fe73ca81b4699887d5845a540b1 100755 (executable)
@@ -24,9 +24,9 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
 import junit.framework.TestCase;
 
 
-public class TestCalculationChain extends TestCase {
+public final class TestCalculationChain extends TestCase {
 
-    public void test46535() throws Exception {
+    public void test46535() {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("46535.xlsx");
 
         CalculationChain chain = wb.getCalculationChain();
@@ -42,7 +42,7 @@ public class TestCalculationChain extends TestCase {
         assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
         cell.setCellFormula(null);
 
-        //the count of items is less by one 
+        //the count of items is less by one
         c = chain.getCTCalcChain().getCArray(0);
         int cnt2 =  chain.getCTCalcChain().getCArray().length;
         assertEquals(cnt - 1, cnt2);
@@ -56,4 +56,4 @@ public class TestCalculationChain extends TestCase {
     }
 
 
-}
\ No newline at end of file
+}
index e10711e6962bfb3597c6b63b56c4f834a635c659..f4564e4d21095fc2c11f9f2629245110ee9c2a71 100755 (executable)
@@ -30,11 +30,10 @@ import junit.framework.TestCase;
 /**
  * @author Roberto Manicardi
  */
-public class TestMapInfo extends TestCase {
+public final class TestMapInfo extends TestCase {
 
 
-    public void testMapInfoExists() throws Exception {
-
+    public void testMapInfoExists() {
 
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
 
@@ -72,13 +71,7 @@ public class TestMapInfo extends TestCase {
             }
 
         }
-
-
         assertNotNull(mapInfo);
         assertNotNull(singleXMLCells);
-
-
     }
-
-
 }
index 7aebf263854e17a88dc791d1df01d8751fe5d5a2..46b0fd802c5743b594c33e359e0d844ec8cb0545 100644 (file)
@@ -25,10 +25,10 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
 
 import junit.framework.TestCase;
 
-public class TestStylesTable extends TestCase {
+public final class TestStylesTable extends TestCase {
        private File xml;
-       
-       protected void setUp() throws Exception {
+
+       protected void setUp() {
                xml = new File(
                                System.getProperty("HSSF.testdata.path") +
                                File.separator + "Formatting.xlsx"
@@ -36,92 +36,92 @@ public class TestStylesTable extends TestCase {
                assertTrue(xml.exists());
        }
 
-       public void testCreateNew() throws Exception {
+       public void testCreateNew() {
                StylesTable st = new StylesTable();
-               
+
                // Check defaults
                assertNotNull(st.getCTStylesheet());
                assertEquals(1, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(0, st._getNumberFormatSize());
        }
-       
-       public void testCreateSaveLoad() throws Exception {
-        XSSFWorkbook wb = new XSSFWorkbook();
-        StylesTable st = wb.getStylesSource();
+
+       public void testCreateSaveLoad() {
+               XSSFWorkbook wb = new XSSFWorkbook();
+               StylesTable st = wb.getStylesSource();
 
                assertNotNull(st.getCTStylesheet());
                assertEquals(1, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(0, st._getNumberFormatSize());
-               
+
                st = XSSFTestDataSamples.writeOutAndReadBack(wb).getStylesSource();
 
-        assertNotNull(st.getCTStylesheet());
+               assertNotNull(st.getCTStylesheet());
                assertEquals(1, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(0, st._getNumberFormatSize());
        }
-       
+
        public void testLoadExisting() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
                assertNotNull(workbook.getStylesSource());
-               
+
                StylesTable st = workbook.getStylesSource();
-               
+
                doTestExisting(st);
        }
        public void testLoadSaveLoad() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
                assertNotNull(workbook.getStylesSource());
-               
+
                StylesTable st = workbook.getStylesSource();
                doTestExisting(st);
-               
+
                st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource();
                doTestExisting(st);
        }
-       public void doTestExisting(StylesTable st) throws Exception {
+       public void doTestExisting(StylesTable st) {
                // Check contents
                assertNotNull(st.getCTStylesheet());
                assertEquals(11, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(8, st._getNumberFormatSize());
-               
+
                assertEquals(2, st.getFonts().size());
                assertEquals(2, st.getFills().size());
                assertEquals(1, st.getBorders().size());
-               
+
                assertEquals("yyyy/mm/dd", st.getNumberFormatAt(165));
                assertEquals("yy/mm/dd", st.getNumberFormatAt(167));
-               
+
                assertNotNull(st.getStyleAt(0));
                assertNotNull(st.getStyleAt(1));
                assertNotNull(st.getStyleAt(2));
-               
+
                assertEquals(0, st.getStyleAt(0).getDataFormat());
                assertEquals(14, st.getStyleAt(1).getDataFormat());
                assertEquals(0, st.getStyleAt(2).getDataFormat());
                assertEquals(165, st.getStyleAt(3).getDataFormat());
-               
+
                assertEquals("yyyy/mm/dd", st.getStyleAt(3).getDataFormatString());
        }
-       
-       public void testPopulateNew() throws Exception {
+
+       public void testPopulateNew() {
                XSSFWorkbook wb = new XSSFWorkbook();
-        StylesTable st = wb.getStylesSource();
-               
+               StylesTable st = wb.getStylesSource();
+
                assertNotNull(st.getCTStylesheet());
                assertEquals(1, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(0, st._getNumberFormatSize());
-               
+
                int nf1 = st.putNumberFormat("yyyy-mm-dd");
                int nf2 = st.putNumberFormat("yyyy-mm-DD");
                assertEquals(nf1, st.putNumberFormat("yyyy-mm-dd"));
-               
+
                st.putStyle(new XSSFCellStyle(st));
-               
+
                // Save and re-load
                st = XSSFTestDataSamples.writeOutAndReadBack(wb).getStylesSource();
 
@@ -129,31 +129,31 @@ public class TestStylesTable extends TestCase {
                assertEquals(2, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(2, st._getNumberFormatSize());
-               
+
                assertEquals("yyyy-mm-dd", st.getNumberFormatAt(nf1));
                assertEquals(nf1, st.putNumberFormat("yyyy-mm-dd"));
                assertEquals(nf2, st.putNumberFormat("yyyy-mm-DD"));
        }
-       
+
        public void testPopulateExisting() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
                assertNotNull(workbook.getStylesSource());
-               
+
                StylesTable st = workbook.getStylesSource();
                assertEquals(11, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(8, st._getNumberFormatSize());
-               
+
                int nf1 = st.putNumberFormat("YYYY-mm-dd");
                int nf2 = st.putNumberFormat("YYYY-mm-DD");
                assertEquals(nf1, st.putNumberFormat("YYYY-mm-dd"));
-               
+
         st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource();
 
                assertEquals(11, st._getXfsSize());
                assertEquals(1, st._getStyleXfsSize());
                assertEquals(10, st._getNumberFormatSize());
-               
+
                assertEquals("YYYY-mm-dd", st.getNumberFormatAt(nf1));
                assertEquals(nf1, st.putNumberFormat("YYYY-mm-dd"));
                assertEquals(nf2, st.putNumberFormat("YYYY-mm-DD"));
index 51b0d02af06038e68791a2278f7e7da7cdbc81c8..564f2dee8cad826c6e3751be1126c3a329ca1681 100755 (executable)
@@ -37,7 +37,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());
@@ -65,7 +65,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));
@@ -76,7 +76,7 @@ public final class TestSheetHiding extends TestCase {
      * Turn the sheet with none hidden into the one with
      *  one hidden
      */
-    public void testHide() throws Exception {
+    public void testHide() {
         wbU.setSheetHidden(0, true);
         assertTrue(wbU.isSheetHidden(0));
         assertFalse(wbU.isSheetHidden(1));
@@ -89,7 +89,7 @@ public final class TestSheetHiding extends TestCase {
      * Turn the sheet with one hidden into the one with
      *  none hidden
      */
-    public void testUnHide() throws Exception {
+    public void testUnHide() {
         wbH.setSheetHidden(0, false);
         assertFalse(wbH.isSheetHidden(0));
         assertFalse(wbH.isSheetHidden(1));
index ed4953b2cd628daee45f0f939b46057c2a65cf75..e98676114cf307611fa7b9a76299362148265f56 100644 (file)
@@ -45,7 +45,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
      * Named ranges had the right reference, but
      *  the wrong sheet name
      */
-    public void test45430() throws Exception {
+    public void test45430() {
         XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("45430.xlsx");
         assertFalse(wb.isMacroEnabled());
         assertEquals(3, wb.getNumberOfNames());
index a5abde4adc1494e9badb4813ed810cc5dd26f8b9..194a983e2512e5f9b7e23ddc985328b1bdd2f0dd 100755 (executable)
@@ -35,7 +35,7 @@ public final class TestXSSFCell extends BaseTestCell {
      * Bug 47026: trouble changing cell type when workbook doesn't contain
      * Shared String Table
      */
-    public void test47026_1() throws Exception {
+    public void test47026_1() {
         Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm");
         Sheet sheet = source.getSheetAt(0);
         Row row = sheet.getRow(0);
@@ -44,7 +44,7 @@ public final class TestXSSFCell extends BaseTestCell {
         cell.setCellValue("456");
     }
 
-    public void test47026_2() throws Exception {
+    public void test47026_2() {
         Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm");
         Sheet sheet = source.getSheetAt(0);
         Row row = sheet.getRow(0);
@@ -60,7 +60,7 @@ public final class TestXSSFCell extends BaseTestCell {
      * Some programs, for example, Microsoft Excel Driver for .xlsx insert inline string
      * instead of using the shared string table. See bug 47206
      */
-    public void testInlineString() throws Exception {
+    public void testInlineString() {
         XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("xlsx-jdbc.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
         XSSFRow row = sheet.getRow(1);
@@ -84,7 +84,7 @@ public final class TestXSSFCell extends BaseTestCell {
     /**
      *  Bug 47278 -  xsi:nil attribute for <t> tag caused Excel 2007 to fail to open workbook
      */
-    public void test47278() throws Exception {
+    public void test47278() {
         XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.createWorkbook();
         XSSFSheet sheet = wb.createSheet();
         XSSFRow row = sheet.createRow(0);
@@ -105,5 +105,4 @@ public final class TestXSSFCell extends BaseTestCell {
         assertEquals(0, sst.getCount());
         assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_1.getCellType());
     }
-    
-}
\ No newline at end of file
+}
index 0e7b8be8070ea552a8187a29a75a69607c18bf8a..d290b4e1ced1b39d35416222570c0e9c57b95777 100644 (file)
@@ -46,9 +46,9 @@ public class TestXSSFCellStyle extends TestCase {
        @Override
        protected void setUp() {
                stylesTable = new StylesTable();
-               
+
                ctStylesheet = stylesTable.getCTStylesheet();
-               
+
                ctBorderA = CTBorder.Factory.newInstance();
                XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
                long borderId = stylesTable.putBorder(borderA);
@@ -71,7 +71,7 @@ public class TestXSSFCellStyle extends TestCase {
                cellStyleXf.setBorderId(1);
                cellStyleXf.setFillId(1);
                cellStyleXf.setFontId(1);
-               
+
                cellXfs = ctStylesheet.addNewCellXfs();
                cellXf = cellXfs.addNewXf();
                cellXf.setXfId(1);
@@ -419,7 +419,7 @@ public class TestXSSFCellStyle extends TestCase {
         assertNull(cellStyle.getFillBackgroundXSSFColor());
         assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
        }
-       
+
        public void testDefaultStyles() {
 
                XSSFWorkbook wb1 = new XSSFWorkbook();
@@ -445,7 +445,7 @@ public class TestXSSFCellStyle extends TestCase {
         assertEquals(style2.getBorderRight(), style1.getBorderRight());
         assertEquals(style2.getBorderTop(), style1.getBorderTop());
        }
-       
+
 
        public void testGetFillForegroundColor() {
 
@@ -481,7 +481,7 @@ public class TestXSSFCellStyle extends TestCase {
             assertEquals(4, styles.getFills().size());
         }
        }
-       
+
        public void testGetFillPattern() {
 
         assertEquals(CellStyle.NO_FILL, cellStyle.getFillPattern());
@@ -585,13 +585,13 @@ public class TestXSSFCellStyle extends TestCase {
        /**
         * Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
         */
-       public void testCloneStyleSameWB() throws Exception {
+       public void testCloneStyleSameWB() {
                // TODO
        }
        /**
         * Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
         */
-       public void testCloneStyleDiffWB() throws Exception {
+       public void testCloneStyleDiffWB() {
                // TODO
        }
 }
index 7cf6e4a846ff1761f53f01decae7858ecc5b851a..c64aa405e0793f8436edbe145c468181756295d5 100644 (file)
@@ -140,7 +140,7 @@ public class TestXSSFComment extends TestCase {
      *  file, save, load, and still see them
      * @throws Exception
      */
-    public void testCreateSave() throws Exception {
+    public void testCreateSave() {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet s1 = wb.createSheet();
         Row r1 = s1.createRow(0);
index 95cc8ac06636d9cea38986704842431668640608..6596edaf5a25b4bbfa6070a4a2dc71a4681426d2 100644 (file)
@@ -27,14 +27,15 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
  */
 public final class TestXSSFDataFormat extends BaseTestDataFormat {
 
-    @Override
-    protected ITestDataProvider getTestDataProvider(){
-        return XSSFITestDataProvider.getInstance();
-    }
+       @Override
+       protected ITestDataProvider getTestDataProvider() {
+               return XSSFITestDataProvider.getInstance();
+       }
+
        /**
-     * Test setting and getting boolean values.
-     */
-    public void testBuiltinFormats() throws Exception {
-        baseBuiltinFormats();
-    }
+        * Test setting and getting boolean values.
+        */
+       public void testBuiltinFormats() {
+               baseBuiltinFormats();
+       }
 }
index ada54b0d8ea5a663417ab9c444dac9f01da83788..e31e42f7530c61b4df71454696266b6ba4ec8660 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.xwpf;
 
 import java.io.File;
@@ -27,13 +28,13 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFRelation;
 
-public class TestXWPFDocument extends TestCase {
+public final class TestXWPFDocument extends TestCase {
        private File sampleFile;
        private File complexFile;
 
        protected void setUp() throws Exception {
                super.setUp();
-               
+
                sampleFile = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "sample.docx"
@@ -42,14 +43,14 @@ public class TestXWPFDocument extends TestCase {
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "IllustrativeCases.docx"
                );
-               
+
                assertTrue(sampleFile.exists());
                assertTrue(complexFile.exists());
        }
 
        public void testContainsMainContentType() throws Exception {
                OPCPackage pack = POIXMLDocument.openPackage(sampleFile.toString());
-               
+
                boolean found = false;
                for(PackagePart part : pack.getParts()) {
                        if(part.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
@@ -63,16 +64,16 @@ public class TestXWPFDocument extends TestCase {
        public void testOpen() throws Exception {
                POIXMLDocument.openPackage(sampleFile.toString());
                POIXMLDocument.openPackage(complexFile.toString());
-               
+
                new XWPFDocument(
                                POIXMLDocument.openPackage(sampleFile.toString())
                );
                new XWPFDocument(
                                POIXMLDocument.openPackage(complexFile.toString())
                );
-               
+
                XWPFDocument xml;
-               
+
                // Simple file
                xml = new XWPFDocument(
                                POIXMLDocument.openPackage(sampleFile.toString())
@@ -81,7 +82,7 @@ public class TestXWPFDocument extends TestCase {
                assertNotNull(xml.getDocument());
                assertNotNull(xml.getDocument().getBody());
                assertNotNull(xml.getStyle());
-               
+
                // Complex file
                xml = new XWPFDocument(
                                POIXMLDocument.openPackage(complexFile.toString())
@@ -90,42 +91,42 @@ public class TestXWPFDocument extends TestCase {
                assertNotNull(xml.getDocument().getBody());
                assertNotNull(xml.getStyle());
        }
-       
+
        public void testMetadataBasics() throws Exception {
                XWPFDocument xml = new XWPFDocument(
                                POIXMLDocument.openPackage(sampleFile.toString())
                );
                assertNotNull(xml.getProperties().getCoreProperties());
                assertNotNull(xml.getProperties().getExtendedProperties());
-               
+
                assertEquals("Microsoft Office Word", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
                assertEquals(1315, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
                assertEquals(10, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());
-               
+
                assertEquals(null, xml.getProperties().getCoreProperties().getTitle());
                assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
        }
-       
+
        public void testMetadataComplex() throws Exception {
                XWPFDocument xml = new XWPFDocument(
                                POIXMLDocument.openPackage(complexFile.toString())
                );
                assertNotNull(xml.getProperties().getCoreProperties());
                assertNotNull(xml.getProperties().getExtendedProperties());
-               
+
                assertEquals("Microsoft Office Outlook", xml.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
                assertEquals(5184, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getCharacters());
                assertEquals(0, xml.getProperties().getExtendedProperties().getUnderlyingProperties().getLines());
-               
+
                assertEquals(" ", xml.getProperties().getCoreProperties().getTitle());
                assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
        }
 
-    public void testWorkbookProperties() throws Exception {
-        XWPFDocument doc = new XWPFDocument();
-        POIXMLProperties props = doc.getProperties();
-        assertNotNull(props);
-        assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
-    }
+       public void testWorkbookProperties() {
+               XWPFDocument doc = new XWPFDocument();
+               POIXMLProperties props = doc.getProperties();
+               assertNotNull(props);
+               assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
+       }
 
 }
index b55b01951bcf74da3cd2c153de0b2666de77f47b..ef5d5868a06cc4772731dcdd870e5c9cece0e4cf 100644 (file)
@@ -33,46 +33,46 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
        private XWPFDocument footer;
        private XWPFDocument oddEven;
        private XWPFDocument diffFirst;
-       
+
        protected void setUp() throws Exception {
                super.setUp();
                File file;
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "NoHeadFoot.docx"
                );
                assertTrue(file.exists());
                noHeader = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "ThreeColHead.docx"
                );
                assertTrue(file.exists());
                header = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "SimpleHeadThreeColFoot.docx"
                );
                assertTrue(file.exists());
                headerFooter = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "FancyFoot.docx"
                );
                assertTrue(file.exists());
                footer = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "PageSpecificHeadFoot.docx"
                );
                assertTrue(file.exists());
                oddEven = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
-               
+
                file = new File(
                                System.getProperty("HWPF.testdata.path") +
                                File.separator + "DiffFirstPageHeadFoot.docx"
@@ -80,72 +80,72 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
                assertTrue(file.exists());
                diffFirst = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
        }
-       
-       public void testPolicy() throws Exception {
+
+       public void testPolicy() {
                XWPFHeaderFooterPolicy policy;
-               
+
                policy = noHeader.getHeaderFooterPolicy();
                assertNull(policy.getDefaultHeader());
                assertNull(policy.getDefaultFooter());
-               
+
                assertNull(policy.getHeader(1));
                assertNull(policy.getHeader(2));
                assertNull(policy.getHeader(3));
                assertNull(policy.getFooter(1));
                assertNull(policy.getFooter(2));
                assertNull(policy.getFooter(3));
-               
-               
+
+
                policy = header.getHeaderFooterPolicy();
                assertNotNull(policy.getDefaultHeader());
                assertNull(policy.getDefaultFooter());
-               
+
                assertEquals(policy.getDefaultHeader(), policy.getHeader(1));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(2));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(3));
                assertNull(policy.getFooter(1));
                assertNull(policy.getFooter(2));
                assertNull(policy.getFooter(3));
-               
-               
+
+
                policy = footer.getHeaderFooterPolicy();
                assertNull(policy.getDefaultHeader());
                assertNotNull(policy.getDefaultFooter());
-               
+
                assertNull(policy.getHeader(1));
                assertNull(policy.getHeader(2));
                assertNull(policy.getHeader(3));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(1));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(2));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(3));
-               
-               
+
+
                policy = headerFooter.getHeaderFooterPolicy();
                assertNotNull(policy.getDefaultHeader());
                assertNotNull(policy.getDefaultFooter());
-               
+
                assertEquals(policy.getDefaultHeader(), policy.getHeader(1));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(2));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(3));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(1));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(2));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(3));
-               
-               
+
+
                policy = oddEven.getHeaderFooterPolicy();
                assertNotNull(policy.getDefaultHeader());
                assertNotNull(policy.getDefaultFooter());
                assertNotNull(policy.getEvenPageHeader());
                assertNotNull(policy.getEvenPageFooter());
-               
+
                assertEquals(policy.getDefaultHeader(), policy.getHeader(1));
                assertEquals(policy.getEvenPageHeader(), policy.getHeader(2));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(3));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(1));
                assertEquals(policy.getEvenPageFooter(), policy.getFooter(2));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(3));
-               
-               
+
+
                policy = diffFirst.getHeaderFooterPolicy();
                assertNotNull(policy.getDefaultHeader());
                assertNotNull(policy.getDefaultFooter());
@@ -153,7 +153,7 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
                assertNotNull(policy.getFirstPageFooter());
                assertNull(policy.getEvenPageHeader());
                assertNull(policy.getEvenPageFooter());
-               
+
                assertEquals(policy.getFirstPageHeader(), policy.getHeader(1));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(2));
                assertEquals(policy.getDefaultHeader(), policy.getHeader(3));
@@ -161,32 +161,32 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
                assertEquals(policy.getDefaultFooter(), policy.getFooter(2));
                assertEquals(policy.getDefaultFooter(), policy.getFooter(3));
        }
-       
-       public void testContents() throws Exception {
+
+       public void testContents() {
                XWPFHeaderFooterPolicy policy;
-               
+
                // Test a few simple bits off a simple header
                policy = diffFirst.getHeaderFooterPolicy();
-               
+
                assertEquals(
                        "I am the header on the first page, and I" + '\u2019' + "m nice and simple\n",
                        policy.getFirstPageHeader().getText()
                );
                assertEquals(
-                               "First header column!\tMid header\tRight header!\n", 
+                               "First header column!\tMid header\tRight header!\n",
                                policy.getDefaultHeader().getText()
                );
-               
-               
+
+
                // And a few bits off a more complex header
                policy = oddEven.getHeaderFooterPolicy();
-               
+
                assertEquals(
                        "[]ODD Page Header text\n\n",
                        policy.getDefaultHeader().getText()
                );
                assertEquals(
-                       "[This is an Even Page, with a Header]\n\n", 
+                       "[This is an Even Page, with a Header]\n\n",
                        policy.getEvenPageHeader().getText()
                );
        }
index 43932b947284f9bb6e730d2b299f0ecaac27c747..e09da018d2071871e171a93e39f5a45dbc30dc08 100644 (file)
@@ -111,8 +111,7 @@ public final class NewOleFile extends RandomAccessFile
       {
       }
     }
-    protected int[] readChain(int[] blockChain, int startBlock) throws IOException
-    {
+    protected int[] readChain(int[] blockChain, int startBlock) {
 
         int[] tempChain = new int[blockChain.length];
         tempChain[0] = startBlock;
index 06bea56a6086ec6c087239b097ee32bfb37e0c2f..483762484dedc6e518df7263ad980ee71e536065 100644 (file)
@@ -114,7 +114,7 @@ public final class HDGFDiagram extends POIDocument {
         * Prints out some simple debug on the base contents of the file.
         * @see org.apache.poi.hdgf.dev.VSDDumper
         */
-       public void debug() throws IOException {
+       public void debug() {
                System.err.println("Trailer is at " + trailerPointer.getOffset());
                System.err.println("Trailer has type " + trailerPointer.getType());
                System.err.println("Trailer has length " + trailerPointer.getLength());
index a8dbfa2a9353052d2e586cebc1dd446cbd25b8ff..d4e32aa0e04f5c5cb07b699b7a2c08df2b80aeaa 100644 (file)
@@ -32,8 +32,8 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
- * This class can be used to extract text from a PowerPoint file.
- *  Can optionally also get the notes from one.
+ * This class can be used to extract text from a PowerPoint file. Can optionally
+ * also get the notes from one.
  *
  * @author Nick Burch
  */
@@ -42,68 +42,74 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
        private SlideShow _show;
        private Slide[] _slides;
 
-       private boolean slidesByDefault = true;
-       private boolean notesByDefault = false;
-       private boolean commentsByDefault = false;
-
-  /**
-   * Basic extractor. Returns all the text, and optionally all the notes
-   */
-  public static void main(String args[]) throws IOException
-  {
-       if(args.length < 1) {
-               System.err.println("Useage:");
-               System.err.println("\tPowerPointExtractor [-notes] <file>");
-               System.exit(1);
-       }
+       private boolean _slidesByDefault = true;
+       private boolean _notesByDefault = false;
+       private boolean _commentsByDefault = false;
 
-       boolean notes = false;
-       boolean comments = false;
-       String file;
-       if(args.length > 1) {
-               notes = true;
-               file = args[1];
-               if(args.length > 2) {
-                       comments = true;
+       /**
+        * Basic extractor. Returns all the text, and optionally all the notes
+        */
+       public static void main(String args[]) throws IOException {
+               if (args.length < 1) {
+                       System.err.println("Useage:");
+                       System.err.println("\tPowerPointExtractor [-notes] <file>");
+                       System.exit(1);
+               }
+
+               boolean notes = false;
+               boolean comments = false;
+               String file;
+               if (args.length > 1) {
+                       notes = true;
+                       file = args[1];
+                       if (args.length > 2) {
+                               comments = true;
+                       }
+               } else {
+                       file = args[0];
                }
-       } else {
-               file = args[0];
-       }
 
-       PowerPointExtractor ppe = new PowerPointExtractor(file);
-       System.out.println(ppe.getText(true,notes,comments));
-  }
+               PowerPointExtractor ppe = new PowerPointExtractor(file);
+               System.out.println(ppe.getText(true, notes, comments));
+       }
 
        /**
         * Creates a PowerPointExtractor, from a file
+        *
         * @param fileName The name of the file to extract from
         */
        public PowerPointExtractor(String fileName) throws IOException {
                this(new FileInputStream(fileName));
        }
+
        /**
         * Creates a PowerPointExtractor, from an Input Stream
+        *
         * @param iStream The input stream containing the PowerPoint document
         */
        public PowerPointExtractor(InputStream iStream) throws IOException {
                this(new POIFSFileSystem(iStream));
        }
+
        /**
         * Creates a PowerPointExtractor, from an open POIFSFileSystem
+        *
         * @param fs the POIFSFileSystem containing the PowerPoint document
         */
        public PowerPointExtractor(POIFSFileSystem fs) throws IOException {
                this(new HSLFSlideShow(fs));
        }
+
        public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
                this(new HSLFSlideShow(dir, fs));
        }
 
        /**
         * Creates a PowerPointExtractor, from a HSLFSlideShow
+        *
         * @param ss the HSLFSlideShow to extract text from
         */
-       public PowerPointExtractor(HSLFSlideShow ss) throws IOException {
+       public PowerPointExtractor(HSLFSlideShow ss) {
                super(ss);
                _hslfshow = ss;
                _show = new SlideShow(_hslfshow);
@@ -111,159 +117,157 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
        }
 
        /**
-        * Should a call to getText() return slide text?
-        * Default is yes
+        * Should a call to getText() return slide text? Default is yes
         */
        public void setSlidesByDefault(boolean slidesByDefault) {
-               this.slidesByDefault = slidesByDefault;
+               this._slidesByDefault = slidesByDefault;
        }
+
        /**
-        * Should a call to getText() return notes text?
-        * Default is no
+        * Should a call to getText() return notes text? Default is no
         */
        public void setNotesByDefault(boolean notesByDefault) {
-               this.notesByDefault = notesByDefault;
+               this._notesByDefault = notesByDefault;
        }
+
        /**
-        * Should a call to getText() return comments text?
-        * Default is no
+        * Should a call to getText() return comments text? Default is no
         */
        public void setCommentsByDefault(boolean commentsByDefault) {
-               this.commentsByDefault = commentsByDefault;
+               this._commentsByDefault = commentsByDefault;
        }
 
        /**
-        * Fetches all the slide text from the slideshow,
-        *  but not the notes, unless you've called
-        *  setSlidesByDefault() and setNotesByDefault()
-        *  to change this
+        * Fetches all the slide text from the slideshow, but not the notes, unless
+        * you've called setSlidesByDefault() and setNotesByDefault() to change this
         */
        public String getText() {
-               return getText(slidesByDefault,notesByDefault,commentsByDefault);
+               return getText(_slidesByDefault, _notesByDefault, _commentsByDefault);
        }
 
        /**
         * Fetches all the notes text from the slideshow, but not the slide text
         */
        public String getNotes() {
-               return getText(false,true);
+               return getText(false, true);
        }
 
-    public List<OLEShape> getOLEShapes() {
-        List<OLEShape> list = new ArrayList<OLEShape>();
-
-        for (int i = 0; i < _slides.length; i++) {
-            Slide slide = _slides[i];
-
-            Shape[] shapes = slide.getShapes();
-            for (int j = 0; j < shapes.length; j++) {
-                if (shapes[j] instanceof OLEShape) {
-                    list.add((OLEShape) shapes[j]);
-                }
-            }
-        }
-
-        return list;
-    }
-
-    /**
-   * Fetches text from the slideshow, be it slide text or note text.
-   * Because the final block of text in a TextRun normally have their
-   *  last \n stripped, we add it back
-   * @param getSlideText fetch slide text
-   * @param getNoteText fetch note text
-   */
-  public String getText(boolean getSlideText, boolean getNoteText) {
-         return getText(getSlideText, getNoteText, commentsByDefault);
-  }
-  public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText) {
-       StringBuffer ret = new StringBuffer();
-
-       if(getSlideText) {
-               for(int i=0; i<_slides.length; i++) {
+       public List<OLEShape> getOLEShapes() {
+               List<OLEShape> list = new ArrayList<OLEShape>();
+
+               for (int i = 0; i < _slides.length; i++) {
                        Slide slide = _slides[i];
 
-                       // Slide header, if set
-                       HeadersFooters hf = slide.getHeadersFooters();
-                       if(hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
-                               ret.append(hf.getHeaderText() + "\n");
+                       Shape[] shapes = slide.getShapes();
+                       for (int j = 0; j < shapes.length; j++) {
+                               if (shapes[j] instanceof OLEShape) {
+                                       list.add((OLEShape) shapes[j]);
+                               }
                        }
+               }
+
+               return list;
+       }
+
+       /**
+        * Fetches text from the slideshow, be it slide text or note text. Because
+        * the final block of text in a TextRun normally have their last \n
+        * stripped, we add it back
+        *
+        * @param getSlideText fetch slide text
+        * @param getNoteText fetch note text
+        */
+       public String getText(boolean getSlideText, boolean getNoteText) {
+               return getText(getSlideText, getNoteText, _commentsByDefault);
+       }
+
+       public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText) {
+               StringBuffer ret = new StringBuffer();
 
-                       // Slide text
-                       TextRun[] runs = slide.getTextRuns();
-                       for(int j=0; j<runs.length; j++) {
-                               TextRun run = runs[j];
-                               if(run != null) {
-                                       String text = run.getText();
-                                       ret.append(text);
-                                       if(! text.endsWith("\n")) {
-                                               ret.append("\n");
+               if (getSlideText) {
+                       for (int i = 0; i < _slides.length; i++) {
+                               Slide slide = _slides[i];
+
+                               // Slide header, if set
+                               HeadersFooters hf = slide.getHeadersFooters();
+                               if (hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
+                                       ret.append(hf.getHeaderText() + "\n");
+                               }
+
+                               // Slide text
+                               TextRun[] runs = slide.getTextRuns();
+                               for (int j = 0; j < runs.length; j++) {
+                                       TextRun run = runs[j];
+                                       if (run != null) {
+                                               String text = run.getText();
+                                               ret.append(text);
+                                               if (!text.endsWith("\n")) {
+                                                       ret.append("\n");
+                                               }
                                        }
                                }
-                       }
 
-                       // Slide footer, if set
-                       if(hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
-                               ret.append(hf.getFooterText() + "\n");
-                       }
+                               // Slide footer, if set
+                               if (hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
+                                       ret.append(hf.getFooterText() + "\n");
+                               }
 
-                       // Comments, if requested and present
-                       if(getCommentText) {
-                               Comment[] comments = slide.getComments();
-                               for(int j=0; j<comments.length; j++) {
-                                       ret.append(
-                                                       comments[j].getAuthor() +
-                                                       " - " +
-                                                       comments[j].getText() +
-                                                       "\n"
-                                       );
+                               // Comments, if requested and present
+                               if (getCommentText) {
+                                       Comment[] comments = slide.getComments();
+                                       for (int j = 0; j < comments.length; j++) {
+                                               ret.append(comments[j].getAuthor() + " - " + comments[j].getText() + "\n");
+                                       }
                                }
                        }
+                       if (getNoteText) {
+                               ret.append("\n");
+                       }
                }
-               if(getNoteText) {
-                       ret.append("\n");
-               }
-       }
 
-       if(getNoteText) {
-               // Not currently using _notes, as that can have the notes of
-               //  master sheets in. Grab Slide list, then work from there,
-               //  but ensure no duplicates
-               HashSet seenNotes = new HashSet();
-               HeadersFooters hf = _show.getNotesHeadersFooters();
-
-               for(int i=0; i<_slides.length; i++) {
-                       Notes notes = _slides[i].getNotesSheet();
-                       if(notes == null) { continue; }
-                       Integer id = new Integer(notes._getSheetNumber());
-                       if(seenNotes.contains(id)) { continue; }
-                       seenNotes.add(id);
-
-                       // Repeat the Notes header, if set
-                       if(hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
-                               ret.append(hf.getHeaderText() + "\n");
-                       }
+               if (getNoteText) {
+                       // Not currently using _notes, as that can have the notes of
+                       // master sheets in. Grab Slide list, then work from there,
+                       // but ensure no duplicates
+                       HashSet seenNotes = new HashSet();
+                       HeadersFooters hf = _show.getNotesHeadersFooters();
 
-                       // Notes text
-                       TextRun[] runs = notes.getTextRuns();
-                       if(runs != null && runs.length > 0) {
-                               for(int j=0; j<runs.length; j++) {
-                                       TextRun run = runs[j];
-                                       String text = run.getText();
-                                       ret.append(text);
-                                       if(! text.endsWith("\n")) {
-                                               ret.append("\n");
+                       for (int i = 0; i < _slides.length; i++) {
+                               Notes notes = _slides[i].getNotesSheet();
+                               if (notes == null) {
+                                       continue;
+                               }
+                               Integer id = new Integer(notes._getSheetNumber());
+                               if (seenNotes.contains(id)) {
+                                       continue;
+                               }
+                               seenNotes.add(id);
+
+                               // Repeat the Notes header, if set
+                               if (hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
+                                       ret.append(hf.getHeaderText() + "\n");
+                               }
+
+                               // Notes text
+                               TextRun[] runs = notes.getTextRuns();
+                               if (runs != null && runs.length > 0) {
+                                       for (int j = 0; j < runs.length; j++) {
+                                               TextRun run = runs[j];
+                                               String text = run.getText();
+                                               ret.append(text);
+                                               if (!text.endsWith("\n")) {
+                                                       ret.append("\n");
+                                               }
                                        }
                                }
-                       }
 
-                       // Repeat the notes footer, if set
-                       if(hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
-                               ret.append(hf.getFooterText() + "\n");
+                               // Repeat the notes footer, if set
+                               if (hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
+                                       ret.append(hf.getFooterText() + "\n");
+                               }
                        }
                }
-       }
 
-       return ret.toString();
-  }
+               return ret.toString();
+       }
 }
index 760745e9044f560d0a304e1f90b5451a1212d0b4..4024890b7697eac21c773292d68ac1e998958063 100644 (file)
@@ -32,14 +32,14 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
  * Reads an Outlook MSG File in and provides hooks into its data structure.
- * 
+ *
  * @author Travis Ferguson
  */
 public class MAPIMessage {
        private POIFSChunkParser chunkParser;
        private POIFSFileSystem fs;
        private Chunks chunks;
-       
+
        /**
         * Constructor for creating new files.
         *
@@ -47,8 +47,8 @@ public class MAPIMessage {
        public MAPIMessage() {
                //TODO make writing possible
        }
-       
-       
+
+
        /**
         * Constructor for reading MSG Files from the file system.
         * @param filename
@@ -57,7 +57,7 @@ public class MAPIMessage {
        public MAPIMessage(String filename) throws IOException {
                this(new FileInputStream(new File(filename)));
        }
-       
+
        /**
         * Constructor for reading MSG Files from an input stream.
         * @param in
@@ -66,12 +66,12 @@ public class MAPIMessage {
        public MAPIMessage(InputStream in) throws IOException {
                this.fs = new POIFSFileSystem(in);
                chunkParser = new POIFSChunkParser(this.fs);
-               
+
                // Figure out the right string type, based on
                //  the chunks present
                chunks = chunkParser.identifyChunks();
        }
-       
+
 
        /**
         * Gets a string value based on the passed chunk.
@@ -83,15 +83,15 @@ public class MAPIMessage {
                StringChunk strchunk = (StringChunk)out;
                return strchunk.toString();
        }
-       
-       
+
+
        /**
         * Gets the plain text body of this Outlook Message
         * @return The string representation of the 'text' version of the body, if available.
-        * @throws IOException 
-        * @throws ChunkNotFoundException 
+        * @throws IOException
+        * @throws ChunkNotFoundException
         */
-       public String getTextBody() throws IOException, ChunkNotFoundException {
+       public String getTextBody() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.textBodyChunk);
        }
 
@@ -102,8 +102,8 @@ public class MAPIMessage {
        public String getSubject() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.subjectChunk);
        }
-       
-       
+
+
        /**
         * Gets the display value of the "TO" line of the outlook message
         * This is not the actual list of addresses/values that will be sent to if you click Reply in the email.
@@ -112,7 +112,7 @@ public class MAPIMessage {
        public String getDisplayTo() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.displayToChunk);
        }
-       
+
        /**
         * Gets the display value of the "FROM" line of the outlook message
         * This is not the actual address that was sent from but the formated display of the user name.
@@ -121,7 +121,7 @@ public class MAPIMessage {
        public String getDisplayFrom() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.displayFromChunk);
        }
-       
+
        /**
         * Gets the display value of the "TO" line of the outlook message
         * This is not the actual list of addresses/values that will be sent to if you click Reply in the email.
@@ -130,7 +130,7 @@ public class MAPIMessage {
        public String getDisplayCC() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.displayCCChunk);
        }
-       
+
        /**
         * Gets the display value of the "TO" line of the outlook message
         * This is not the actual list of addresses/values that will be sent to if you click Reply in the email.
@@ -154,19 +154,19 @@ public class MAPIMessage {
         * Gets the message class of the parsed Outlook Message.
         * (Yes, you can use this to determine if a message is a calendar item, note, or actual outlook Message)
         * For emails the class will be IPM.Note
-        * 
+        *
         * @throws ChunkNotFoundException
         */
        public String getMessageClass() throws ChunkNotFoundException {
                return getStringFromChunk(chunks.messageClass);
-       }       
-       
+       }
+
        /**
         * Gets the message attachments.
-        * 
+        *
         * @return a map containing attachment name (String) and data (ByteArrayInputStream)
         */
        public Map getAttachmentFiles() {
                return this.chunkParser.getAttachmentList();
-       }       
+       }
 }
index 8e7bcac90aa641c0bb8ba34e0985eded5a4570c5..d435ebff08bc10339468bf901ed8a386aae8a3af 100644 (file)
@@ -28,9 +28,9 @@ import org.apache.poi.hwpf.model.FileInformationBlock;
  *  use this program.
  */
 public final class HWPFLister {
-       private HWPFDocument doc;
+       private final HWPFDocument _doc;
        public HWPFLister(HWPFDocument doc) {
-               this.doc = doc;
+               _doc = doc;
        }
 
        public static void main(String[] args) throws Exception {
@@ -46,8 +46,8 @@ public final class HWPFLister {
                l.dumpFIB();
        }
 
-       public void dumpFIB() throws Exception {
-               FileInformationBlock fib = doc.getFileInformationBlock();
+       public void dumpFIB() {
+               FileInformationBlock fib = _doc.getFileInformationBlock();
                System.out.println(fib.toString());
        }
 }
index b4308af39905cf167f69ebdb9c80c6d9d20236f7..1be78ab1a660e2db1d4bb70b79519ec65bda31db 100644 (file)
@@ -71,7 +71,7 @@ public final class WordExtractor extends POIOLE2TextExtractor {
         * Create a new Word Extractor
         * @param doc The HWPFDocument to extract from
         */
-       public WordExtractor(HWPFDocument doc) throws IOException {
+       public WordExtractor(HWPFDocument doc) {
                super(doc);
                this.doc = doc;
        }
index 8d5967411c4157f43a30f80649a7a4c7680a2332..d5e55b1a2ff53648a6af617eb788ac16e6f8cc6f 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hwpf.model;
 
-import java.io.IOException;
-
 import org.apache.poi.util.LittleEndian;
 
 /**
@@ -78,9 +76,7 @@ public final class FIBLongHandler {
     _longs[longCode] = value;
   }
 
-  void serialize(byte[] mainStream, int offset)
-    throws IOException
-  {
+  void serialize(byte[] mainStream, int offset) {
     LittleEndian.putShort(mainStream, offset, (short)_longs.length);
     offset += LittleEndian.SHORT_SIZE;
 
index 4de7e5a29ddeb6d4f7abd277f67f81166384f8f0..28ffe22a63b51dadf8f3417a0e2c5c82ec525a84 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hwpf.model;
 
-import java.io.IOException;
-
 import org.apache.poi.util.LittleEndian;
 
 /**
@@ -60,9 +58,7 @@ public final class FIBShortHandler {
     return (_shorts.length * LittleEndian.SHORT_SIZE) + LittleEndian.SHORT_SIZE;
   }
 
-  void serialize(byte[] mainStream)
-    throws IOException
-  {
+  void serialize(byte[] mainStream) {
     int offset = START;
     LittleEndian.putShort(mainStream, offset, (short)_shorts.length);
     offset += LittleEndian.SHORT_SIZE;
index e66a26266482ac6beedf657326ea6689ef07190d..8c9224fd9df40ef7aacaf9252ad1ebef853ac0c1 100644 (file)
@@ -49,7 +49,7 @@ public final class TestPOIDocumentScratchpad extends TestCase {
         * Set things up, using a PowerPoint document and
         *  a Word Document for our testing
         */
-    public void setUp() throws Exception {
+       public void setUp() throws Exception {
                String dirnameHSLF = System.getProperty("HSLF.testdata.path");
                String filenameHSLF = dirnameHSLF + "/basic_test_ppt_file.ppt";
                String dirnameHSSF = System.getProperty("HSSF.testdata.path");
@@ -66,39 +66,35 @@ public final class TestPOIDocumentScratchpad extends TestCase {
                doc2 = new HWPFDocument(pfs2);
        }
 
-    public void testReadProperties() throws Exception {
-       // We should have both sets
-       assertNotNull(doc.getDocumentSummaryInformation());
-       assertNotNull(doc.getSummaryInformation());
+       public void testReadProperties() {
+               // We should have both sets
+               assertNotNull(doc.getDocumentSummaryInformation());
+               assertNotNull(doc.getSummaryInformation());
 
-       // Check they are as expected for the test doc
-       assertEquals("Hogwarts", doc.getSummaryInformation().getAuthor());
-       assertEquals(10598, doc.getDocumentSummaryInformation().getByteCount());
-    }
+               // Check they are as expected for the test doc
+               assertEquals("Hogwarts", doc.getSummaryInformation().getAuthor());
+               assertEquals(10598, doc.getDocumentSummaryInformation().getByteCount());
+       }
 
-    public void testReadProperties2() throws Exception {
-       // Check again on the word one
-       assertNotNull(doc2.getDocumentSummaryInformation());
-       assertNotNull(doc2.getSummaryInformation());
+       public void testReadProperties2() {
+               // Check again on the word one
+               assertNotNull(doc2.getDocumentSummaryInformation());
+               assertNotNull(doc2.getSummaryInformation());
 
-       assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
-       assertEquals("", doc2.getSummaryInformation().getKeywords());
-       assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
-    }
+               assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
+               assertEquals("", doc2.getSummaryInformation().getKeywords());
+               assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
+       }
 
-    public void testWriteProperties() throws Exception {
-       // Just check we can write them back out into a filesystem
-       POIFSFileSystem outFS = new POIFSFileSystem();
-       doc.writeProperties(outFS);
+       public void testWriteProperties() throws Exception {
+               // Just check we can write them back out into a filesystem
+               POIFSFileSystem outFS = new POIFSFileSystem();
+               doc.writeProperties(outFS);
 
-       // Should now hold them
-       assertNotNull(
-                       outFS.createDocumentInputStream("\005SummaryInformation")
-       );
-       assertNotNull(
-                       outFS.createDocumentInputStream("\005DocumentSummaryInformation")
-       );
-    }
+               // Should now hold them
+               assertNotNull(outFS.createDocumentInputStream("\005SummaryInformation"));
+               assertNotNull(outFS.createDocumentInputStream("\005DocumentSummaryInformation"));
+       }
 
     public void testWriteReadProperties() throws Exception {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
index bbdeadad0914a5861d18cef3d280f78362b0a769..f3af7c375f2edf1066b6c985f008456e145cfeb7 100644 (file)
@@ -106,7 +106,7 @@ public final class TestHDGFLZW extends TestCase {
                0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
        };
 
-       public void testFromToInt() throws Exception {
+       public void testFromToInt() {
                byte b255 = -1;
                assertEquals(255, HDGFLZW.fromByte(b255));
                assertEquals(-1, HDGFLZW.fromInt( HDGFLZW.fromByte(b255) ));
index a24733c919a2491d4c2b5111d67146328e86e10a..16bd9a961ef3af8908f7d41f447a9d34198bdd04 100644 (file)
@@ -30,7 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 public final class TestVisioExtractor extends TestCase {
        private String dirname;
        private String defFilename;
-       protected void setUp() throws Exception {
+       protected void setUp() {
                dirname = System.getProperty("HDGF.testdata.path");
                defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd";
        }
index aaed0fd6f86efda25a36fb1a8b3e9956332c1453..b8aa155888bf2819c82dea04c9d379b33c38e4f5 100644 (file)
@@ -40,7 +40,7 @@ public final class TestPointerFactory extends TestCase {
                -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
        };
 
-       public void testCreateV4() throws Exception {
+       public void testCreateV4() {
                PointerFactory pf = new PointerFactory(4);
                try {
                        pf.createPointer(new byte[]{}, 0);
@@ -50,7 +50,7 @@ public final class TestPointerFactory extends TestCase {
                }
        }
 
-       public void testCreateV5() throws Exception {
+       public void testCreateV5() {
                PointerFactory pf = new PointerFactory(5);
                try {
                        pf.createPointer(new byte[]{}, 0);
@@ -61,7 +61,7 @@ public final class TestPointerFactory extends TestCase {
                }
        }
 
-       public void testCreateV6() throws Exception {
+       public void testCreateV6() {
                PointerFactory pf = new PointerFactory(6);
 
                Pointer a = pf.createPointer(vp6_a, 0);
@@ -117,7 +117,7 @@ public final class TestPointerFactory extends TestCase {
                assertFalse(d.destinationHasPointers());
        }
 
-       public void testCreateV6FromMid() throws Exception {
+       public void testCreateV6FromMid() {
                PointerFactory pf = new PointerFactory(11);
 
                // Create a from part way down the byte stream
index 507c2e9579bc0d32d14bd2f27f3950ca7351cb0a..66c3907082cf75786524a97acca0f79a9bfb3568 100644 (file)
@@ -52,17 +52,17 @@ public final class TestStreamBugs extends StreamTest {
                filesystem.createDocumentInputStream("VisioDocument").read(contents);
        }
 
-       public void testGetTrailer() throws Exception {
+       public void testGetTrailer() {
                Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
                Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
        }
 
-       public void TOIMPLEMENTtestGetCertainChunks() throws Exception {
+       public void TOIMPLEMENTtestGetCertainChunks() {
                int offsetA = 3708;
                int offsetB = 3744;
        }
 
-       public void testGetChildren() throws Exception {
+       public void testGetChildren() {
                Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
                TrailerStream trailer = (TrailerStream)
                        Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
index 8f1897e00efe93d3d4e2e228bb0d678508111704..a06c03aa24b8bbbda837edee98e6785e3a043d4b 100644 (file)
@@ -205,7 +205,7 @@ public final class TestStreamComplex extends StreamTest {
                assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
        }
 
-       public void testChunkWithText() throws Exception {
+       public void testChunkWithText() {
                // Parent ChunkStream is at 0x7194
                // This is one of the last children of the trailer
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
index 29ab7a8aca12f7855a817d7ebb00ee4d386989b8..96e1591e0200ff83ee12fc341fac55da207b3663 100644 (file)
@@ -25,7 +25,7 @@ import junit.framework.TestCase;
 public final class TestHPBFDocument extends TestCase {
        private String dir;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                dir = System.getProperty("HPBF.testdata.path");
        }
 
index 6bd05612e0adfe7c3985228984f5b1030700ca62..7aceb66d431887e3bf6cbda35e8ef01f766a1fe4 100644 (file)
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
 public final class TextPublisherTextExtractor extends TestCase {
        private String dir;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                dir = System.getProperty("HPBF.testdata.path");
        }
 
index e803cae15602c71e3e8653956c62c9c2eb69b5cd..702c5fd8f304d5beedf23786646c2bce37b5aa8c 100644 (file)
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
 public final class TestEscherParts extends TestCase {
        private String dir;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                dir = System.getProperty("HPBF.testdata.path");
        }
 
index 69d46d0923693fe0ac59a74ae953c3bafcce95bb..6a80c86286e1b8c5d5e2417257533fda71b615e9 100644 (file)
@@ -32,7 +32,7 @@ import junit.framework.TestCase;
 public final class TestQuillContents extends TestCase {
        private String dir;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                dir = System.getProperty("HPBF.testdata.path");
        }
 
index 60b93dea6431a8780f01086ea2e62c33496557da..16e0c2785cd15451159d65c742c75c9c11a8be90 100644 (file)
@@ -31,13 +31,13 @@ public final class TestRecordCounts extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow ss;
 
-    public TestRecordCounts() throws Exception {
+       public TestRecordCounts() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                ss = new HSLFSlideShow(filename);
-    }
+       }
 
-    public void testSheetsCount() throws Exception {
+       public void testSheetsCount() {
                // Top level
                Record[] r = ss.getRecords();
 
@@ -51,7 +51,7 @@ public final class TestRecordCounts extends TestCase {
                assertEquals(3,count);
        }
 
-    public void testNotesCount() throws Exception {
+       public void testNotesCount() {
                // Top level
                Record[] r = ss.getRecords();
 
@@ -66,7 +66,7 @@ public final class TestRecordCounts extends TestCase {
                assertEquals(3,count);
        }
 
-    public void testSlideListWithTextCount() throws Exception {
+       public void testSlideListWithTextCount() {
                // Second level
                Record[] rt = ss.getRecords();
                Record[] r = rt[0].getChildRecords();
index e45ca51d125ab2fc44e4cfdc123e38a5d6a669a5..fdcc45e0b9a1c254ddf3d012e79f4e7b2c59fcfa 100644 (file)
@@ -61,7 +61,7 @@ public final class TestCruddyExtractor extends TestCase {
                te = new QuickButCruddyTextExtractor(filename);
     }
 
-    public void testReadAsVector() throws Exception {
+    public void testReadAsVector() {
                // Extract the text from the file as a vector
                Vector foundTextV = te.getTextAsVector();
 
@@ -73,7 +73,7 @@ public final class TestCruddyExtractor extends TestCase {
                }
        }
 
-       public void testReadAsString() throws Exception {
+       public void testReadAsString() {
                // Extract the text as a String
                String foundText = te.getTextAsString();
 
index 7871b059769267fc69ed37b07f3a24841b43bc6a..e1ac1914f66a7e04e02a9722922677aab073701b 100644 (file)
@@ -35,7 +35,7 @@ public final class TestBackground extends TestCase {
     /**
      * Default background for slide, shape and slide master.
      */
-    public void testDefaults() throws Exception {
+    public void testDefaults() {
         SlideShow ppt = new SlideShow();
 
         assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());
index f445f2b62b3747ad6cc1f654f84c0522d502022c..aff848dfc5e11becc7da87e6730dc64aaa11f8e2 100755 (executable)
@@ -20,8 +20,6 @@ package org.apache.poi.hslf.model;
 import junit.framework.TestCase;
 import org.apache.poi.hslf.usermodel.SlideShow;
 
-import java.io.IOException;
-
 /**
  * Test adding fonts to the presenataion resources
  *
@@ -29,7 +27,7 @@ import java.io.IOException;
  */
 public final class TestPPFont extends TestCase{
 
-    public void testCreate() throws IOException {
+    public void testCreate() {
         SlideShow ppt = new SlideShow();
         assertEquals(1, ppt.getNumberOfFonts());
         assertEquals("Arial", ppt.getFont(0).getFontName());
index 9d80f7dc720c6041d9d84849335ec354bb0c504d..3be128921b3ee929d093bb4a62cdbe996431389c 100755 (executable)
@@ -21,7 +21,6 @@ import java.awt.Graphics2D;
 import java.awt.Rectangle;
 import java.awt.image.BufferedImage;
 import java.io.File;
-import java.io.IOException;
 
 import junit.framework.TestCase;
 
index 565445f7b4769272ee5cb608d20f2750e54c030a..292b7fd63d0975dc44761d833a11cb27100d6430 100644 (file)
@@ -183,7 +183,7 @@ public final class TestShapes extends TestCase {
     /**
      * Test with an empty text box
      */
-    public void testEmptyTextBox() throws Exception {
+    public void testEmptyTextBox() {
        assertEquals(2, pptB.getSlides().length);
        Slide s1 = pptB.getSlides()[0];
        Slide s2 = pptB.getSlides()[1];
@@ -310,7 +310,7 @@ public final class TestShapes extends TestCase {
         assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
     }
 
-    public void testLineWidth() throws IOException {
+    public void testLineWidth() {
         SimpleShape sh = new AutoShape(ShapeTypes.RightTriangle);
 
         EscherOptRecord opt = (EscherOptRecord)SimpleShape.getEscherChild(sh.getSpContainer(), EscherOptRecord.RECORD_ID);
@@ -324,7 +324,7 @@ public final class TestShapes extends TestCase {
         assertEquals(1.0, sh.getLineWidth());
     }
 
-    public void testShapeId() throws IOException {
+    public void testShapeId() {
         SlideShow ppt = new SlideShow();
         Slide slide = ppt.createSlide();
         Shape shape = null;
index 0282c2a7e6e5ea3bed147543362dc209ca3fc11b..667478b043a07f71d2dcff767ea88be1f32f1c54 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hslf.model;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import java.io.FileInputStream;
@@ -34,7 +35,7 @@ import org.apache.poi.hslf.usermodel.SlideShow;
  *
  * @author Yegor Kozlov
  */
-public final class TestSheet extends TestCase{
+public final class TestSheet extends TestCase {
 
     /**
      * For each ppt in the test directory check that all sheets are properly initialized
@@ -59,7 +60,7 @@ public final class TestSheet extends TestCase{
         }
     }
 
-    private void doSlideShow(SlideShow ppt) throws Exception {
+    private void doSlideShow(SlideShow ppt) {
         Slide[] slide = ppt.getSlides();
         for (int i = 0; i < slide.length; i++) {
             verify(slide[i]);
@@ -89,19 +90,22 @@ public final class TestSheet extends TestCase{
         assertTrue(sheet._getSheetRefId() != 0);
 
         TextRun[] txt = sheet.getTextRuns();
-        assertTrue(txt != null);
+        if (txt == null) {
+            throw new AssertionFailedError("no text runs");
+        }
         for (int i = 0; i < txt.length; i++) {
             assertNotNull(txt[i].getSheet());
         }
 
         Shape[] shape = sheet.getShapes();
-        assertTrue(shape != null);
+        if (shape == null) {
+            throw new AssertionFailedError("no shapes");
+        }
         for (int i = 0; i < shape.length; i++) {
             assertNotNull(shape[i].getSpContainer());
             assertNotNull(shape[i].getSheet());
             assertNotNull(shape[i].getShapeName());
             assertNotNull(shape[i].getAnchor());
         }
-
     }
 }
index 2fcc6927c70d046a325ead39e0904cf17eab93f2..770a44803e5346bc90043e3e597a57d3120705cb 100644 (file)
@@ -18,6 +18,8 @@
 package org.apache.poi.hslf.model;
 
 
+import java.io.IOException;
+
 import junit.framework.TestCase;
 
 import org.apache.poi.hslf.HSLFSlideShow;
@@ -37,27 +39,35 @@ public final class TestTextRun extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
        private SlideShow ssRich;
-       private HSLFSlideShow hss;
-       private HSLFSlideShow hssRich;
 
-    protected void setUp() throws Exception {
+       // TODO - use this or similar through rest of hslf tests
+       private static SlideShow openSampleSlideShow(String name) {
                String dirname = System.getProperty("HSLF.testdata.path");
 
                // Basic (non rich) test file
-               String filename = dirname + "/basic_test_ppt_file.ppt";
-               hss = new HSLFSlideShow(filename);
-               ss = new SlideShow(hss);
+               String filename = dirname + "/" + name;
+               HSLFSlideShow x;
+               try {
+                       x = new HSLFSlideShow(filename);
+               } catch (IOException e) {
+                       throw new RuntimeException(e);
+               }
+               return new SlideShow(x);
+       }
+
+       protected void setUp() {
+
+               // Basic (non rich) test file
+               ss = openSampleSlideShow("basic_test_ppt_file.ppt");
 
                // Rich test file
-               filename = dirname + "/Single_Coloured_Page.ppt";
-               hssRich = new HSLFSlideShow(filename);
-               ssRich = new SlideShow(hssRich);
+               ssRich = openSampleSlideShow("Single_Coloured_Page.ppt");
        }
 
-    /**
-     * Test to ensure that getting the text works correctly
-     */
-    public void testGetText() throws Exception {
+       /**
+        * Test to ensure that getting the text works correctly
+        */
+       public void testGetText() {
                Slide slideOne = ss.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
 
@@ -81,12 +91,12 @@ public final class TestTextRun extends TestCase {
                assertEquals("This is the subtitle, in bold\nThis bit is blue and italic\nThis bit is red (normal)", textRunsR[1].getText());
                assertEquals("This is a title, it\u2019s in black", textRunsR[0].getRawText());
                assertEquals("This is the subtitle, in bold\rThis bit is blue and italic\rThis bit is red (normal)", textRunsR[1].getRawText());
-    }
+       }
 
-    /**
-     * Test to ensure changing non rich text bytes->bytes works correctly
-     */
-    public void testSetText() throws Exception {
+       /**
+        * Test to ensure changing non rich text bytes->bytes works correctly
+        */
+       public void testSetText() {
                Slide slideOne = ss.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun run = textRuns[0];
@@ -102,13 +112,13 @@ public final class TestTextRun extends TestCase {
                // Ensure trailing \n's get stripped
                run.setText(changeTo + "\n");
                assertEquals(changeTo, run.getText());
-    }
+       }
 
-    /**
-     * Test to ensure that changing non rich text between bytes and
-     *  chars works correctly
-     */
-    public void testAdvancedSetText() throws Exception {
+       /**
+        * Test to ensure that changing non rich text between bytes and
+        *  chars works correctly
+        */
+       public void testAdvancedSetText() {
                Slide slideOne = ss.getSlides()[0];
                TextRun run = slideOne.getTextRuns()[0];
 
@@ -116,7 +126,7 @@ public final class TestTextRun extends TestCase {
                TextBytesAtom tba = run._byteAtom;
                TextCharsAtom tca = run._charAtom;
 
-       // Bytes -> Bytes
+               // Bytes -> Bytes
                assertNull(tca);
                assertNotNull(tba);
                assertFalse(run._isUnicode);
@@ -132,7 +142,7 @@ public final class TestTextRun extends TestCase {
                assertNull(tca);
                assertNotNull(tba);
 
-       // Bytes -> Chars
+               // Bytes -> Chars
                assertNull(tca);
                assertNotNull(tba);
                assertFalse(run._isUnicode);
@@ -148,7 +158,7 @@ public final class TestTextRun extends TestCase {
                assertNotNull(tca);
                assertNull(tba);
 
-       // Chars -> Chars
+               // Chars -> Chars
                assertNull(tba);
                assertNotNull(tca);
                assertTrue(run._isUnicode);
@@ -163,13 +173,13 @@ public final class TestTextRun extends TestCase {
                assertTrue(run._isUnicode);
                assertNotNull(tca);
                assertNull(tba);
-    }
+       }
 
-    /**
-     * Tests to ensure that non rich text has the right default rich text run
-     *  set up for it
-     */
-    public void testGetRichTextNonRich() throws Exception {
+       /**
+        * Tests to ensure that non rich text has the right default rich text run
+        *  set up for it
+        */
+       public void testGetRichTextNonRich() {
                Slide slideOne = ss.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
 
@@ -191,12 +201,12 @@ public final class TestTextRun extends TestCase {
                assertNull(rtrA._getRawParagraphStyle());
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
-    }
+       }
 
-    /**
-     * Tests to ensure that the rich text runs are built up correctly
-     */
-    public void testGetRichText() throws Exception {
+       /**
+        * Tests to ensure that the rich text runs are built up correctly
+        */
+       public void testGetRichText() {
                Slide slideOne = ssRich.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
 
@@ -236,13 +246,13 @@ public final class TestTextRun extends TestCase {
                assertFalse( rtrB._getRawCharacterStyle().equals( rtrC._getRawCharacterStyle() ));
                assertFalse( rtrB._getRawCharacterStyle().equals( rtrD._getRawCharacterStyle() ));
                assertFalse( rtrC._getRawCharacterStyle().equals( rtrD._getRawCharacterStyle() ));
-    }
+       }
 
-    /**
-     * Tests to ensure that setting the text where the text isn't rich,
-     *  ensuring that everything stays with the same default styling
-     */
-    public void testSetTextWhereNotRich() throws Exception {
+       /**
+        * Tests to ensure that setting the text where the text isn't rich,
+        *  ensuring that everything stays with the same default styling
+        */
+       public void testSetTextWhereNotRich() {
                Slide slideOne = ss.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
@@ -260,13 +270,13 @@ public final class TestTextRun extends TestCase {
                assertEquals("Test Foo Test", rtrB.getText());
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
-    }
+       }
 
-    /**
-     * Tests to ensure that setting the text where the text is rich
-     *  sets everything to the same styling
-     */
-    public void testSetTextWhereRich() throws Exception {
+       /**
+        * Tests to ensure that setting the text where the text is rich
+        *  sets everything to the same styling
+        */
+       public void testSetTextWhereRich() {
                Slide slideOne = ssRich.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
@@ -308,13 +318,13 @@ public final class TestTextRun extends TestCase {
                assertNotNull(rtrB._getRawParagraphStyle());
                assertEquals( tpBP, rtrB._getRawParagraphStyle() );
                assertEquals( tpBC, rtrB._getRawCharacterStyle() );
-    }
+       }
 
-    /**
-     * Test to ensure the right stuff happens if we change the text
-     *  in a rich text run, that doesn't happen to actually be rich
-     */
-    public void testChangeTextInRichTextRunNonRich() throws Exception {
+       /**
+        * Test to ensure the right stuff happens if we change the text
+        *  in a rich text run, that doesn't happen to actually be rich
+        */
+       public void testChangeTextInRichTextRunNonRich() {
                Slide slideOne = ss.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
@@ -333,13 +343,13 @@ public final class TestTextRun extends TestCase {
                // Will now have dummy props
                assertNotNull(rtrB._getRawCharacterStyle());
                assertNotNull(rtrB._getRawParagraphStyle());
-    }
+       }
 
-    /**
-     * Tests to ensure changing the text within rich text runs works
-     *  correctly
-     */
-    public void testChangeTextInRichTextRun() throws Exception {
+       /**
+        * Tests to ensure changing the text within rich text runs works
+        *  correctly
+        */
+       public void testChangeTextInRichTextRun() {
                Slide slideOne = ssRich.getSlides()[0];
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
@@ -409,7 +419,7 @@ public final class TestTextRun extends TestCase {
                assertEquals(tpBC.getTextPropList(), ntpBC.getTextPropList());
                assertEquals(tpCC.getTextPropList(), ntpCC.getTextPropList());
                assertEquals(tpDC.getTextPropList(), ntpDC.getTextPropList());
-    }
+       }
 
 
        /**
@@ -419,10 +429,10 @@ public final class TestTextRun extends TestCase {
         * of the wrong list of potential paragraph properties defined in StyleTextPropAtom.
         *
         */
-       public void testBug41015() throws Exception {
+       public void testBug41015() {
                RichTextRun[] rt;
 
-               SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/bug-41015.ppt"));
+               SlideShow ppt = openSampleSlideShow("bug-41015.ppt");
                Slide sl = ppt.getSlides()[0];
                TextRun[] txt = sl.getTextRuns();
                assertEquals(2, txt.length);
@@ -436,61 +446,61 @@ public final class TestTextRun extends TestCase {
                assertEquals(2, rt.length);
                assertEquals(0, rt[0].getIndentLevel());
                assertEquals("Sdfsdfsdf\n" +
-                       "Dfgdfg\n" +
-                       "Dfgdfgdfg\n", rt[0].getText());
+                               "Dfgdfg\n" +
+                               "Dfgdfgdfg\n", rt[0].getText());
                assertEquals(1, rt[1].getIndentLevel());
                assertEquals("Sdfsdfs\n" +
-                       "Sdfsdf\n", rt[1].getText());
+                               "Sdfsdf\n", rt[1].getText());
        }
 
-    /**
-     * Test creation of TextRun objects.
-     */
-    public void testAddTextRun() throws Exception{
-        SlideShow ppt = new SlideShow();
-        Slide slide = ppt.createSlide();
-
-        assertNull(slide.getTextRuns());
-
-        TextBox shape1 = new TextBox();
-        TextRun run1 = shape1.getTextRun();
-        assertSame(run1, shape1.createTextRun());
-        run1.setText("Text 1");
-        slide.addShape(shape1);
-
-        //The array of Slide's text runs must be updated when new text shapes are added.
-        TextRun[] runs = slide.getTextRuns();
-        assertNotNull(runs);
-        assertSame(run1, runs[0]);
-
-        TextBox shape2 = new TextBox();
-        TextRun run2 = shape2.getTextRun();
-        assertSame(run2, shape2.createTextRun());
-        run2.setText("Text 2");
-        slide.addShape(shape2);
-
-        runs = slide.getTextRuns();
-        assertEquals(2, runs.length);
-
-        assertSame(run1, runs[0]);
-        assertSame(run2, runs[1]);
-
-        //as getShapes()
-        Shape[] sh = slide.getShapes();
-        assertEquals(2, sh.length);
-        assertTrue(sh[0] instanceof TextBox);
-        TextBox box1 = (TextBox)sh[0];
-        assertSame(run1, box1.getTextRun());
-        TextBox box2 = (TextBox)sh[1];
-        assertSame(run2, box2.getTextRun());
-
-        //test Table - a complex group of shapes containing text objects
-        Slide slide2 = ppt.createSlide();
-        assertNull(slide2.getTextRuns());
-        Table table = new Table(2, 2);
-        slide2.addShape(table);
-        runs = slide2.getTextRuns();
-        assertNotNull(runs);
-        assertEquals(4, runs.length);
-    }
+       /**
+        * Test creation of TextRun objects.
+        */
+       public void testAddTextRun() {
+               SlideShow ppt = new SlideShow();
+               Slide slide = ppt.createSlide();
+
+               assertNull(slide.getTextRuns());
+
+               TextBox shape1 = new TextBox();
+               TextRun run1 = shape1.getTextRun();
+               assertSame(run1, shape1.createTextRun());
+               run1.setText("Text 1");
+               slide.addShape(shape1);
+
+               //The array of Slide's text runs must be updated when new text shapes are added.
+               TextRun[] runs = slide.getTextRuns();
+               assertNotNull(runs);
+               assertSame(run1, runs[0]);
+
+               TextBox shape2 = new TextBox();
+               TextRun run2 = shape2.getTextRun();
+               assertSame(run2, shape2.createTextRun());
+               run2.setText("Text 2");
+               slide.addShape(shape2);
+
+               runs = slide.getTextRuns();
+               assertEquals(2, runs.length);
+
+               assertSame(run1, runs[0]);
+               assertSame(run2, runs[1]);
+
+               //as getShapes()
+               Shape[] sh = slide.getShapes();
+               assertEquals(2, sh.length);
+               assertTrue(sh[0] instanceof TextBox);
+               TextBox box1 = (TextBox)sh[0];
+               assertSame(run1, box1.getTextRun());
+               TextBox box2 = (TextBox)sh[1];
+               assertSame(run2, box2.getTextRun());
+
+               //test Table - a complex group of shapes containing text objects
+               Slide slide2 = ppt.createSlide();
+               assertNull(slide2.getTextRuns());
+               Table table = new Table(2, 2);
+               slide2.addShape(table);
+               runs = slide2.getTextRuns();
+               assertNotNull(runs);
+               assertEquals(4, runs.length);
+       }
 }
index 5fffb13427920db4173def8b094be79c8f88b094..13090c812a45614e98118b37381d0665ad441457 100644 (file)
@@ -35,13 +35,13 @@ public final class TestCString extends TestCase {
                0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00,
                0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00 };
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                CString ca = new CString(data_a, 0, data_a.length);
                assertEquals(4026l, ca.getRecordType());
                CString cb = new CString(data_b, 0, data_a.length);
                assertEquals(4026l, cb.getRecordType());
        }
-       public void testCount() throws Exception {
+       public void testCount() {
                CString ca = new CString(data_a, 0, data_a.length);
                assertEquals(0, ca.getOptions());
                CString cb = new CString(data_b, 0, data_a.length);
@@ -51,7 +51,7 @@ public final class TestCString extends TestCase {
                assertEquals(28, ca.getOptions());
        }
 
-       public void testText() throws Exception {
+       public void testText() {
                CString ca = new CString(data_a, 0, data_a.length);
                assertEquals("Hogwarts", ca.getText());
                CString cb = new CString(data_b, 0, data_a.length);
index 22e6347dec565acd4d44bdd0ee9fa502a9e60517..e506075e04b6176cf26fed4342ef193162fecf03 100644 (file)
@@ -35,12 +35,12 @@ public final class TestColorSchemeAtom extends TestCase {
                00, 0x99-256, 0x99-256, 00,         0x99-256, 0xCC-256, 00, 00
        };
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
                assertEquals(2032l, csa.getRecordType());
        }
 
-       public void testToRGB() throws Exception {
+       public void testToRGB() {
                byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
 
                assertEquals(3,rgb.length);
@@ -49,7 +49,7 @@ public final class TestColorSchemeAtom extends TestCase {
                assertEquals(55, rgb[2]);
        }
 
-       public void testFromRGB() throws Exception {
+       public void testFromRGB() {
                byte[] rgb_a = new byte[] { 0, 255-256, 55 };
                byte[] rgb_b = new byte[] { 255-256, 127, 79 };
 
@@ -60,7 +60,7 @@ public final class TestColorSchemeAtom extends TestCase {
                assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
        }
 
-       public void testRGBs() throws Exception {
+       public void testRGBs() {
                ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
 
                assertEquals( 16777215 , csa.getBackgroundColourRGB() );
index f4fff8ca5952ffd7b0ca165cff43dc399f4b88e7..a3e1f2d8aeb82a98b8fdeb81efb9877759af05d9 100644 (file)
@@ -84,16 +84,16 @@ public final class TestComment2000 extends TestCase {
 
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
                assertEquals(12000l, ca.getRecordType());
        }
-       public void testAuthor() throws Exception {
+       public void testAuthor() {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
                assertEquals("Dumbledore", ca.getAuthor());
                assertEquals("D", ca.getAuthorInitials());
        }
-       public void testText() throws Exception {
+       public void testText() {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
                assertEquals("Yes, they certainly are, aren't they!", ca.getText());
        }
index a5749ee2e7c133b2f4dadb75ea15acfab6b01577..0e5f946a5f033f023677452918deddeea27d65d1 100644 (file)
@@ -47,35 +47,35 @@ public final class TestComment2000Atom extends TestCase {
 
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                assertEquals(12001l, ca.getRecordType());
        }
 
-    public void testGetDate() throws Exception {
+       public void testGetDate() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
 
-       // A is 2006-01-24 (2nd day of week) 10:26:15.205
+               // A is 2006-01-24 (2nd day of week) 10:26:15.205
                Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
                // B is 2006-01-24 (2nd day of week) 21:25:03.725
                Date exp_b = sdf.parse("2006-01-24 21:25:03.725");
 
                assertEquals(exp_a, ca.getDate());
                assertEquals(exp_b, cb.getDate());
-    }
+       }
 
-    public void testGetNums() throws Exception {
+       public void testGetNums() {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
 
-       // A is number 1
+               // A is number 1
                assertEquals(1, ca.getNumber());
-       // B is number 5
+               // B is number 5
                assertEquals(5, cb.getNumber());
-    }
+       }
 
-    public void testGetPos() throws Exception {
+       public void testGetPos() {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
 
@@ -86,7 +86,7 @@ public final class TestComment2000Atom extends TestCase {
                // B is at 0x0A, 0x0E
                assertEquals(0x0A, cb.getXOffset());
                assertEquals(0x0E, cb.getYOffset());
-    }
+       }
 
        public void testWrite() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
@@ -101,15 +101,15 @@ public final class TestComment2000Atom extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       Comment2000Atom a = new Comment2000Atom();
+       public void testCreate() throws Exception {
+               Comment2000Atom a = new Comment2000Atom();
 
-       // Set number, x and y
-       a.setNumber(1);
-       a.setXOffset(0x92);
-       a.setYOffset(0x92);
+               // Set number, x and y
+               a.setNumber(1);
+               a.setXOffset(0x92);
+               a.setYOffset(0x92);
 
-       // Set the date
+               // Set the date
                Date date_a = sdf.parse("2006-01-24 10:26:15.205");
                a.setDate(date_a);
 
@@ -122,7 +122,7 @@ public final class TestComment2000Atom extends TestCase {
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+       }
 
        // Try to turn a into b
        public void testChange() throws Exception {
index e068e8984bd23a8ee24049e12eb7a1be41cdabc9..e61273bb50c59efd6ab7c18f6bafdb740823d1af 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hslf.record;
 
-
 import junit.framework.TestCase;
 import java.io.*;
 
@@ -25,8 +24,7 @@ import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.poifs.filesystem.*;
 
 /**
- * Tests that Document works properly
- * (Also tests Environment while we're at it)
+ * Tests that Document works properly (Also tests Environment while we're at it)
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
@@ -36,55 +34,49 @@ public final class TestDocument extends TestCase {
        // POIFS primed on the test data
        private POIFSFileSystem pfs;
 
-    public TestDocument() throws Exception {
+       public TestDocument() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                FileInputStream fis = new FileInputStream(filename);
                pfs = new POIFSFileSystem(fis);
                ss = new HSLFSlideShow(pfs);
-    }
+       }
 
-    private Document getDocRecord() {
-       Record[] r = ss.getRecords();
-       for(int i=(r.length-1); i>=0; i--) {
-               if(r[i] instanceof Document) {
-                       return (Document)r[i];
-               }
-       }
-       throw new IllegalStateException("No Document record found");
-    }
+       private Document getDocRecord() {
+               Record[] r = ss.getRecords();
+               for (int i = (r.length - 1); i >= 0; i--) {
+                       if (r[i] instanceof Document) {
+                               return (Document) r[i];
+                       }
+               }
+               throw new IllegalStateException("No Document record found");
+       }
 
-    public void testRecordType() throws Exception {
-       Document dr = getDocRecord();
-       assertEquals(1000, dr.getRecordType());
+       public void testRecordType() {
+               Document dr = getDocRecord();
+               assertEquals(1000, dr.getRecordType());
        }
 
-    public void testChildRecords() throws Exception {
-       Document dr = getDocRecord();
-       assertNotNull(dr.getDocumentAtom());
-       assertTrue(dr.getDocumentAtom() instanceof DocumentAtom);
+       public void testChildRecords() {
+               Document dr = getDocRecord();
+               assertNotNull(dr.getDocumentAtom());
 
-       assertNotNull(dr.getEnvironment());
-       assertTrue(dr.getEnvironment() instanceof Environment);
+               assertNotNull(dr.getEnvironment());
 
-       assertNotNull(dr.getSlideListWithTexts());
-       assertEquals(3, dr.getSlideListWithTexts().length);
-       assertNotNull(dr.getSlideListWithTexts()[0]);
-       assertTrue(dr.getSlideListWithTexts()[0] instanceof SlideListWithText);
-       assertNotNull(dr.getSlideListWithTexts()[1]);
-       assertTrue(dr.getSlideListWithTexts()[1] instanceof SlideListWithText);
-       assertNotNull(dr.getSlideListWithTexts()[2]);
-       assertTrue(dr.getSlideListWithTexts()[2] instanceof SlideListWithText);
-    }
+               assertNotNull(dr.getSlideListWithTexts());
+               assertEquals(3, dr.getSlideListWithTexts().length);
+               assertNotNull(dr.getSlideListWithTexts()[0]);
+               assertNotNull(dr.getSlideListWithTexts()[1]);
+               assertNotNull(dr.getSlideListWithTexts()[2]);
+       }
 
-    public void testEnvironment() throws Exception {
-       Document dr = getDocRecord();
-       Environment env = dr.getEnvironment();
+       public void testEnvironment() {
+               Document dr = getDocRecord();
+               Environment env = dr.getEnvironment();
 
-       assertEquals(1010, env.getRecordType());
-       assertNotNull(env.getFontCollection());
-       assertTrue(env.getFontCollection() instanceof FontCollection);
-    }
+               assertEquals(1010, env.getRecordType());
+               assertNotNull(env.getFontCollection());
+       }
 
-    // No need to check re-writing - hslf.TestReWrite does all that for us
+       // No need to check re-writing - hslf.TestReWrite does all that for us
 }
index 9b28d431adf947b53c0e5219e5e0f3e1994e5d96..890c0a73b7e4023e34e24e84b91d12ea18e0be90 100644 (file)
@@ -34,11 +34,11 @@ public final class TestDocumentAtom extends TestCase {
                0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
                1, 0, 0, 0, 0, 0, 0, 1 };
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
                assertEquals(1001l, da.getRecordType());
        }
-       public void testSizeAndZoom() throws Exception {
+       public void testSizeAndZoom() {
                DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
                assertEquals(5760l, da.getSlideSizeX());
                assertEquals(4320l, da.getSlideSizeY());
@@ -48,17 +48,17 @@ public final class TestDocumentAtom extends TestCase {
                assertEquals(5l, da.getServerZoomFrom());
                assertEquals(10l, da.getServerZoomTo());
        }
-       public void testMasterPersist() throws Exception {
+       public void testMasterPersist() {
                DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
                assertEquals(2l, da.getNotesMasterPersist());
                assertEquals(0l, da.getHandoutMasterPersist());
        }
-       public void testSlideDetails() throws Exception {
+       public void testSlideDetails() {
                DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
                assertEquals(1, da.getFirstSlideNum());
                assertEquals(0, da.getSlideSizeType());
        }
-       public void testBooleans() throws Exception {
+       public void testBooleans() {
                DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
                assertEquals(false, da.getSaveWithFonts());
                assertEquals(false, da.getOmitTitlePlace());
index 9aa03a98874216f1e7bc4dd286cfdb73770b228e..81a939a4d027d1480bbd9f660bb1a748ab06c7df 100755 (executable)
@@ -69,23 +69,23 @@ public final class TestExControl extends TestCase {
             0x65, 0x00, 0x63, 0x00, 0x74, 0x00
     };
 
-    public void testRead() throws Exception {
+       public void testRead() {
                ExControl record = new ExControl(data, 0, data.length);
                assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
 
-        assertNotNull(record.getExControlAtom());
-        assertEquals(256, record.getExControlAtom().getSlideId());
+               assertNotNull(record.getExControlAtom());
+               assertEquals(256, record.getExControlAtom().getSlideId());
 
-        ExOleObjAtom oleObj = record.getExOleObjAtom();
-        assertNotNull(oleObj);
-        assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
-        assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
-        assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+               ExOleObjAtom oleObj = record.getExOleObjAtom();
+               assertNotNull(oleObj);
+               assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+               assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
+               assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
 
-        assertEquals("Shockwave Flash Object", record.getMenuName());
-        assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
-        assertEquals("Shockwave Flash Object", record.getClipboardName());
-    }
+               assertEquals("Shockwave Flash Object", record.getMenuName());
+               assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
+               assertEquals("Shockwave Flash Object", record.getClipboardName());
+       }
 
        public void testWrite() throws Exception {
                ExControl record = new ExControl(data, 0, data.length);
@@ -93,32 +93,31 @@ public final class TestExControl extends TestCase {
                record.writeOut(baos);
                byte[] b = baos.toByteArray();
 
-        assertTrue(Arrays.equals(data, b));
+               assertTrue(Arrays.equals(data, b));
        }
 
-    public void testNewRecord() throws Exception {
-        ExControl record = new ExControl();
-        ExControlAtom ctrl = record.getExControlAtom();
-        ctrl.setSlideId(256);
-
-        ExOleObjAtom oleObj = record.getExOleObjAtom();
-        oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
-        oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
-        oleObj.setObjID(1);
-        oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
-        oleObj.setObjStgDataRef(2);
-        oleObj.setOptions(1283584);
+       public void testNewRecord() throws Exception {
+               ExControl record = new ExControl();
+               ExControlAtom ctrl = record.getExControlAtom();
+               ctrl.setSlideId(256);
 
-        record.setMenuName("Shockwave Flash Object");
-        record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
-        record.setClipboardName("Shockwave Flash Object");
+               ExOleObjAtom oleObj = record.getExOleObjAtom();
+               oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+               oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+               oleObj.setObjID(1);
+               oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+               oleObj.setObjStgDataRef(2);
+               oleObj.setOptions(1283584);
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        record.writeOut(baos);
-        byte[] b = baos.toByteArray();
+               record.setMenuName("Shockwave Flash Object");
+               record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
+               record.setClipboardName("Shockwave Flash Object");
 
-        assertEquals(data.length, b.length);
-        assertTrue(Arrays.equals(data, b));
-    }
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
 
+               assertEquals(data.length, b.length);
+               assertTrue(Arrays.equals(data, b));
+       }
 }
index 3c903f41eed7b71879228ffc78515c4c73524232..d566a1f054481eda204a30dc5e4522926a53959f 100755 (executable)
@@ -48,9 +48,9 @@ public final class TestExVideoContainer extends TestCase {
 
 
 
-    public void testRead() throws Exception {
-               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
-               assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
+    public void testRead() {
+        ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+        assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
 
         ExMediaAtom exMedia = record.getExMediaAtom();
         assertEquals(1, exMedia.getObjectId());
@@ -64,14 +64,14 @@ public final class TestExVideoContainer extends TestCase {
         assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());
     }
 
-       public void testWrite() throws Exception {
-               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               record.writeOut(baos);
-               byte[] b = baos.toByteArray();
+    public void testWrite() throws Exception {
+        ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
 
-               assertTrue(Arrays.equals(data, b));
-       }
+        assertTrue(Arrays.equals(data, b));
+    }
 
     public void testNewRecord() throws Exception {
         ExVideoContainer record = new ExVideoContainer();
index 75af7afa0c98a57ce88e1936a7f93868ff69db2a..d0d47b7d713d7c4dae9fd51cff08032b8e26d77d 100644 (file)
@@ -40,7 +40,7 @@ public final class TestFontCollection extends TestCase {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xDA-256, 0x12, 0x00,
         0x28, 0xDD-256, 0x0D, 0x30, 0x00, 0x00, 0x04, 0x00  };
 
-    public void testFonts() throws Exception {
+    public void testFonts() {
         FontCollection fonts = new FontCollection(data, 0, data.length);
         Record[] child = fonts.getChildRecords();
         assertEquals(child.length, 1);
@@ -49,7 +49,7 @@ public final class TestFontCollection extends TestCase {
         assertEquals(fnt.getFontName(), "Times New Roman");
     }
 
-    public void testAddFont() throws Exception {
+    public void testAddFont() {
         FontCollection fonts = new FontCollection(data, 0, data.length);
         int idx = fonts.addFont("Times New Roman");
         assertEquals(idx, 0);
index 5db87e136d6b9cdcbb16ae410a6c5c78616c2f3d..b391c06ed7d7fb76076be1aa2ef9ac1f862c1500 100644 (file)
@@ -33,7 +33,7 @@ public final class TestHeadersFootersAtom extends TestCase {
             0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
             0x00, 0x00, 0x23, 0x00 };
 
-    public void testRead() throws Exception {
+    public void testRead() {
                HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
                assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
 
@@ -70,7 +70,7 @@ public final class TestHeadersFootersAtom extends TestCase {
         assertTrue(Arrays.equals(data, b));
     }
 
-    public void testFlags() throws Exception {
+    public void testFlags() {
         HeadersFootersAtom record = new HeadersFootersAtom();
 
         //in a new record all the bits are 0
@@ -87,6 +87,5 @@ public final class TestHeadersFootersAtom extends TestCase {
 
         record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
         assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
-
     }
 }
index 921b08929b32e62d87475eeac37826c178e21c4f..5ac5c22b484a537a418104f15d41bcffdd9bb577 100644 (file)
@@ -50,7 +50,7 @@ public final class TestHeadersFootersContainer extends TestCase {
             0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
     };
 
-    public void testReadSlideHeadersFootersContainer() throws Exception {
+    public void testReadSlideHeadersFootersContainer() {
                HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
                assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
         assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
@@ -103,7 +103,7 @@ public final class TestHeadersFootersContainer extends TestCase {
         assertTrue(Arrays.equals(slideData, b));
     }
 
-    public void testReadNotesHeadersFootersContainer() throws Exception {
+    public void testReadNotesHeadersFootersContainer() {
                HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
                assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
         assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());
index ad48bd1dcdc58d97cff2894c10145ff24cc9c46c..9ecb03b22ccf31db4ad2cc2b710557212eea9854 100644 (file)
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 
 
 package org.apache.poi.hslf.record;
@@ -38,19 +38,19 @@ public class TestInteractiveInfo extends TestCase {
                00, 00, 00, 00, 01, 00, 00, 00,
                04, 00, 00, 00, 8, 00, 00, 00
        };
-       
-    public void testRecordType() throws Exception {
+
+       public void testRecordType() {
                InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
                assertEquals(4082, ii.getRecordType());
        }
-    
-    public void testGetChildDetails() throws Exception {
+
+       public void testGetChildDetails() {
                InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
                InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
-               
+
                assertEquals(1, ia.getHyperlinkID());
-    }
-    
+       }
+
        public void testWrite() throws Exception {
                InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -64,24 +64,24 @@ public class TestInteractiveInfo extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       InteractiveInfo ii = new InteractiveInfo();
-       InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
-       
-       // Set values
-       ia.setHyperlinkID(1);
-       ia.setSoundRef(0);
-       ia.setAction((byte)4);
-       ia.setHyperlinkType((byte)8);
-       
+       public void testCreate() throws Exception {
+               InteractiveInfo ii = new InteractiveInfo();
+               InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();
+
+               // Set values
+               ia.setHyperlinkID(1);
+               ia.setSoundRef(0);
+               ia.setAction((byte)4);
+               ia.setHyperlinkType((byte)8);
+
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ii.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                assertEquals(data_a.length, b.length);
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+   }
 }
index 90deb5253e38b726cf333e9e311ede34195b5d21..e12ecd75c558dd67cca2728137f9351a7e5f30fc 100644 (file)
@@ -31,11 +31,11 @@ public final class TestNotesAtom extends TestCase {
        private byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
                0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
                assertEquals(1009l, na.getRecordType());
        }
-       public void testFlags() throws Exception {
+       public void testFlags() {
                NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
                assertEquals(0x80000000, na.getSlideID());
                assertEquals(false, na.getFollowMasterObjects());
index 464cac41dd095cd9bf1477d0dc636a5fe52bdf57..45522dfd81aa4375d3a256b1ecea5615c5057697 100644 (file)
@@ -26,19 +26,19 @@ import junit.framework.TestCase;
  * @author Nick Burch (nick at torchbox dot com)
  */
 public final class TestRecordTypes extends TestCase {
-    public void testPPTNameLookups() throws Exception {
+       public void testPPTNameLookups() {
                assertEquals("MainMaster", RecordTypes.recordName(1016));
                assertEquals("TextBytesAtom", RecordTypes.recordName(4008));
                assertEquals("VBAInfo", RecordTypes.recordName(1023));
        }
 
-    public void testEscherNameLookups() throws Exception {
+       public void testEscherNameLookups() {
                assertEquals("EscherDggContainer", RecordTypes.recordName(0xf000));
                assertEquals("EscherClientTextbox", RecordTypes.recordName(0xf00d));
                assertEquals("EscherSelection", RecordTypes.recordName(0xf119));
        }
 
-       public void testPPTClassLookups() throws Exception {
+       public void testPPTClassLookups() {
                assertEquals(Slide.class, RecordTypes.recordHandlingClass(1006));
                assertEquals(TextCharsAtom.class, RecordTypes.recordHandlingClass(4000));
                assertEquals(TextBytesAtom.class, RecordTypes.recordHandlingClass(4008));
@@ -49,7 +49,7 @@ public final class TestRecordTypes extends TestCase {
                assertEquals(UnknownRecordPlaceholder.class, RecordTypes.recordHandlingClass(2019));
        }
 
-       public void testEscherClassLookups() throws Exception {
+       public void testEscherClassLookups() {
                // Should all come back with null, as DDF handles them
                assertEquals(null, RecordTypes.recordHandlingClass(0xf000));
                assertEquals(null, RecordTypes.recordHandlingClass(0xf001));
index d9840d22d340a6735146e8fec4fb269f493ee0ed..28b122abae5c07589a864e79a8ac3df7314f7b15 100644 (file)
@@ -33,11 +33,11 @@ public final class TestSlideAtom extends TestCase {
                0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
                0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
                assertEquals(1007l, sa.getRecordType());
        }
-       public void testFlags() throws Exception {
+       public void testFlags() {
                SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
 
                // First 12 bytes are a SSlideLayoutAtom, checked elsewhere
@@ -51,7 +51,7 @@ public final class TestSlideAtom extends TestCase {
                assertEquals(true, sa.getFollowMasterScheme());
                assertEquals(true, sa.getFollowMasterBackground());
        }
-       public void testSSlideLayoutAtom() throws Exception {
+       public void testSSlideLayoutAtom() {
                SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
                SSlideLayoutAtom ssla = sa.getSSlideLayoutAtom();
 
index aad4aec623bf9bae184018c8ca2dfe2cc90607e4..25aa8a5350e3a183f7c480ad7d49ae857cfe66f8 100644 (file)
@@ -32,11 +32,11 @@ public final class TestSlidePersistAtom extends TestCase {
                4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
                1, 0, 0, 0, 0, 0, 0 };
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
                assertEquals(1011l, spa.getRecordType());
        }
-       public void testFlags() throws Exception {
+       public void testFlags() {
                SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
                assertEquals(4, spa.getRefID() );
                assertEquals(true, spa.getHasShapesOtherThanPlaceholders() );
index 2a4892319409a3c96b011506d6ca11f639efddd3..a95186c30619e2ea5893a9e540f4443a8ebe014a 100644 (file)
@@ -36,7 +36,7 @@ import org.apache.poi.util.HexDump;
  */
 public final class TestStyleTextPropAtom extends TestCase {
     /** From a real file: a paragraph with 4 different styles */
-    private byte[] data_a = new byte[] {
+    private static final byte[] data_a = new byte[] {
       0, 0, 0xA1-256, 0x0F, 0x2A, 0, 0, 0,
       0x36, 00, 00, 00, // paragraph is 54 long
       00, 00,           // (paragraph reserved field)
@@ -50,7 +50,7 @@ public final class TestStyleTextPropAtom extends TestCase {
       00, 00, 0x04, 00, // font.color only
       0xFF-256, 0x33, 00, 0xFE-256 // red
     };
-    private int data_a_text_len = 0x36-1;
+    private static final int data_a_text_len = 0x36-1;
 
     /**
      * From a real file: 4 paragraphs with text in 4 different styles:
@@ -60,7 +60,7 @@ public final class TestStyleTextPropAtom extends TestCase {
      * left aligned+underlined+larger font size (96)
      * left aligned+underlined+larger font size+red (1)
      */
-    private byte[] data_b = new byte[] {
+    private static final byte[] data_b = new byte[] {
         0, 0, 0xA1-256, 0x0F, 0x80-256, 0, 0, 0,
         0x1E, 00, 00, 00,     // paragraph is 30 long
         00, 00,               // paragraph reserved field
@@ -108,14 +108,14 @@ public final class TestStyleTextPropAtom extends TestCase {
         0x18, 00,             // font size 24
         0xFF-256, 0x33, 00, 0xFE-256 // colour red
     };
-    private int data_b_text_len = 0xB3;
+    private static final int data_b_text_len = 0xB3;
 
     /**
      * From a real file. Has a mask with more bits
      *  set than it actually has data for. Shouldn't do,
      *  but some real files do :(
      */
-    private byte[] data_c = new byte[] {
+    private static final byte[] data_c = new byte[] {
         0, 0, -95, 15, 62, 0, 0, 0,
         123, 0, 0, 0, 0, 0, 48, 8,
         10, 0, 1, 0, 0, 0, 0, 0,
@@ -131,15 +131,15 @@ public final class TestStyleTextPropAtom extends TestCase {
     /**
      * From a real file supplied for Bug 40143 by tales@great.ufc.br
      */
-    private byte[] data_d = {
+    private static final byte[] data_d = {
         0x00, 0x00, 0xA1-256, 0x0F, 0x1E, 0x00, 0x00, 0x00, //header
         (byte)0xA0, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 ,
         0x01 , 0x00, (byte)0xA0 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x63 , 0x00 ,
         0x01 , 0x00, 0x01 , 0x00 , 0x00, 0x00 , 0x01 , 0x00 , 0x14 , 0x00
     };
-    private int data_d_text_len = 0xA0-1;
+    private static final int data_d_text_len = 0xA0-1;
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
         StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         StyleTextPropAtom stpc = new StyleTextPropAtom(data_c,0,data_c.length);
@@ -149,7 +149,7 @@ public final class TestStyleTextPropAtom extends TestCase {
     }
 
 
-    public void testCharacterStyleCounts() throws Exception {
+    public void testCharacterStyleCounts() {
         StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
 
@@ -223,7 +223,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         TextProp tp_1_1 = (TextProp)b_ch_1.getTextPropList().get(0);
         TextProp tp_1_2 = (TextProp)b_ch_1.getTextPropList().get(1);
         assertEquals(true, tp_1_1 instanceof CharFlagsTextProp);
-        assertEquals(true, tp_1_2 instanceof TextProp);
         assertEquals("font.size", tp_1_2.getName());
         assertEquals(20, tp_1_2.getValue());
 
@@ -233,8 +232,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         TextProp tp_2_2 = (TextProp)b_ch_2.getTextPropList().get(1);
         TextProp tp_2_3 = (TextProp)b_ch_2.getTextPropList().get(2);
         assertEquals(true, tp_2_1 instanceof CharFlagsTextProp);
-        assertEquals(true, tp_2_2 instanceof TextProp);
-        assertEquals(true, tp_2_3 instanceof TextProp);
         assertEquals("font.size", tp_2_2.getName());
         assertEquals("font.color", tp_2_3.getName());
         assertEquals(20, tp_2_2.getValue());
@@ -243,8 +240,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(2,b_ch_3.getTextPropList().size());
         TextProp tp_3_1 = (TextProp)b_ch_3.getTextPropList().get(0);
         TextProp tp_3_2 = (TextProp)b_ch_3.getTextPropList().get(1);
-        assertEquals(true, tp_3_1 instanceof TextProp);
-        assertEquals(true, tp_3_2 instanceof TextProp);
         assertEquals("font.size", tp_3_1.getName());
         assertEquals("font.color", tp_3_2.getName());
         assertEquals(20, tp_3_1.getValue());
@@ -255,8 +250,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         TextProp tp_4_2 = (TextProp)b_ch_4.getTextPropList().get(1);
         TextProp tp_4_3 = (TextProp)b_ch_4.getTextPropList().get(2);
         assertEquals(true, tp_4_1 instanceof CharFlagsTextProp);
-        assertEquals(true, tp_4_2 instanceof TextProp);
-        assertEquals(true, tp_4_3 instanceof TextProp);
         assertEquals("font.index", tp_4_2.getName());
         assertEquals("font.size", tp_4_3.getName());
         assertEquals(24, tp_4_3.getValue());
@@ -276,8 +269,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(2,b_p_1.getTextPropList().size());
         TextProp tp_1_1 = (TextProp)b_p_1.getTextPropList().get(0);
         TextProp tp_1_2 = (TextProp)b_p_1.getTextPropList().get(1);
-        assertEquals(true, tp_1_1 instanceof TextProp);
-        assertEquals(true, tp_1_2 instanceof TextProp);
         assertEquals("alignment", tp_1_1.getName());
         assertEquals("linespacing", tp_1_2.getName());
         assertEquals(0, tp_1_1.getValue());
@@ -286,8 +277,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         // 2nd is centre aligned (default) + normal line spacing
         assertEquals(1,b_p_2.getTextPropList().size());
         TextProp tp_2_1 = (TextProp)b_p_2.getTextPropList().get(0);
-        assertEquals(true, tp_2_1 instanceof TextProp);
-        assertEquals(true, tp_1_2 instanceof TextProp);
         assertEquals("linespacing", tp_2_1.getName());
         assertEquals(80, tp_2_1.getValue());
 
@@ -295,8 +284,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(2,b_p_3.getTextPropList().size());
         TextProp tp_3_1 = (TextProp)b_p_3.getTextPropList().get(0);
         TextProp tp_3_2 = (TextProp)b_p_3.getTextPropList().get(1);
-        assertEquals(true, tp_3_1 instanceof TextProp);
-        assertEquals(true, tp_3_2 instanceof TextProp);
         assertEquals("alignment", tp_3_1.getName());
         assertEquals("linespacing", tp_3_2.getName());
         assertEquals(2, tp_3_1.getValue());
@@ -306,8 +293,6 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(2,b_p_4.getTextPropList().size());
         TextProp tp_4_1 = (TextProp)b_p_4.getTextPropList().get(0);
         TextProp tp_4_2 = (TextProp)b_p_4.getTextPropList().get(1);
-        assertEquals(true, tp_4_1 instanceof TextProp);
-        assertEquals(true, tp_4_2 instanceof TextProp);
         assertEquals("alignment", tp_4_1.getName());
         assertEquals("linespacing", tp_4_2.getName());
         assertEquals(0, tp_4_1.getValue());
index 1df2ad0c5103db7b17750164f44c8583f8ae750e..85d5b7a5521fbf8bb02838cb90169a2094a2a42d 100644 (file)
@@ -38,16 +38,16 @@ public final class TestTextBytesAtom extends TestCase {
                0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
        private String alt_text = "This is a test title";
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
                assertEquals(4008l, tba.getRecordType());
        }
 
-       public void testTextA() throws Exception {
+       public void testTextA() {
                TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
                assertEquals(data_text, tba.getText());
        }
-       public void testTextB() throws Exception {
+       public void testTextB() {
                TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
                assertEquals(alt_text, tba.getText());
        }
index 2f29dfd3c7f86e5e04b2b845a4d3b8f388eff5c9..b37a234ba55e4f4f0457278064f9fc173b4b6f5b 100644 (file)
@@ -35,16 +35,16 @@ public final class TestTextCharsAtom extends TestCase {
                0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 };
        private String alt_text = "This\u01A3";
 
-    public void testRecordType() throws Exception {
+    public void testRecordType() {
                TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
                assertEquals(4000l, tca.getRecordType());
        }
 
-       public void testTextA() throws Exception {
+       public void testTextA() {
                TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
                assertEquals(data_text, tca.getText());
        }
-       public void testTextB() throws Exception {
+       public void testTextB() {
                TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
                assertEquals(alt_text, tca.getText());
        }
index 22947132d486da5c8a39836e8b61fa4215c473a7..b2c819439f4ada238189bead209276752ea015b1 100644 (file)
@@ -32,11 +32,11 @@ public final class TestTextHeaderAtom extends TestCase {
        private byte[] title_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
        private byte[] body_data = new byte[]  { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
                assertEquals(3999l, tha.getRecordType());
        }
-       public void testTypes() throws Exception {
+       public void testTypes() {
                TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12);
                TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12);
                TextHeaderAtom b_tha = new TextHeaderAtom(body_data,0,12);
index b82e29b5c457916c695f5cb7ee340d84add1c697..3607dd4e3ab2198c0822718f2a52d09a2fbefff2 100644 (file)
@@ -33,11 +33,11 @@ public final class TestUserEditAtom extends TestCase {
                00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00,
                05, 00, 00, 00, 01, 00, 0xF6-256, 77 };
 
-    public void testRecordType() throws Exception {
+       public void testRecordType() {
                UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
                assertEquals(4085l, uea.getRecordType());
        }
-       public void testFlags() throws Exception {
+       public void testFlags() {
                UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
 
                assertEquals(256, uea.getLastViewedSlideID() );
index 5b43a6ad5097dc561eb6592013ddfe3520e56e76..4863c41a540bcc3ed8df45a19ae973c98ff26b42 100644 (file)
@@ -31,16 +31,16 @@ public final class TestCounts extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
-    public TestCounts() throws Exception {
+       public TestCounts() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testSheetsCount() throws Exception {
+       public void testSheetsCount() {
                Slide[] slides = ss.getSlides();
-               // Two sheets - master sheet is seperate
+               // Two sheets - master sheet is separate
                assertEquals(2, slides.length);
 
                // They are slides 1+2
@@ -56,7 +56,7 @@ public final class TestCounts extends TestCase {
                assertEquals(257, slides[1]._getSheetNumber());
        }
 
-    public void testNotesCount() throws Exception {
+       public void testNotesCount() {
                Notes[] notes = ss.getNotes();
                // Two sheets -> two notes
                // Note: there are also notes on the slide master
index 78c29357277b8093b0980aac766696da4a939a0d..fac33c5e075ff803f1d83b9a5537bdbb42ac6a15 100644 (file)
@@ -33,14 +33,14 @@ public final class TestMostRecentRecords extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
-    public TestMostRecentRecords() throws Exception {
+       public TestMostRecentRecords() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testCount() throws Exception {
+       public void testCount() {
                // Most recent core records
                Record[] mrcr = ss.getMostRecentCoreRecords();
 
@@ -48,7 +48,7 @@ public final class TestMostRecentRecords extends TestCase {
                assertEquals(7, mrcr.length);
        }
 
-    public void testRightRecordTypes() throws Exception {
+       public void testRightRecordTypes() {
                // Most recent core records
                Record[] mrcr = ss.getMostRecentCoreRecords();
 
@@ -69,7 +69,7 @@ public final class TestMostRecentRecords extends TestCase {
                assertEquals(1008, mrcr[6].getRecordType());
        }
 
-    public void testCorrectRecords() throws Exception {
+       public void testCorrectRecords() {
                // Most recent core records
                Record[] mrcr = ss.getMostRecentCoreRecords();
 
index 56638e2e987508ad02ddae0e43a12af1924831f5..e024c910d20de9eca8be888cf3a9fb0e99355e53 100644 (file)
@@ -31,14 +31,14 @@ public final class TestNotesText extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
-    public TestNotesText() throws Exception {
+       public TestNotesText() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testNotesOne() throws Exception {
+       public void testNotesOne() {
                Notes notes = ss.getNotes()[0];
 
                String[] expectText = new String[] {"These are the notes for page 1"};
@@ -46,9 +46,9 @@ public final class TestNotesText extends TestCase {
                for(int i=0; i<expectText.length; i++) {
                        assertEquals(expectText[i], notes.getTextRuns()[i].getText());
                }
-    }
+       }
 
-       public void testNotesTwo() throws Exception {
+       public void testNotesTwo() {
                Notes notes = ss.getNotes()[1];
                String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"};
                assertEquals(expectText.length, notes.getTextRuns().length);
index 24189ad2c8551ae663d7d561ddd38dc1af249bbb..bcd7616d5657d372d32feee9e46e7397edf71661 100644 (file)
@@ -34,7 +34,7 @@ public final class TestPictures extends TestCase{
 
     protected File cwd;
 
-    public void setUp() throws Exception {
+    public void setUp() {
         cwd = new File(System.getProperty("HSLF.testdata.path"));
     }
 
index da04a33d103a6c468026133f61c1c37e8810b5d4..72e6bd488e03f4195b6b41652e60bdbedc8d0e6d 100644 (file)
@@ -36,30 +36,30 @@ public final class TestRecordSetup extends TestCase {
        private SlideShow ss;
        private HSLFSlideShow hss;
 
-    public TestRecordSetup() throws Exception {
+       public TestRecordSetup() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testHandleParentAwareRecords() throws Exception {
-       Record[] records = hss.getRecords();
-       for(int i=0; i<records.length; i++) {
-               ensureParentAware(records[i],null);
-       }
+       public void testHandleParentAwareRecords() {
+               Record[] records = hss.getRecords();
+               for(int i=0; i<records.length; i++) {
+                       ensureParentAware(records[i],null);
+               }
+       }
+       private void ensureParentAware(Record r,RecordContainer parent) {
+               if(r instanceof ParentAwareRecord) {
+                       ParentAwareRecord pr = (ParentAwareRecord)r;
+                       assertEquals(parent, pr.getParentRecord());
+               }
+               if(r instanceof RecordContainer) {
+                       RecordContainer rc = (RecordContainer)r;
+                       Record[] children = rc.getChildRecords();
+                       for(int i=0; i<children.length; i++) {
+                               ensureParentAware(children[i], rc);
+                       }
+               }
        }
-    private void ensureParentAware(Record r,RecordContainer parent) {
-       if(r instanceof ParentAwareRecord) {
-               ParentAwareRecord pr = (ParentAwareRecord)r;
-               assertEquals(parent, pr.getParentRecord());
-       }
-       if(r instanceof RecordContainer) {
-               RecordContainer rc = (RecordContainer)r;
-               Record[] children = rc.getChildRecords();
-               for(int i=0; i<children.length; i++) {
-                       ensureParentAware(children[i], rc);
-               }
-       }
-    }
 }
index 9c10f8b0369cde3cd6e2e6d72e241eb88e3944c9..bb78de0bcc54d8aaf1ec61e6c08cdcaf2479c516 100644 (file)
@@ -31,14 +31,14 @@ public final class TestSheetText extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
-    public TestSheetText() throws Exception {
+       public TestSheetText() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testSheetOne() throws Exception {
+       public void testSheetOne() {
                Sheet slideOne = ss.getSlides()[0];
 
                String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"};
@@ -46,9 +46,9 @@ public final class TestSheetText extends TestCase {
                for(int i=0; i<expectText.length; i++) {
                        assertEquals(expectText[i], slideOne.getTextRuns()[i].getText());
                }
-    }
+       }
 
-       public void testSheetTwo() throws Exception {
+       public void testSheetTwo() {
                Sheet slideTwo = ss.getSlides()[1];
                String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"};
                assertEquals(expectText.length, slideTwo.getTextRuns().length);
@@ -80,7 +80,7 @@ public final class TestSheetText extends TestCase {
                        "Can they co-exist?\n\n" +
                        "Gay Harley\n" +
                        "Clean Development Alliance\n" +
-                       "COP 11 \u2013 MOP 1\n" + // special long hyphon
+                       "COP 11 \u2013 MOP 1\n" + // special long hyphen
                        "December 5, 2005\n";
 
                assertEquals(1, s.getTextRuns().length);
index 7eab827f1c93e0608598bd46fbde38aa92f29830..2cc111afbdbf1f057d365d907940a232397d7746 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hslf.usermodel;
 
-
 import junit.framework.TestCase;
 import org.apache.poi.hslf.*;
 import org.apache.poi.hslf.model.*;
@@ -33,7 +32,7 @@ public final class TestSlideOrdering extends TestCase {
        // Complex slideshow, record order doesn't match slide order
        private SlideShow ssB;
 
-    public TestSlideOrdering() throws Exception {
+       public TestSlideOrdering() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
 
                String filenameA = dirname + "/basic_test_ppt_file.ppt";
@@ -43,112 +42,93 @@ public final class TestSlideOrdering extends TestCase {
                String filenameB = dirname + "/incorrect_slide_order.ppt";
                HSLFSlideShow hssB = new HSLFSlideShow(filenameB);
                ssB = new SlideShow(hssB);
-    }
-
-    /**
-     * Test the simple case - record order matches slide order
-     */
-    public void testSimpleCase() throws Exception {
-       assertEquals(2, ssA.getSlides().length);
-
-       Slide s1 = ssA.getSlides()[0];
-       Slide s2 = ssA.getSlides()[1];
-
-       String[] firstTRs = new String[] {
-                       "This is a test title",
-                       "This is the title on page 2"
-       };
-
-       assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
-       assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
-    }
-
-    /**
-     * Test the complex case - record order differs from slide order
-     */
-    public void testComplexCase() throws Exception {
-       assertEquals(3, ssB.getSlides().length);
-
-       Slide s1 = ssB.getSlides()[0];
-       Slide s2 = ssB.getSlides()[1];
-       Slide s3 = ssB.getSlides()[2];
-
-       String[] firstTRs = new String[] {
-                       "Slide 1",
-                       "Slide 2",
-                       "Slide 3"
-       };
-
-       assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
-       assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
-       assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
-    }
-
-    /**
-     * Assert that the order of slides is correct.
-     *
-     * @param filename  file name of the slide show to assert
-     * @param titles    array of reference slide titles
-     */
-    protected void assertSlideOrdering(String filename, String[] titles) throws Exception {
-        SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));
-        Slide[] slide = ppt.getSlides();
-
-        assertEquals(titles.length, slide.length);
-        for (int i = 0; i < slide.length; i++) {
-            String title = slide[i].getTitle();
-            assertEquals("Wrong slide title in " + filename, titles[i], title);
-        }
-    }
-
-    public void testTitles() throws Exception{
-        String dirname = System.getProperty("HSLF.testdata.path");
-
-        assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt",
-                new String[]{
-                    "This is a test title",
-                    "This is the title on page 2"
-                });
-
-        assertSlideOrdering(dirname + "/incorrect_slide_order.ppt",
-                new String[]{
-                    "Slide 1",
-                    "Slide 2",
-                    "Slide 3"
-                });
-
-        assertSlideOrdering(dirname + "/next_test_ppt_file.ppt",
-                new String[]{
-                    "This is a test title",
-                    "This is the title on page 2"
-                });
-
-        assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt",
-                new String[]{
-                    "This is a title, it" + (char)0x2019 +"s in black"
-                });
-
-        assertSlideOrdering(dirname + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
-                new String[]{
-                    "This is a title, it"+ (char)0x2019 +"s in black"
-                });
-
-        assertSlideOrdering(dirname + "/ParagraphStylesShorterThanCharStyles.ppt",
-                new String[]{
-                    "ROMANCE: AN ANALYSIS",
-                    "AGENDA",
-                    "You are an important supplier of various items that I need",
-                    '\n' + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
-                    "Since the time that we seriously go out together, you rank highly among existing relationships",
-                    "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
-                    "Your physical characteristics are strong when compared with your competition",
-                    "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
-                    "When people found out that we were going out, their responses have been mixed",
-                    "The benchmark of relationship lifecycles, suggests that we are on schedule",
-                    "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
-                    "THE ANSWER",
-                    "Unfortunately a huge disconnect exists between my needs and your existing service",
-                    "SUMMARY",
-                });
-    }
+       }
+
+       /**
+        * Test the simple case - record order matches slide order
+        */
+       public void testSimpleCase() {
+               assertEquals(2, ssA.getSlides().length);
+
+               Slide s1 = ssA.getSlides()[0];
+               Slide s2 = ssA.getSlides()[1];
+
+               String[] firstTRs = new String[] { "This is a test title", "This is the title on page 2" };
+
+               assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
+               assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
+       }
+
+       /**
+        * Test the complex case - record order differs from slide order
+        */
+       public void testComplexCase() {
+               assertEquals(3, ssB.getSlides().length);
+
+               Slide s1 = ssB.getSlides()[0];
+               Slide s2 = ssB.getSlides()[1];
+               Slide s3 = ssB.getSlides()[2];
+
+               String[] firstTRs = new String[] { "Slide 1", "Slide 2", "Slide 3" };
+
+               assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
+               assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
+               assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
+       }
+
+       /**
+        * Assert that the order of slides is correct.
+        *
+        * @param filename
+        *            file name of the slide show to assert
+        * @param titles
+        *            array of reference slide titles
+        */
+       protected void assertSlideOrdering(String filename, String[] titles) throws Exception {
+               SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));
+               Slide[] slide = ppt.getSlides();
+
+               assertEquals(titles.length, slide.length);
+               for (int i = 0; i < slide.length; i++) {
+                       String title = slide[i].getTitle();
+                       assertEquals("Wrong slide title in " + filename, titles[i], title);
+               }
+       }
+
+       public void testTitles() throws Exception {
+               String dirname = System.getProperty("HSLF.testdata.path");
+
+               assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt", new String[] {
+                               "This is a test title", "This is the title on page 2" });
+
+               assertSlideOrdering(dirname + "/incorrect_slide_order.ppt", new String[] { "Slide 1",
+                               "Slide 2", "Slide 3" });
+
+               assertSlideOrdering(dirname + "/next_test_ppt_file.ppt", new String[] {
+                               "This is a test title", "This is the title on page 2" });
+
+               assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt",
+                               new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
+
+               assertSlideOrdering(dirname + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
+                               new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
+
+               assertSlideOrdering(
+                               dirname + "/ParagraphStylesShorterThanCharStyles.ppt",
+                               new String[] {
+                                               "ROMANCE: AN ANALYSIS",
+                                               "AGENDA",
+                                               "You are an important supplier of various items that I need",
+                                               '\n' + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
+                                               "Since the time that we seriously go out together, you rank highly among existing relationships",
+                                               "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
+                                               "Your physical characteristics are strong when compared with your competition",
+                                               "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
+                                               "When people found out that we were going out, their responses have been mixed",
+                                               "The benchmark of relationship lifecycles, suggests that we are on schedule",
+                                               "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
+                                               "THE ANSWER",
+                                               "Unfortunately a huge disconnect exists between my needs and your existing service",
+                                               "SUMMARY", });
+       }
 }
index 5cb99cbf83dd53b028c21f234d8db4e820debc63..73c3a03e70a1a21cbc7cdc6eda10495a1bcc589b 100644 (file)
@@ -27,107 +27,96 @@ import junit.framework.TestCase;
 
 /**
  * Tests to verify that the library can read blank msg files.
- * 
+ *
  * @author Travis Ferguson
  *
  */
-public class TestBlankFileRead extends TestCase {
+public final class TestBlankFileRead extends TestCase {
        private MAPIMessage mapiMessage;
-       
+
        /**
         * Initialize this test, load up the blank.msg mapi message.
-        * @throws IOException 
         */
        public TestBlankFileRead() throws IOException {
                String dirname = System.getProperty("HSMF.testdata.path");
                this.mapiMessage = new MAPIMessage(dirname + "/blank.msg");
        }
-       
-       /** 
+
+       /**
         * Check if we can read the body of the blank message, we expect "".
-        * 
-        * @throws Exception
         */
        public void testReadBody() throws Exception {
                try {
-                       mapiMessage.getTextBody();              
+                       mapiMessage.getTextBody();
                } catch(ChunkNotFoundException exp) {
                        return;
                }
-               
+
                TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
        }
-       
+
 
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
         */
        public void testReadDisplayCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayCC();
                String expected = "";
-               
+
                TestCase.assertEquals(expected, obtained);
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
         */
        public void testReadDisplayTo() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayTo();
                String expected = "";
-               
+
                TestCase.assertEquals(expected, obtained);
        }
-       
+
        /**
         * Test to see if we can read the FROM Chunk.
-        * @throws ChunkNotFoundException 
-        * 
         */
-       public void testReadDisplayFrom() throws ChunkNotFoundException {
+       public void testReadDisplayFrom() {
                try {
-                       mapiMessage.getDisplayFrom();           
+                       mapiMessage.getDisplayFrom();
                } catch(ChunkNotFoundException exp) {
                        return;
                }
-               
+
                TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
         */
        public void testReadDisplayBCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayBCC();
                String expected = "";
-               
+
                TestCase.assertEquals(expected, obtained);
        }
-       
-       
+
+
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadSubject() throws Exception {
                String obtained = mapiMessage.getSubject();
                TestCase.assertEquals("", obtained);
        }
-       
-       
+
+
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
-       public void testReadConversationTopic() throws Exception {
+       public void testReadConversationTopic() {
                try {
                        mapiMessage.getConversationTopic();
                } catch(ChunkNotFoundException exp) {
@@ -135,6 +124,6 @@ public class TestBlankFileRead extends TestCase {
                }
                TestCase.fail("We shouldn't have a ConversationTopic node on the blank.msg file.");
        }
-       
-       
+
+
 }
index 1adb68b809b5eb52a69a1e2d68bc7fdef4d1d2a6..0819d58fa513bdeecf87c17691e7e567ced7db24 100644 (file)
@@ -19,13 +19,14 @@ package org.apache.poi.hwpf;
 
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.List;
 
+import junit.framework.TestCase;
+
 import org.apache.poi.hwpf.model.PicturesTable;
 import org.apache.poi.hwpf.usermodel.Picture;
 
-import junit.framework.TestCase;
-
 /**
  * Test picture support in HWPF
  * @author nick
@@ -34,25 +35,25 @@ public final class TestHWPFPictures extends TestCase {
        private String docAFile;
        private String docBFile;
        private String docCFile;
-    private String docDFile;
+       private String docDFile;
 
        private String imgAFile;
        private String imgBFile;
        private String imgCFile;
-    private String imgDFile;
+       private String imgDFile;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
                String dirname = System.getProperty("HWPF.testdata.path");
 
                docAFile = dirname + "/testPictures.doc";
                docBFile = dirname + "/two_images.doc";
                docCFile = dirname + "/vector_image.doc";
-        docDFile = dirname + "/GaiaTest.doc";
+               docDFile = dirname + "/GaiaTest.doc";
 
                imgAFile = dirname + "/simple_image.jpg";
                imgBFile = dirname + "/simple_image.png";
                imgCFile = dirname + "/vector_image.emf";
-        imgDFile = dirname + "/GaiaTestImg.png";
+               imgDFile = dirname + "/GaiaTestImg.png";
        }
 
        /**
@@ -134,21 +135,20 @@ public final class TestHWPFPictures extends TestCase {
         * Pending the missing files being uploaded to
         *  bug #44937
         */
-    public void BROKENtestEscherDrawing() throws Exception
-    {
-        HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
-        List allPictures = docD.getPicturesTable().getAllPictures();
+       public void BROKENtestEscherDrawing() throws Exception {
+               HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
+               List allPictures = docD.getPicturesTable().getAllPictures();
 
-        assertEquals(1, allPictures.size());
+               assertEquals(1, allPictures.size());
 
-        Picture pic = (Picture) allPictures.get(0);
-        assertNotNull(pic);
-        byte[] picD = readFile(imgDFile);
+               Picture pic = (Picture) allPictures.get(0);
+               assertNotNull(pic);
+               byte[] picD = readFile(imgDFile);
 
-        assertEquals(picD.length, pic.getContent().length);
+               assertEquals(picD.length, pic.getContent().length);
 
-        assertBytesSame(picD, pic.getContent());
-    }
+               assertBytesSame(picD, pic.getContent());
+       }
 
        private void assertBytesSame(byte[] a, byte[] b) {
                assertEquals(a.length, b.length);
@@ -157,17 +157,22 @@ public final class TestHWPFPictures extends TestCase {
                }
        }
 
-       private byte[] readFile(String file) throws Exception {
+       private static byte[] readFile(String file) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               FileInputStream fis = new FileInputStream(file);
-               byte[] buffer = new byte[1024];
-
-               int read = 0;
-               while(read > -1) {
-                       read = fis.read(buffer);
-                       if(read > 0) {
-                               baos.write(buffer,0,read);
+               try {
+                       FileInputStream fis = new FileInputStream(file);
+                       byte[] buffer = new byte[1024];
+
+                       int read = 0;
+                       while(read > -1) {
+                               read = fis.read(buffer);
+                               if(read > 0) {
+                                       baos.write(buffer,0,read);
+                               }
                        }
+                       fis.close();
+               } catch (IOException e) {
+                       throw new RuntimeException(e);
                }
 
                return baos.toByteArray();
index 283cae027f8448b297acd5ca944dcda860a32d0a..bda94653012bba0369f868e0b9c6b4b7a28b49f9 100644 (file)
@@ -65,12 +65,12 @@ public final class TestHWPFRangeParts extends TestCase {
                "The trick with this one is that it contains some Unicode based strings in it.\r" +
                "Firstly, some currency symbols:\r" +
                "\tGBP - \u00a3\r" +
-        "\tEUR - \u20ac\r" +
-        "Now, we\u2019ll have some French text, in bold and big:\r" +
-        "\tMoli\u00e8re\r" +
-        "And some normal French text:\r" +
-        "\tL'Avare ou l'\u00c9cole du mensonge\r" +
-        "That\u2019s it for page one\r"
+               "\tEUR - \u20ac\r" +
+               "Now, we\u2019ll have some French text, in bold and big:\r" +
+               "\tMoli\u00e8re\r" +
+               "And some normal French text:\r" +
+               "\tL'Avare ou l'\u00c9cole du mensonge\r" +
+               "That\u2019s it for page one\r"
        ;
        private static final String u_page_2 =
                "This is page two. Les Pr\u00e9cieuses ridicules. The end.\r"
@@ -109,7 +109,7 @@ public final class TestHWPFRangeParts extends TestCase {
                );
        }
 
-       public void testBasics() throws Exception {
+       public void testBasics() {
                // First check the start and end bits
                assertEquals(
                                0,
@@ -142,7 +142,7 @@ public final class TestHWPFRangeParts extends TestCase {
                );
        }
 
-       public void testContents() throws Exception {
+       public void testContents() {
                Range r;
 
                // Now check the real ranges
@@ -179,7 +179,7 @@ public final class TestHWPFRangeParts extends TestCase {
                );
        }
 
-       public void testBasicsUnicode() throws Exception {
+       public void testBasicsUnicode() {
                // First check the start and end bits
                assertEquals(
                                0,
@@ -213,7 +213,7 @@ public final class TestHWPFRangeParts extends TestCase {
                );
        }
 
-       public void testContentsUnicode() throws Exception {
+       public void testContentsUnicode() {
                Range r;
 
                // Now check the real ranges
index 261c9e6b6650658840fca1b0a128838d10528147..a945540a0a31be45d2e55c2e8037e5781297878e 100644 (file)
@@ -111,7 +111,7 @@ public final class TestWordExtractor extends TestCase {
     /**
      * Test textPieces based extraction
      */
-    public void testExtractFromTextPieces() throws Exception {
+    public void testExtractFromTextPieces() {
        String text = extractor.getTextFromPieces();
        assertEquals(p_text1_block, text);
     }
index 585c534ed942bc570705452b1f3e0e31a28d9b4a..6cae52ccd39ee4ac7126d6567f47d790625a5780 100644 (file)
@@ -28,11 +28,11 @@ import junit.framework.TestCase;
  */
 public final class TestWordExtractorBugs extends TestCase {
        private String dirname;
-    protected void setUp() throws Exception {
+       protected void setUp() {
                dirname = System.getProperty("HWPF.testdata.path");
-    }
+       }
 
-    public void testProblemMetadata() throws Exception {
+       public void testProblemMetadata() throws Exception {
                String filename = dirname + "/ProblemExtracting.doc";
                WordExtractor extractor =
                        new WordExtractor(new FileInputStream(filename));
@@ -41,6 +41,5 @@ public final class TestWordExtractorBugs extends TestCase {
                extractor.getText();
                extractor.getParagraphText();
                extractor.getTextFromPieces();
-    }
-
+       }
 }
index f750a59a6d3e6193e28f0d7c221e5b96abeedd8c..779847e27eca3813072f587cc1141884f94caf62 100755 (executable)
@@ -29,7 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument;
 public class TestBug46610 extends TestCase {
   private String dirname;
 
-  protected void setUp() throws Exception {
+  protected void setUp() {
     dirname = System.getProperty("HWPF.testdata.path");
   }
 
index 1a48ab6b605a5fdf997ee65eb9c1d7b0b6a6169a..13913eab048ea293fb1a7903f7cc5e69ffb9fe9d 100644 (file)
@@ -25,8 +25,7 @@ import junit.framework.TestCase;
 import org.apache.poi.hwpf.HWPFDocument;
 
 /**
- * Tests for the handling of header stories into
- *  headers, footers etc
+ * Tests for the handling of header stories into headers, footers etc
  */
 public final class TestHeaderStories extends TestCase {
        private HWPFDocument none;
@@ -38,71 +37,60 @@ public final class TestHeaderStories extends TestCase {
        private HWPFDocument unicode;
        private HWPFDocument withFields;
 
-    protected void setUp() throws Exception {
+       protected void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
 
-               none = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "NoHeadFoot.doc"))
-               );
-               header = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "ThreeColHead.doc"))
-               );
-               footer = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "ThreeColFoot.doc"))
-               );
-               headerFooter = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "SimpleHeadThreeColFoot.doc"))
-               );
-               oddEven = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "PageSpecificHeadFoot.doc"))
-               );
-               diffFirst = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "DiffFirstPageHeadFoot.doc"))
-               );
+               none = new HWPFDocument(new FileInputStream(new File(dirname, "NoHeadFoot.doc")));
+               header = new HWPFDocument(new FileInputStream(new File(dirname, "ThreeColHead.doc")));
+               footer = new HWPFDocument(new FileInputStream(new File(dirname, "ThreeColFoot.doc")));
+               headerFooter = new HWPFDocument(new FileInputStream(new File(dirname,
+                               "SimpleHeadThreeColFoot.doc")));
+               oddEven = new HWPFDocument(new FileInputStream(
+                               new File(dirname, "PageSpecificHeadFoot.doc")));
+               diffFirst = new HWPFDocument(new FileInputStream(new File(dirname,
+                               "DiffFirstPageHeadFoot.doc")));
                unicode = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc"))
-               );
+                               new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc")));
                withFields = new HWPFDocument(
-                               new FileInputStream(new File(dirname, "HeaderWithMacros.doc"))
-               );
-    }
+                               new FileInputStream(new File(dirname, "HeaderWithMacros.doc")));
+       }
 
-    public void testNone() throws Exception {
-       HeaderStories hs = new HeaderStories(none);
+       public void testNone() {
+               HeaderStories hs = new HeaderStories(none);
 
-       assertNull(hs.getPlcfHdd());
-       assertEquals(0, hs.getRange().text().length());
-    }
+               assertNull(hs.getPlcfHdd());
+               assertEquals(0, hs.getRange().text().length());
+       }
 
-    public void testHeader() throws Exception {
-       HeaderStories hs = new HeaderStories(header);
+       public void testHeader() {
+               HeaderStories hs = new HeaderStories(header);
 
-       assertEquals(60, hs.getRange().text().length());
+               assertEquals(60, hs.getRange().text().length());
 
-       // Should have the usual 6 separaters
-       // Then all 6 of the different header/footer kinds
-       // Finally a terminater
-       assertEquals(13, hs.getPlcfHdd().length());
+               // Should have the usual 6 separaters
+               // Then all 6 of the different header/footer kinds
+               // Finally a terminater
+               assertEquals(13, hs.getPlcfHdd().length());
 
-       assertEquals(215, hs.getRange().getStartOffset());
+               assertEquals(215, hs.getRange().getStartOffset());
 
-       assertEquals(0, hs.getPlcfHdd().getProperty(0).getStart());
-       assertEquals(3, hs.getPlcfHdd().getProperty(1).getStart());
-       assertEquals(6, hs.getPlcfHdd().getProperty(2).getStart());
-       assertEquals(6, hs.getPlcfHdd().getProperty(3).getStart());
-       assertEquals(9, hs.getPlcfHdd().getProperty(4).getStart());
-       assertEquals(12, hs.getPlcfHdd().getProperty(5).getStart());
+               assertEquals(0, hs.getPlcfHdd().getProperty(0).getStart());
+               assertEquals(3, hs.getPlcfHdd().getProperty(1).getStart());
+               assertEquals(6, hs.getPlcfHdd().getProperty(2).getStart());
+               assertEquals(6, hs.getPlcfHdd().getProperty(3).getStart());
+               assertEquals(9, hs.getPlcfHdd().getProperty(4).getStart());
+               assertEquals(12, hs.getPlcfHdd().getProperty(5).getStart());
 
-       assertEquals(12, hs.getPlcfHdd().getProperty(6).getStart());
-       assertEquals(12, hs.getPlcfHdd().getProperty(7).getStart());
-       assertEquals(59, hs.getPlcfHdd().getProperty(8).getStart());
-       assertEquals(59, hs.getPlcfHdd().getProperty(9).getStart());
-       assertEquals(59, hs.getPlcfHdd().getProperty(10).getStart());
-       assertEquals(59, hs.getPlcfHdd().getProperty(11).getStart());
+               assertEquals(12, hs.getPlcfHdd().getProperty(6).getStart());
+               assertEquals(12, hs.getPlcfHdd().getProperty(7).getStart());
+               assertEquals(59, hs.getPlcfHdd().getProperty(8).getStart());
+               assertEquals(59, hs.getPlcfHdd().getProperty(9).getStart());
+               assertEquals(59, hs.getPlcfHdd().getProperty(10).getStart());
+               assertEquals(59, hs.getPlcfHdd().getProperty(11).getStart());
 
-       assertEquals(59, hs.getPlcfHdd().getProperty(12).getStart());
+               assertEquals(59, hs.getPlcfHdd().getProperty(12).getStart());
 
-       assertEquals("\u0003\r\r", hs.getFootnoteSeparator());
+               assertEquals("\u0003\r\r", hs.getFootnoteSeparator());
                assertEquals("\u0004\r\r", hs.getFootnoteContSeparator());
                assertEquals("", hs.getFootnoteContNote());
                assertEquals("\u0003\r\r", hs.getEndnoteSeparator());
@@ -113,63 +101,65 @@ public final class TestHeaderStories extends TestCase {
                assertEquals("", hs.getEvenHeader());
                assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
 
-
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("", hs.getOddFooter());
-    }
+       }
 
-    public void testFooter() throws Exception {
-       HeaderStories hs = new HeaderStories(footer);
+       public void testFooter() {
+               HeaderStories hs = new HeaderStories(footer);
 
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("", hs.getOddHeader()); // Was \r\r but gets emptied
 
-
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
-    }
+       }
 
-    public void testHeaderFooter() throws Exception {
-       HeaderStories hs = new HeaderStories(headerFooter);
+       public void testHeaderFooter() {
+               HeaderStories hs = new HeaderStories(headerFooter);
 
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("I am some simple header text here\r\r\r", hs.getOddHeader());
 
-
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
-    }
+       }
 
-    public void testOddEven() throws Exception {
-       HeaderStories hs = new HeaderStories(oddEven);
+       public void testOddEven() {
+               HeaderStories hs = new HeaderStories(oddEven);
 
                assertEquals("", hs.getFirstHeader());
-               assertEquals("[This is an Even Page, with a Header]\u0007August 20, 2008\u0007\u0007\r\r", hs.getEvenHeader());
-               assertEquals("August 20, 2008\u0007[ODD Page Header text]\u0007\u0007\r\r", hs.getOddHeader());
-
+               assertEquals("[This is an Even Page, with a Header]\u0007August 20, 2008\u0007\u0007\r\r",
+                               hs.getEvenHeader());
+               assertEquals("August 20, 2008\u0007[ODD Page Header text]\u0007\u0007\r\r", hs
+                               .getOddHeader());
 
                assertEquals("", hs.getFirstFooter());
-               assertEquals("\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getEvenFooter());
+               assertEquals(
+                               "\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r",
+                               hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
 
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(1));
-               assertEquals("\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getFooter(2));
+               assertEquals(
+                               "\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r",
+                               hs.getFooter(2));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
-    }
+       }
 
-    public void testFirst() throws Exception {
-       HeaderStories hs = new HeaderStories(diffFirst);
+       public void testFirst() {
+               HeaderStories hs = new HeaderStories(diffFirst);
 
-               assertEquals("I am the header on the first page, and I\u2019m nice and simple\r\r", hs.getFirstHeader());
+               assertEquals("I am the header on the first page, and I\u2019m nice and simple\r\r", hs
+                               .getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
 
-
                assertEquals("The footer of the first page\r\r", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
@@ -177,29 +167,31 @@ public final class TestHeaderStories extends TestCase {
                assertEquals("The footer of the first page\r\r", hs.getFooter(1));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(2));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
-    }
+       }
 
-    public void testUnicode() throws Exception {
-       HeaderStories hs = new HeaderStories(unicode);
+       public void testUnicode() {
+               HeaderStories hs = new HeaderStories(unicode);
 
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
-               assertEquals("This is a simple header, with a \u20ac euro symbol in it.\r\r\r", hs.getOddHeader());
-
+               assertEquals("This is a simple header, with a \u20ac euro symbol in it.\r\r\r", hs
+                               .getOddHeader());
 
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("The footer, with Moli\u00e8re, has Unicode in it.\r\r", hs.getOddFooter());
-    }
+       }
 
-    public void testWithFields() throws Exception {
-       HeaderStories hs = new HeaderStories(withFields);
-       assertFalse(hs.areFieldsStripped());
+       public void testWithFields() {
+               HeaderStories hs = new HeaderStories(withFields);
+               assertFalse(hs.areFieldsStripped());
 
-       assertEquals("HEADER GOES HERE. 8/12/2008 \u0013 AUTHOR   \\* MERGEFORMAT \u0014Eric Roch\u0015\r\r\r", hs.getOddHeader());
+               assertEquals(
+                               "HEADER GOES HERE. 8/12/2008 \u0013 AUTHOR   \\* MERGEFORMAT \u0014Eric Roch\u0015\r\r\r",
+                               hs.getOddHeader());
 
-       // Now turn on stripping
-       hs.setAreFieldsStripped(true);
-       assertEquals("HEADER GOES HERE. 8/12/2008 Eric Roch\r\r\r", hs.getOddHeader());
-    }
+               // Now turn on stripping
+               hs.setAreFieldsStripped(true);
+               assertEquals("HEADER GOES HERE. 8/12/2008 Eric Roch\r\r\r", hs.getOddHeader());
+       }
 }
index 7fc362e3b7521b38410921ee4c504d69a76f373e..0ae09c8f4ca990486c3ed055bdbfdbba55bcbf28 100644 (file)
@@ -24,7 +24,7 @@ import junit.framework.TestCase;
  *  text replacement or textual contents
  */
 public final class TestRange extends TestCase {
-       public void testFieldStripping() throws Exception {
+       public void testFieldStripping() {
                String exp = "This is some text.";
 
                String single = "This is some \u0013Blah!\u0015text.";
index 6468e3e370f0dbef2e34ed31ed298348d7982b7d..5e08588a293355efb7c0043adc35d38cc9889a4d 100644 (file)
@@ -47,7 +47,7 @@ public final class TestRangeDelete extends TestCase {
 
        private String illustrativeDocFile;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
 
                String dirname = System.getProperty("HWPF.testdata.path");
 
index 76452622f7fc9202ecfdbd6f911ce49cb48d1ca9..cdae245ece62abb86a25965d86067e3a1b333d9a 100644 (file)
@@ -39,7 +39,7 @@ public final class TestRangeInsertion extends TestCase {
 
        private String illustrativeDocFile;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
 
                String dirname = System.getProperty("HWPF.testdata.path");
 
index 05e3d2ca24fee7711ee78e49bcf0ffaa3e495565..96f1493bdf0fb385652ee9cc40c308654d3f75e6 100644 (file)
@@ -79,7 +79,7 @@ public final class TestRangeProperties extends TestCase {
        }
 
 
-       public void testAsciiTextParagraphs() throws Exception {
+       public void testAsciiTextParagraphs() {
                Range r = a.getRange();
                assertEquals(
                                a_page_1 +
@@ -138,7 +138,7 @@ public final class TestRangeProperties extends TestCase {
                );
        }
 
-       public void testAsciiStyling() throws Exception {
+       public void testAsciiStyling() {
                Range r = a.getRange();
 
                Paragraph p1 = r.getParagraph(0);
@@ -160,7 +160,7 @@ public final class TestRangeProperties extends TestCase {
         * Tests the raw definitions of the paragraphs of
         *  a unicode document
         */
-       public void testUnicodeParagraphDefinitions() throws Exception {
+       public void testUnicodeParagraphDefinitions() {
                Range r = u.getRange();
                String[] p1_parts = u_page_1.split("\r");
                String[] p2_parts = u_page_2.split("\r");
@@ -251,7 +251,7 @@ public final class TestRangeProperties extends TestCase {
        /**
         * Tests the paragraph text of a unicode document
         */
-       public void testUnicodeTextParagraphs() throws Exception {
+       public void testUnicodeTextParagraphs() {
                Range r = u.getRange();
                assertEquals(
                                u_page_1 +
@@ -281,7 +281,7 @@ public final class TestRangeProperties extends TestCase {
                assertEquals(page_break + "\r", r.getParagraph(10).text());
                assertEquals(p2_parts[0] + "\r", r.getParagraph(11).text());
        }
-       public void testUnicodeStyling() throws Exception {
+       public void testUnicodeStyling() {
                Range r = u.getRange();
                String[] p1_parts = u_page_1.split("\r");
 
index 794979d0fad4f609f4619ea8d2a3939b8d87748f..dc32b24a3d52f62d6ebd056b8b14e9db7b428c21 100644 (file)
@@ -42,7 +42,7 @@ public final class TestRangeReplacement extends TestCase {
 
        private String illustrativeDocFile;
 
-       protected void setUp() throws Exception {
+       protected void setUp() {
 
                String dirname = System.getProperty("HWPF.testdata.path");
 
index 2e877acf129ea7cbff7d2addc515cbe4203bf3a4..47f2c0be979167da17998cfa966d5f96f7266afb 100644 (file)
@@ -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();
        }
index 8db7c4be385cfed545bf9bee1349eee6f708f22d..3b947e693d36879ebb7f6a21243f192cf8b8f66c 100644 (file)
@@ -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 " +
index 83161d5b45e3d71ec19fae4446589f9ea73a6ebd..f1713533aa3bf6ecca9be29bee1c7c637ec8f5dc 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    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());
     }
-
 }
index 9cf14e47b439e501053b3db693dfc14883cade08..757972de9f60cfb44179eae3b5c286f64fa2b78b 100644 (file)
@@ -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 );
index 3a189353d0e6b16eb18f6f444acc99b410dc0aff..e05cbc6badad621c99cfbb0bee3e618088e35083 100644 (file)
    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);
-    }
+       }
 }
index 8557f2b4a134d1f84ece4085536daf3b9e571a28..138b80af8e7657221fc075c34648549dad78c827 100644 (file)
    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() );
     }
-
 }
index f416ec941c073492e7896f45b5e208ce8b291c75..75a5980cf6f90131de9dc8ab86361844c22487f4 100644 (file)
@@ -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
+}
index 415cca33f1a4e79d778a5376c0513828698cb636..ae4245ec4be870fcb13826ad970fccd5938f391a 100644 (file)
@@ -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);
index f89297390cd36c36c00c40b3adefa5cd679c8432..c7939e33a57a2b8f950e9afba2de352f36f055f2 100644 (file)
@@ -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
+}
index 00d5c8c11136d3da513e7f979969ba752a7d322c..6aaa509a559f5b2de20cb0e9b0062563b366b477 100644 (file)
@@ -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]);
+       }
 }
index a93bed20c21cff024afffbf74ef0a3b57ad0c65c..48449f40f041f651664286e554e18a86c00f44fa 100644 (file)
@@ -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) {
index 0dd5758479199c45981c32f4aab050528073c626..61125ac46b28dc0e2274bd7869eda46fc146c797 100644 (file)
@@ -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());
     }
 }
-
-
index a7d140cae2caf137a0b13a361bffd1844fe85a8c..1913e078a4804f12ab7aaa9a96db26aaf789fdad 100644 (file)
@@ -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());
     }
 }
-
-
index a80ce11837e3bd3c0a3b9b6b0fcdd10e75c59604..f05b57f737e468d976d61ae560805f9ffc143f82 100644 (file)
@@ -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());
     }
 }
-
-
index e4b89abb31ca836861660cff65e27fb5aece46fd..93ab765339ad290a5689c9ec27314f96ff3d351c 100644 (file)
@@ -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());
     }
 }
-
-
index 2131777f8006878219dcbeaffa0c4bb420eb698d..f017de980d1e2092ac54d20658066d5ff51ff7b9 100644 (file)
@@ -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());
     }
 }
-
-
index 3c9f439752293ac79b906e414260770ac491517c..3ca33a2e82de1926cbf6ceacb6204eb999a97e4c 100644 (file)
@@ -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());
     }
 }
-
-
index 2c2c2ea0c380265e9cea17586625ffa0101bc797..43ffd6cb1e8776b1149108ea114b7302a93b9052 100644 (file)
@@ -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);
                }
index 266200b2d2e9d1014dba435cc8d6c682e22c7be5..6ab59fa2df3712573f2ea2df323f602cf59260e3 100644 (file)
@@ -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());
     }
index 2535f6413081739d5b678004aaf088e90c3c8e04..6dbd4bce872e62cf67fa0f7e6d825c769a17b843 100644 (file)
@@ -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('='));
     }
-
 }
index ba791bf58a4e9099e19864ec405194449012178c..d94cfd9a96b25dbbd1e95619fa6907d7a1af6711 100644 (file)
@@ -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
+}
index 98ccbf0394f9442257e15a3f1da034b0e9dc3598..3e2feaed021a3b7c3927e1fd76621bc6d674b3e9 100644 (file)
@@ -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);
     }
 }
index 5de4fc787b149b5631f246378135b60bcf65ea30..d24371de5829cdc2a3c6b1f7e784adec772f3e51 100644 (file)
@@ -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);
         }
-
     }
-
 }
index 431fa2d7d5092e9289ebd2180dc7ab24655accd4..8bbbc06d506717109e05c16794b7ece3f65791a1 100755 (executable)
@@ -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
+}
index 454a297105b4719eace241645ceba889641e9626..f863dd980d8aa4af2d888bdec55a628bd01c6073 100755 (executable)
@@ -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;
index 3ce255a0e4150331d76c8934efb097a0deb39fd0..39050ccd8cccad106573ff383948bd7703c1490b 100644 (file)
 
 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);
     }
 }
index a14c2510b51a3a37e5767b40e7a0645025a27414..8ce707d9aa1e4c723a2750044faf58ae3531c834 100644 (file)
@@ -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");
index ddd9101593a3d6e875176d333ba51a51678d6fe8..52b88d34efa7efad048d3f87c2a622a131f9ab5b 100644 (file)
@@ -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));
index a90aa290805dc186adb55a755263fd469a89bbc6..b0efff9c6d787afa825a544fb36f4bc5c87f8581 100644 (file)
@@ -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");
     }
-
 }
index bfaed8d37090502ccbb12ea805c5cbd88a36b6d0..d5a929dd9e060c2de6ee2f5b6e52f2bf4cbecded 100755 (executable)
@@ -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
+}
index 98284df7c8a42d1a3baf0f41be03bfa0dbc7f598..2a81023ed5622204e5d7445265ea1490fd9eea26 100755 (executable)
@@ -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
+}