Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////
- //Test case:
- public class TestShiftRows() {
- private Workbook wb;
- private Sheet sheet;
- @Before
- public void setUp() {
- wb = new Workbook();
- sheet = wb.createSheet("Sheet1");
- for (int r=0; r<4; r++) {
- sheet.createRow(r);
- }
- }
- @After
- public void tearDown() throws IOException {
- wb.close();
- }
- // This test is written as expected-to-fail and should be rewritten
- // as expected-to-pass when the bug is fixed.
- //@Ignore("Bug 59733 - shiftRows() causes org.apache.xmlbeans.impl.values.XmlValueDisconnectedException")
- @Test
- public void shiftRowsThenRemovingCausesDisconnectedValue() throws IOException {
- // Shift the 2nd row on top of the 0th row
- sheet.shiftRows(2, 2, -2);
- /*
- * An XmlValueDisconnectedException is thrown when shifting the 3rd row on top of the 0th row.
- * This should not happen.
- */
- try {
- sheet.removeRow(sheet.getRow(0));
- assertEquals(1, sheet.getRow(1).getRowNum());
- testPassesNow(59733);
- } catch (XmlValueDisconnectedException e) {
- skipTest(e);
- }
- }
- }
- //////////////////////////////////////////
- //Supporting code:
- import static org.junit.Assert.fail;
- import static org.junit.Assume.assumeTrue;
- public class TestCaseHelper {
- private TestCaseHelper() {
- // no instances: this class contains static methods only
- }
- /*
- * Skips the test when an exception is raised due to a known but unfixed bug
- *
- * @param e the exception that was caught that will no longer
- * be raised when the bug is fixed
- */
- public static void skipTest(Throwable e) {
- assumeTrue("This test currently fails with " + e, false);
- }
- /**
- *
- * @param bug the bug number corresponding to a known bug in bugzilla
- */
- public static void testPassesNow(int bugNumber) {
- fail("This test passes now. Please update the unit test and bug " + bugNumber + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement