### Question:
SplitTransaction { public void rollback(final OnlineRegions or) throws IOException { FileSystem fs = this.parent.getFilesystem(); ListIterator<JournalEntry> iterator = this.journal.listIterator(this.journal.size()); while (iterator.hasPrevious()) { JournalEntry je = iterator.previous(); switch(je) { case CREATE_SPLIT_DIR: cleanupSplitDir(fs, this.splitdir); break; case CLOSED_PARENT_REGION: this.parent.initialize(); break; case STARTED_REGION_A_CREATION: cleanupDaughterRegion(fs, this.parent.getTableDir(), this.hri_a.getEncodedName()); break; case STARTED_REGION_B_CREATION: cleanupDaughterRegion(fs, this.parent.getTableDir(), this.hri_b.getEncodedName()); break; case OFFLINED_PARENT: if (or != null) or.addToOnlineRegions(this.parent); break; default: throw new RuntimeException("Unhandled journal entry: " + je); } } } SplitTransaction(final HRegion r, final byte [] splitrow); boolean prepare(); void rollback(final OnlineRegions or);  }### Answer:
@Test public void testRollback() throws IOException { final int rowcount = TEST_UTIL.loadRegion(this.parent, CF); assertTrue(rowcount > 0); int parentRowCount = countRows(this.parent); assertEquals(rowcount, parentRowCount); SplitTransaction st = prepareGOOD_SPLIT_ROW(); SplitTransaction spiedUponSt = spy(st); when(spiedUponSt.createDaughterRegion(spiedUponSt.getSecondDaughter(), null)). thenThrow(new MockedFailedDaughterCreation()); boolean expectedException = false; Server mockServer = Mockito.mock(Server.class); when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration()); try { spiedUponSt.execute(mockServer, null); } catch (MockedFailedDaughterCreation e) { expectedException = true; } assertTrue(expectedException); spiedUponSt.rollback(null); int parentRowCount2 = countRows(this.parent); assertEquals(parentRowCount, parentRowCount2); assertTrue(!this.fs.exists(HRegion.getRegionDir(this.testdir, st.getFirstDaughter()))); assertTrue(!this.fs.exists(HRegion.getRegionDir(this.testdir, st.getSecondDaughter()))); assertTrue(!this.parent.lock.writeLock().isHeldByCurrentThread()); assertTrue(st.prepare()); PairOfSameType<HRegion> daughters = st.execute(mockServer, null); int daughtersRowCount = 0; for (HRegion r: daughters) { HRegion openRegion = HRegion.openHRegion(r.getRegionInfo(), r.getLog(), r.getConf()); try { int count = countRows(openRegion); assertTrue(count > 0 && count != rowcount); daughtersRowCount += count; } finally { openRegion.close(); } } assertEquals(rowcount, daughtersRowCount); assertTrue(!this.parent.lock.writeLock().isHeldByCurrentThread()); }