aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs/storage
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-09-12 18:45:07 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-09-12 18:45:07 +0000
commitfbcf869f48e696a28ea364b8ff394476a96cdd21 (patch)
tree636ea213a2b2f8c826ee4ba8f1ac650d918869e3 /src/testcases/org/apache/poi/poifs/storage
parentf580fb0d728ad52873fb28be121e436f92fadfbb (diff)
downloadpoi-fbcf869f48e696a28ea364b8ff394476a96cdd21.tar.gz
poi-fbcf869f48e696a28ea364b8ff394476a96cdd21.zip
fix eclipse warning - mostly generics cosmetics
close resources in tests junit4 conversions convert spreadsheet based formular test to junit parameterized tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1702659 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs/storage')
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java44
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java18
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java29
3 files changed, 44 insertions, 47 deletions
diff --git a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
index 46011916ee..806154599d 100644
--- a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
+++ b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
@@ -17,31 +17,27 @@
package org.apache.poi.poifs.storage;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Tests for org.apache.poi.poifs.storage<br/>
- *
- * @author Josh Micich
*/
-public final class AllPOIFSStorageTests {
-
- public static Test suite() {
- TestSuite result = new TestSuite(AllPOIFSStorageTests.class.getName());
- result.addTestSuite(TestBATBlock.class);
- result.addTestSuite(TestBlockAllocationTableReader.class);
- result.addTestSuite(TestBlockAllocationTableWriter.class);
- result.addTestSuite(TestBlockListImpl.class);
- result.addTestSuite(TestDocumentBlock.class);
- result.addTestSuite(TestHeaderBlockReading.class);
- result.addTestSuite(TestHeaderBlockWriting.class);
- result.addTestSuite(TestPropertyBlock.class);
- result.addTestSuite(TestRawDataBlock.class);
- result.addTestSuite(TestRawDataBlockList.class);
- result.addTestSuite(TestSmallBlockTableReader.class);
- result.addTestSuite(TestSmallBlockTableWriter.class);
- result.addTestSuite(TestSmallDocumentBlock.class);
- result.addTestSuite(TestSmallDocumentBlockList.class);
- return result;
- }
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestBATBlock.class,
+ TestBlockAllocationTableReader.class,
+ TestBlockAllocationTableWriter.class,
+ TestBlockListImpl.class,
+ TestDocumentBlock.class,
+ TestHeaderBlockReading.class,
+ TestHeaderBlockWriting.class,
+ TestPropertyBlock.class,
+ TestRawDataBlock.class,
+ TestRawDataBlockList.class,
+ TestSmallBlockTableReader.class,
+ TestSmallBlockTableWriter.class,
+ TestSmallDocumentBlock.class,
+ TestSmallDocumentBlockList.class
+})
+public class AllPOIFSStorageTests {
}
diff --git a/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java b/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
index 2a36dd0a46..344b514853 100644
--- a/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
+++ b/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
@@ -17,24 +17,26 @@
package org.apache.poi.poifs.storage;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
+import org.junit.Test;
/**
* Class to test BlockListImpl functionality
*
* @author Marc Johnson
*/
-public final class TestBlockListImpl extends TestCase {
+public final class TestBlockListImpl {
private static final class BlockListTestImpl extends BlockListImpl {
public BlockListTestImpl() {
// no extra initialisation
@@ -44,6 +46,7 @@ public final class TestBlockListImpl extends TestCase {
return new BlockListTestImpl();
}
+ @Test
public void testZap() throws IOException {
BlockListImpl list = create();
@@ -79,7 +82,7 @@ public final class TestBlockListImpl extends TestCase {
}
}
-
+ @Test
public void testRemove() throws IOException {
BlockListImpl list = create();
RawDataBlock[] blocks = new RawDataBlock[ 5 ];
@@ -139,6 +142,7 @@ public final class TestBlockListImpl extends TestCase {
}
}
+ @Test
public void testSetBAT() throws IOException {
BlockListImpl list = create();
@@ -154,6 +158,7 @@ public final class TestBlockListImpl extends TestCase {
}
}
+ @Test
public void testFetchBlocks() throws IOException {
// strategy:
@@ -169,7 +174,7 @@ public final class TestBlockListImpl extends TestCase {
// that includes a reserved (XBAT) block, and one that
// points off into space somewhere
BlockListImpl list = create();
- List raw_blocks = new ArrayList();
+ List<RawDataBlock> raw_blocks = new ArrayList<RawDataBlock>();
byte[] data = new byte[ 512 ];
int offset = 0;
@@ -227,8 +232,7 @@ public final class TestBlockListImpl extends TestCase {
raw_blocks.add(
new RawDataBlock(new ByteArrayInputStream(new byte[ 0 ])));
}
- list.setBlocks(( RawDataBlock [] ) raw_blocks
- .toArray(new RawDataBlock[ 0 ]));
+ list.setBlocks(raw_blocks.toArray(new RawDataBlock[raw_blocks.size()]));
int[] blocks =
{
0
diff --git a/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java b/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java
index 0cf8398ab7..e4af23a99a 100644
--- a/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java
+++ b/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java
@@ -17,26 +17,27 @@
package org.apache.poi.poifs.storage;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.poifs.common.POIFSConstants;
-
-import junit.framework.TestCase;
+import org.apache.poi.poifs.property.Property;
+import org.junit.Test;
/**
* Class to test PropertyBlock functionality
- *
- * @author Marc Johnson
*/
-public final class TestPropertyBlock extends TestCase {
+public final class TestPropertyBlock {
- public void testCreatePropertyBlocks() {
+ @Test
+ public void testCreatePropertyBlocks() throws Exception {
// test with 0 properties
- List properties = new ArrayList();
+ List<Property> properties = new ArrayList<Property>();
BlockWritable[] blocks =
PropertyBlock.createPropertyBlockArray(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS,properties);
@@ -181,22 +182,18 @@ public final class TestPropertyBlock extends TestCase {
}
}
- private static void verifyCorrect(BlockWritable[] blocks, byte[] testblock) {
+ private static void verifyCorrect(BlockWritable[] blocks, byte[] testblock)
+ throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream(512
* blocks.length);
- for (int j = 0; j < blocks.length; j++) {
- try {
- blocks[ j ].writeBlocks(stream);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ for (BlockWritable b : blocks) {
+ b.writeBlocks(stream);
}
byte[] output = stream.toByteArray();
assertEquals(testblock.length, output.length);
- for (int j = 0; j < testblock.length; j++)
- {
+ for (int j = 0; j < testblock.length; j++) {
assertEquals("mismatch at offset " + j, testblock[ j ],
output[ j ]);
}