diff options
author | Dominik Stadler <centic@apache.org> | 2014-06-11 20:36:30 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2014-06-11 20:36:30 +0000 |
commit | 427d733469c6a0c7293b60debeb6622d39d19238 (patch) | |
tree | 55813e78030a3a3bd6f28eeb2fd8e5cf237be6eb /src/testcases/org | |
parent | 267d70569ade0505d90564648979351ced3f24c6 (diff) | |
download | poi-427d733469c6a0c7293b60debeb6622d39d19238.tar.gz poi-427d733469c6a0c7293b60debeb6622d39d19238.zip |
Add missing @Overrides, reformat some files, increase coverage slightly,
comments, fix Eclipse warnings and add close() calls in some tests and
in HMEFMessage() to close files during tests correctly.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1602008 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
5 files changed, 69 insertions, 8 deletions
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java index 348dcc8674..6efa51bb5f 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java @@ -268,7 +268,7 @@ public class TestWrite assertNotNull(psa[0]); assertTrue(psa[0].isSummaryInformation()); - final Section s = (Section) (psa[0].getSections().get(0)); + final Section s = (psa[0].getSections().get(0)); Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR); Object p2 = s.getProperty(PropertyIDMap.PID_TITLE); assertEquals(AUTHOR, p1); @@ -349,11 +349,11 @@ public class TestWrite stream.close(); } assertNotNull(psa[0]); - Section s = (Section) (psa[0].getSections().get(0)); + Section s = (psa[0].getSections().get(0)); assertEquals(s.getFormatID(), formatID); Object p = s.getProperty(2); assertEquals(SECTION1, p); - s = (Section) (psa[0].getSections().get(1)); + s = (psa[0].getSections().get(1)); p = s.getProperty(2); assertEquals(SECTION2, p); } @@ -584,7 +584,7 @@ public class TestWrite PropertySet psr = new PropertySet(bytes); assertTrue(psr.isSummaryInformation()); - Section sr = (Section) psr.getSections().get(0); + Section sr = psr.getSections().get(0); String title = (String) sr.getProperty(PropertyIDMap.PID_TITLE); assertEquals(TITLE, title); } diff --git a/src/testcases/org/apache/poi/hpsf/basic/Util.java b/src/testcases/org/apache/poi/hpsf/basic/Util.java index 3af8cd94f9..8eca84b65c 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/Util.java +++ b/src/testcases/org/apache/poi/hpsf/basic/Util.java @@ -131,7 +131,7 @@ final class Util { final String[] poiFiles) throws FileNotFoundException, IOException { - final List files = new ArrayList(); + final List<POIFile> files = new ArrayList<POIFile>(); POIFSReader r = new POIFSReader(); POIFSReaderListener pfl = new POIFSReaderListener() { @@ -170,7 +170,7 @@ final class Util { r.read(new FileInputStream(poiFs)); POIFile[] result = new POIFile[files.size()]; for (int i = 0; i < result.length; i++) - result[i] = (POIFile) files.get(i); + result[i] = files.get(i); return result; } @@ -195,7 +195,7 @@ final class Util { public static POIFile[] readPropertySets(final File poiFs) throws FileNotFoundException, IOException { - final List files = new ArrayList(7); + final List<POIFile> files = new ArrayList<POIFile>(7); final POIFSReader r = new POIFSReader(); POIFSReaderListener pfl = new POIFSReaderListener() { diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java index ea3df4cf2d..b5793a266f 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java @@ -111,6 +111,8 @@ public final class TestNPOIFSFileSystem { for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { assertEquals(512, fs.getBigBlockSize()); } + fsA.close(); + fsB.close(); // Now with a simple 4096 block file fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi")); @@ -118,6 +120,8 @@ public final class TestNPOIFSFileSystem { for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { assertEquals(4096, fs.getBigBlockSize()); } + fsA.close(); + fsB.close(); } @Test @@ -186,6 +190,8 @@ public final class TestNPOIFSFileSystem { assertEquals(i+1, ministore.getNextBlock(i)); } assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50)); + + fs.close(); } // Now with a simple 4096 block file @@ -252,6 +258,8 @@ public final class TestNPOIFSFileSystem { assertEquals(i+1, ministore.getNextBlock(i)); } assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50)); + + fs.close(); } } @@ -295,6 +303,8 @@ public final class TestNPOIFSFileSystem { for(int i=100; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) { assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(i)); } + + fs.close(); } // Quick check on 4096 byte blocks too @@ -311,6 +321,8 @@ public final class TestNPOIFSFileSystem { assertEquals(i+1, fs.getNextBlock(i)); } assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11)); + + fs.close(); } } @@ -348,6 +360,8 @@ public final class TestNPOIFSFileSystem { assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); + + fs.close(); } // Quick check on 4096 byte blocks too @@ -380,6 +394,8 @@ public final class TestNPOIFSFileSystem { assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); + + fs.close(); } } @@ -591,6 +607,8 @@ public final class TestNPOIFSFileSystem { // Look inside another DirectoryEntry imageD = (DirectoryEntry)image; assertEquals(7, imageD.getEntryCount()); + + fs.close(); } } @@ -635,6 +653,8 @@ public final class TestNPOIFSFileSystem { ps = PropertySetFactory.create(inp); DocumentSummaryInformation dinf = (DocumentSummaryInformation)ps; assertEquals(131333, dinf.getOSVersion()); + + fs.close(); } } diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java index 4aa6abf14c..c875c52997 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java @@ -28,7 +28,6 @@ import org.apache.poi.poifs.common.POIFSConstants; /** * Tests for the Mini Store in the NIO POIFS */ -@SuppressWarnings("resource") public final class TestNPOIFSMiniStore extends TestCase { private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance(); @@ -103,6 +102,8 @@ public final class TestNPOIFSMiniStore extends TestCase { for(int i=181; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) { assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i)); } + + fs.close(); } } @@ -168,6 +169,8 @@ public final class TestNPOIFSMiniStore extends TestCase { assertEquals((byte)0, b.get()); assertEquals((byte)0, b.get()); } + + fs.close(); } } @@ -198,6 +201,8 @@ public final class TestNPOIFSMiniStore extends TestCase { // Allocate it, then ask again ministore.setNextBlock(181, POIFSConstants.END_OF_CHAIN); assertEquals(182, ministore.getFreeBlock()); + + fs.close(); } /** @@ -240,6 +245,8 @@ public final class TestNPOIFSMiniStore extends TestCase { assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(255)); // 2nd SBAT assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(256)); // 3rd SBAT assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(257)); // 3rd SBAT + + fs.close(); } /** @@ -322,5 +329,7 @@ public final class TestNPOIFSMiniStore extends TestCase { for(int i=193; i<256; i++) { assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i)); } + + fs.close(); } } diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java index 7ee10a1910..1dcdba1ca2 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java @@ -62,6 +62,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); assertEquals((byte)0x00, b.get()); + + fs.close(); } /** @@ -103,6 +105,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x00, b98.get()); assertEquals((byte)0x00, b98.get()); assertEquals((byte)0x00, b98.get()); + + fs.close(); } /** @@ -157,6 +161,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x01, b22.get()); assertEquals((byte)0x02, b22.get()); assertEquals((byte)0x00, b22.get()); + + fs.close(); } /** @@ -211,6 +217,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x00, b2.get()); assertEquals((byte)0x46, b2.get()); assertEquals((byte)0x00, b2.get()); + + fs.close(); } /** @@ -249,6 +257,8 @@ public final class TestNPOIFSStream extends TestCase { // Good, it was detected } assertEquals(true, i.hasNext()); + + fs.close(); } /** @@ -304,6 +314,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x00, b180.get()); assertEquals((byte)0x00, b180.get()); assertEquals((byte)0x80, b180.get()); + + fs.close(); } /** @@ -334,6 +346,8 @@ public final class TestNPOIFSStream extends TestCase { byte exp = (byte)(i%256); assertEquals(exp, data[i]); } + + fs.close(); } /** @@ -373,6 +387,8 @@ public final class TestNPOIFSStream extends TestCase { byte exp = (byte)(i%256); assertEquals(exp, data[i]); } + + fs.close(); } /** @@ -417,6 +433,8 @@ public final class TestNPOIFSStream extends TestCase { count++; } assertEquals(3, count); + + fs.close(); } /** @@ -507,6 +525,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102)); assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103)); assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104)); + + fs.close(); } /** @@ -547,6 +567,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals(130, fs.getNextBlock(129)); assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(130)); assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(131)); + + fs.close(); } /** @@ -600,6 +622,8 @@ public final class TestNPOIFSStream extends TestCase { count++; } assertEquals(5, count); + + fs.close(); } /** @@ -790,6 +814,8 @@ public final class TestNPOIFSStream extends TestCase { assertEquals((byte)0x42, b183.get(1)); assertEquals((byte)0x81, b184.get(0)); assertEquals((byte)0x82, b184.get(1)); + + fs.close(); } /** @@ -823,6 +849,8 @@ public final class TestNPOIFSStream extends TestCase { stream.updateContents(data); fail("Loop should have been detected but wasn't!"); } catch(IllegalStateException e) {} + + fs.close(); } /** @@ -889,6 +917,8 @@ public final class TestNPOIFSStream extends TestCase { } assertEquals(false, it.hasNext()); + + fs.close(); } /** @@ -1079,5 +1109,7 @@ public final class TestNPOIFSStream extends TestCase { normal = (DocumentEntry)fs.getRoot().getEntry("Normal"); assertEquals(4096, normal.getSize()); assertEquals(4096, ((DocumentNode)normal).getProperty().getSize()); + + fs.close(); } } |