aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/eventusermodel
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/hssf/eventusermodel
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/hssf/eventusermodel')
-rw-r--r--src/testcases/org/apache/poi/hssf/eventusermodel/AllEventUserModelTests.java22
-rw-r--r--src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java30
2 files changed, 24 insertions, 28 deletions
diff --git a/src/testcases/org/apache/poi/hssf/eventusermodel/AllEventUserModelTests.java b/src/testcases/org/apache/poi/hssf/eventusermodel/AllEventUserModelTests.java
index 41e3b86322..a5d9073759 100644
--- a/src/testcases/org/apache/poi/hssf/eventusermodel/AllEventUserModelTests.java
+++ b/src/testcases/org/apache/poi/hssf/eventusermodel/AllEventUserModelTests.java
@@ -17,22 +17,18 @@
package org.apache.poi.hssf.eventusermodel;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Collects all tests for <tt>org.apache.poi.hssf.eventusermodel</tt>.
- *
- * @author Josh Micich
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestEventWorkbookBuilder.class,
+ TestFormatTrackingHSSFListener.class,
+ TestHSSFEventFactory.class,
+ TestMissingRecordAwareHSSFListener.class
+})
public class AllEventUserModelTests {
-
- public static Test suite() {
- TestSuite result = new TestSuite(AllEventUserModelTests.class.getName());
- result.addTestSuite(TestEventWorkbookBuilder.class);
- result.addTestSuite(TestFormatTrackingHSSFListener.class);
- result.addTestSuite(TestHSSFEventFactory.class);
- result.addTestSuite(TestMissingRecordAwareHSSFListener.class);
- return result;
- }
}
diff --git a/src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java b/src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java
index ad144a2a37..1eb61509a6 100644
--- a/src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java
+++ b/src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java
@@ -16,23 +16,25 @@
==================================================================== */
package org.apache.poi.hssf.eventusermodel;
-import java.io.IOException;
-import java.io.InputStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.NumberRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Test;
/**
* Tests for FormatTrackingHSSFListener
*/
-public final class TestFormatTrackingHSSFListener extends TestCase {
+public final class TestFormatTrackingHSSFListener {
private FormatTrackingHSSFListener listener;
private MockHSSFListener mockListen;
@@ -42,16 +44,14 @@ public final class TestFormatTrackingHSSFListener extends TestCase {
listener = new FormatTrackingHSSFListener(mockListen);
req.addListenerForAllRecords(listener);
+ File file = HSSFTestDataSamples.getSampleFile(filename);
HSSFEventFactory factory = new HSSFEventFactory();
- try {
- InputStream is = HSSFTestDataSamples.openSampleFileStream(filename);
- POIFSFileSystem fs = new POIFSFileSystem(is);
- factory.processWorkbookEvents(req, fs);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ POIFSFileSystem fs = new POIFSFileSystem(file);
+ factory.processWorkbookEvents(req, fs);
+ fs.close();
}
+ @Test
public void testFormats() throws Exception {
processFile("MissingBits.xls");
@@ -68,6 +68,7 @@ public final class TestFormatTrackingHSSFListener extends TestCase {
* exceptions thrown, but in future we might also
* want to check the exact strings!
*/
+ @Test
public void testTurnToString() throws Exception {
String[] files = new String[] {
"45365.xls", "45365-2.xls", "MissingBits.xls"
@@ -81,8 +82,7 @@ public final class TestFormatTrackingHSSFListener extends TestCase {
// Now check we can turn all the numeric
// cells into strings without error
- for(int i=0; i<mockListen._records.size(); i++) {
- Record r = (Record)mockListen._records.get(i);
+ for(Record r : mockListen._records) {
CellValueRecordInterface cvr = null;
if(r instanceof NumberRecord) {
@@ -106,7 +106,7 @@ public final class TestFormatTrackingHSSFListener extends TestCase {
private static final class MockHSSFListener implements HSSFListener {
public MockHSSFListener() {}
- private final List _records = new ArrayList();
+ private final List<Record> _records = new ArrayList<Record>();
public void processRecord(Record record) {
_records.add(record);