// Text
try {
ExtractorFactory.createExtractor(txt);
- fail();
+ fail("expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// Good
}
extractor.close();
// Text
- try {
- FileInputStream stream = new FileInputStream(txt);
- try {
- ExtractorFactory.createExtractor(stream);
- fail();
- } finally {
- IOUtils.closeQuietly(stream);
- }
+ try (FileInputStream stream = new FileInputStream(txt)) {
+ ExtractorFactory.createExtractor(stream);
+ fail("expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// Good
}
// Text
try {
ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(txt)));
- fail();
+ fail("expected IllegalArgumentException");
} catch(IOException e) {
// Good
}
// Text
try {
ExtractorFactory.createExtractor(new OPOIFSFileSystem(new FileInputStream(txt)));
- fail();
+ fail("expected IllegalArgumentException");
} catch(IOException e) {
// Good
}
/**
* Verify that it's not possible to create a row label outside of the referenced area.
*/
- @Test
+ @Test(expected = IndexOutOfBoundsException.class)
public void testAddRowLabelOutOfRangeThrowsException() {
- int columnIndex = 5;
-
- try {
- pivotTable.addRowLabel(columnIndex);
- } catch(IndexOutOfBoundsException e) {
- return;
- }
- fail();
+ pivotTable.addRowLabel(5);
}
/**
/**
* Verify that it's not possible to create a column label outside of the referenced area.
*/
- @Test
+ @Test(expected = IndexOutOfBoundsException.class)
public void testAddColumnLabelOutOfRangeThrowsException() {
- int columnIndex = 5;
-
- try {
- pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex);
- } catch(IndexOutOfBoundsException e) {
- return;
- }
- fail();
+ pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 5);
}
/**
/**
* Verify that it's not possible to create a data column outside of the referenced area.
*/
- @Test
+ @Test(expected = IndexOutOfBoundsException.class)
public void testAddDataColumnOutOfRangeThrowsException() {
- int columnIndex = 5;
- boolean isDataField = true;
-
- try {
- pivotTable.addDataColumn(columnIndex, isDataField);
- } catch(IndexOutOfBoundsException e) {
- return;
- }
- fail();
+ pivotTable.addDataColumn(5, true);
}
/**
/**
* Verify that it's not possible to create a new filter outside of the referenced area.
*/
- @Test
+ @Test(expected = IndexOutOfBoundsException.class)
public void testAddReportFilterOutOfRangeThrowsException() {
- int columnIndex = 5;
- try {
- pivotTable.addReportFilter(columnIndex);
- } catch(IndexOutOfBoundsException e) {
- return;
- }
- fail();
+ pivotTable.addReportFilter(5);
}
/**
import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertStartsWith;
+import static org.junit.Assert.fail;
import java.io.IOException;
// Quick doesn't have them
try {
quick.getHeaders();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {}
// Attachments doesn't have them
try {
attachments.getHeaders();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {}
// Outlook30 has some
try {
attachments.getHtmlBody();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {
// Good
}
try {
attachments.getHtmlBody();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {
// Good
}
try {
noRecipientAddress.getRecipientEmailAddress();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {
// Good
}
try {
noRecipientAddress.getRecipientEmailAddressList();
- fail();
+ fail("expected ChunkNotFoundException");
} catch(ChunkNotFoundException e) {
// Good
}
styB.verifyBelongsToWorkbook(wbB);
try {
styA.verifyBelongsToWorkbook(wbB);
- fail();
+ fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected during successful test
}
try {
styB.verifyBelongsToWorkbook(wbA);
- fail();
+ fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected during successful test
}
cellB.setCellStyle(styB);
try {
cellA.setCellStyle(styB);
- fail();
+ fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected during successful test
}
try {
cellB.setCellStyle(styA);
- fail();
+ fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected during successful test
}
Record[] recs = RecordInspector.getRecords(sheet, 0);
if (recs.length == 28 && recs[23] instanceof StringRecord) {
wb.close();
- throw new AssertionFailedError("Identified bug - leftover StringRecord");
+ fail("Identified bug - leftover StringRecord");
}
confirmStringRecord(sheet, false);
new AreaReference(ref2D, SpreadsheetVersion.EXCEL97);
try {
new AreaReference(refDCSimple, SpreadsheetVersion.EXCEL97);
- fail();
+ fail("expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// expected during successful test
}
try {
new AreaReference(refDC2D, SpreadsheetVersion.EXCEL97);
- fail();
+ fail("expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// expected during successful test
}
try {
new AreaReference(refDC3D, SpreadsheetVersion.EXCEL97);
- fail();
+ fail("expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// expected during successful test
}