tidy up some test code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808944 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
01b1005379
commit
a9ec0770f0
@ -332,7 +332,7 @@ public class TestExtractorFactory {
|
|||||||
// Text
|
// Text
|
||||||
try {
|
try {
|
||||||
ExtractorFactory.createExtractor(txt);
|
ExtractorFactory.createExtractor(txt);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
@ -480,14 +480,9 @@ public class TestExtractorFactory {
|
|||||||
extractor.close();
|
extractor.close();
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
try {
|
try (FileInputStream stream = new FileInputStream(txt)) {
|
||||||
FileInputStream stream = new FileInputStream(txt);
|
|
||||||
try {
|
|
||||||
ExtractorFactory.createExtractor(stream);
|
ExtractorFactory.createExtractor(stream);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(stream);
|
|
||||||
}
|
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
@ -568,7 +563,7 @@ public class TestExtractorFactory {
|
|||||||
// Text
|
// Text
|
||||||
try {
|
try {
|
||||||
ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(txt)));
|
ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(txt)));
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
@ -650,7 +645,7 @@ public class TestExtractorFactory {
|
|||||||
// Text
|
// Text
|
||||||
try {
|
try {
|
||||||
ExtractorFactory.createExtractor(new OPOIFSFileSystem(new FileInputStream(txt)));
|
ExtractorFactory.createExtractor(new OPOIFSFileSystem(new FileInputStream(txt)));
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
|
@ -86,16 +86,9 @@ public abstract class BaseTestXSSFPivotTable {
|
|||||||
/**
|
/**
|
||||||
* Verify that it's not possible to create a row label outside of the referenced area.
|
* Verify that it's not possible to create a row label outside of the referenced area.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test(expected = IndexOutOfBoundsException.class)
|
||||||
public void testAddRowLabelOutOfRangeThrowsException() {
|
public void testAddRowLabelOutOfRangeThrowsException() {
|
||||||
int columnIndex = 5;
|
pivotTable.addRowLabel(5);
|
||||||
|
|
||||||
try {
|
|
||||||
pivotTable.addRowLabel(columnIndex);
|
|
||||||
} catch(IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,16 +190,9 @@ public abstract class BaseTestXSSFPivotTable {
|
|||||||
/**
|
/**
|
||||||
* Verify that it's not possible to create a column label outside of the referenced area.
|
* Verify that it's not possible to create a column label outside of the referenced area.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test(expected = IndexOutOfBoundsException.class)
|
||||||
public void testAddColumnLabelOutOfRangeThrowsException() {
|
public void testAddColumnLabelOutOfRangeThrowsException() {
|
||||||
int columnIndex = 5;
|
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 5);
|
||||||
|
|
||||||
try {
|
|
||||||
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex);
|
|
||||||
} catch(IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,17 +212,9 @@ public abstract class BaseTestXSSFPivotTable {
|
|||||||
/**
|
/**
|
||||||
* Verify that it's not possible to create a data column outside of the referenced area.
|
* Verify that it's not possible to create a data column outside of the referenced area.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test(expected = IndexOutOfBoundsException.class)
|
||||||
public void testAddDataColumnOutOfRangeThrowsException() {
|
public void testAddDataColumnOutOfRangeThrowsException() {
|
||||||
int columnIndex = 5;
|
pivotTable.addDataColumn(5, true);
|
||||||
boolean isDataField = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
pivotTable.addDataColumn(columnIndex, isDataField);
|
|
||||||
} catch(IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,15 +235,9 @@ public abstract class BaseTestXSSFPivotTable {
|
|||||||
/**
|
/**
|
||||||
* Verify that it's not possible to create a new filter outside of the referenced area.
|
* Verify that it's not possible to create a new filter outside of the referenced area.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test(expected = IndexOutOfBoundsException.class)
|
||||||
public void testAddReportFilterOutOfRangeThrowsException() {
|
public void testAddReportFilterOutOfRangeThrowsException() {
|
||||||
int columnIndex = 5;
|
pivotTable.addReportFilter(5);
|
||||||
try {
|
|
||||||
pivotTable.addReportFilter(columnIndex);
|
|
||||||
} catch(IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ package org.apache.poi.hsmf;
|
|||||||
|
|
||||||
import static org.apache.poi.POITestCase.assertContains;
|
import static org.apache.poi.POITestCase.assertContains;
|
||||||
import static org.apache.poi.POITestCase.assertStartsWith;
|
import static org.apache.poi.POITestCase.assertStartsWith;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -99,13 +100,13 @@ public final class TestBasics extends TestCase {
|
|||||||
// Quick doesn't have them
|
// Quick doesn't have them
|
||||||
try {
|
try {
|
||||||
quick.getHeaders();
|
quick.getHeaders();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {}
|
} catch(ChunkNotFoundException e) {}
|
||||||
|
|
||||||
// Attachments doesn't have them
|
// Attachments doesn't have them
|
||||||
try {
|
try {
|
||||||
attachments.getHeaders();
|
attachments.getHeaders();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {}
|
} catch(ChunkNotFoundException e) {}
|
||||||
|
|
||||||
// Outlook30 has some
|
// Outlook30 has some
|
||||||
@ -157,7 +158,7 @@ public final class TestBasics extends TestCase {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
attachments.getHtmlBody();
|
attachments.getHtmlBody();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
@ -170,7 +171,7 @@ public final class TestBasics extends TestCase {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
attachments.getHtmlBody();
|
attachments.getHtmlBody();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
@ -185,13 +186,13 @@ public final class TestBasics extends TestCase {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
noRecipientAddress.getRecipientEmailAddress();
|
noRecipientAddress.getRecipientEmailAddress();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
noRecipientAddress.getRecipientEmailAddressList();
|
noRecipientAddress.getRecipientEmailAddressList();
|
||||||
fail();
|
fail("expected ChunkNotFoundException");
|
||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
|
@ -301,13 +301,13 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
styB.verifyBelongsToWorkbook(wbB);
|
styB.verifyBelongsToWorkbook(wbB);
|
||||||
try {
|
try {
|
||||||
styA.verifyBelongsToWorkbook(wbB);
|
styA.verifyBelongsToWorkbook(wbB);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
styB.verifyBelongsToWorkbook(wbA);
|
styB.verifyBelongsToWorkbook(wbA);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
@ -319,13 +319,13 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
cellB.setCellStyle(styB);
|
cellB.setCellStyle(styB);
|
||||||
try {
|
try {
|
||||||
cellA.setCellStyle(styB);
|
cellA.setCellStyle(styB);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
cellB.setCellStyle(styA);
|
cellB.setCellStyle(styA);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
Record[] recs = RecordInspector.getRecords(sheet, 0);
|
Record[] recs = RecordInspector.getRecords(sheet, 0);
|
||||||
if (recs.length == 28 && recs[23] instanceof StringRecord) {
|
if (recs.length == 28 && recs[23] instanceof StringRecord) {
|
||||||
wb.close();
|
wb.close();
|
||||||
throw new AssertionFailedError("Identified bug - leftover StringRecord");
|
fail("Identified bug - leftover StringRecord");
|
||||||
}
|
}
|
||||||
confirmStringRecord(sheet, false);
|
confirmStringRecord(sheet, false);
|
||||||
|
|
||||||
|
@ -126,19 +126,19 @@ public final class TestAreaReference extends TestCase {
|
|||||||
new AreaReference(ref2D, SpreadsheetVersion.EXCEL97);
|
new AreaReference(ref2D, SpreadsheetVersion.EXCEL97);
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDCSimple, SpreadsheetVersion.EXCEL97);
|
new AreaReference(refDCSimple, SpreadsheetVersion.EXCEL97);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDC2D, SpreadsheetVersion.EXCEL97);
|
new AreaReference(refDC2D, SpreadsheetVersion.EXCEL97);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
new AreaReference(refDC3D, SpreadsheetVersion.EXCEL97);
|
new AreaReference(refDC3D, SpreadsheetVersion.EXCEL97);
|
||||||
fail();
|
fail("expected IllegalArgumentException");
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user