Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. ////////////////////////////////////
  2. //Test case:
  3.  
  4. public class TestShiftRows() {
  5.     private Workbook wb;
  6.     private Sheet sheet;
  7.  
  8.     @Before
  9.     public void setUp() {
  10.         wb = new Workbook();
  11.         sheet = wb.createSheet("Sheet1");
  12.         for (int r=0; r<4; r++) {
  13.             sheet.createRow(r);
  14.         }
  15.     }
  16.  
  17.     @After
  18.     public void tearDown() throws IOException {
  19.         wb.close();
  20.     }    
  21.  
  22.     // This test is written as expected-to-fail and should be rewritten
  23.     // as expected-to-pass when the bug is fixed.
  24.     //@Ignore("Bug 59733 - shiftRows() causes org.apache.xmlbeans.impl.values.XmlValueDisconnectedException")
  25.     @Test
  26.     public void shiftRowsThenRemovingCausesDisconnectedValue() throws IOException {
  27.         // Shift the 2nd row on top of the 0th row
  28.         sheet.shiftRows(2, 2, -2);
  29.        
  30.         /*
  31.          * An XmlValueDisconnectedException is thrown when shifting the 3rd row on top of the 0th row.
  32.          * This should not happen.
  33.          */
  34.         try {
  35.             sheet.removeRow(sheet.getRow(0));
  36.             assertEquals(1, sheet.getRow(1).getRowNum());
  37.             testPassesNow(59733);
  38.         } catch (XmlValueDisconnectedException e) {
  39.             skipTest(e);
  40.         }
  41.     }
  42. }
  43.  
  44. //////////////////////////////////////////
  45. //Supporting code:
  46.  
  47. import static org.junit.Assert.fail;
  48. import static org.junit.Assume.assumeTrue;
  49.  
  50. public class TestCaseHelper {
  51.     private TestCaseHelper() {
  52.         // no instances: this class contains static methods only
  53.     }
  54.  
  55.     /*
  56.      * Skips the test when an exception is raised due to a known but unfixed bug
  57.      *
  58.      * @param e  the exception that was caught that will no longer
  59.      * be raised when the bug is fixed
  60.      */
  61.     public static void skipTest(Throwable e) {
  62.         assumeTrue("This test currently fails with " + e, false);
  63.     }
  64.  
  65.     /**
  66.      *
  67.      * @param bug  the bug number corresponding to a known bug in bugzilla
  68.      */
  69.     public static void testPassesNow(int bugNumber) {
  70.         fail("This test passes now. Please update the unit test and bug " + bugNumber + ".");
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement