eolivelli commented on a change in pull request #2257: 2178: IOException Should 
Be Thrown When Journal Is Corrupted
URL: https://github.com/apache/bookkeeper/pull/2257#discussion_r378672666
 
 

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java
 ##########
 @@ -794,4 +801,50 @@ private void testPartialFileInfoPostV3Journal(boolean 
truncateMasterKey)
             // correct behaviour
         }
     }
+
+    @Test(expected = IOException.class)
+    public void testJournalScanIOException() throws Exception {
+        File journalDir = createTempDir("bookie", "journal");
+        Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir));
+
+        File ledgerDir = createTempDir("bookie", "ledger");
+        Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir));
+
+        writeV4Journal(Bookie.getCurrentDirectory(journalDir), 100, 
"testPasswd".getBytes());
+
+        ServerConfiguration conf = 
TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+                .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+                .setMetadataServiceUri(null);
+
+        Journal.JournalScanner journalScanner = new DummyJournalScan();
+        FileChannel fileChannel = PowerMockito.mock(FileChannel.class);
+
+        PowerMockito.when(fileChannel.position(Mockito.anyLong()))
+                .thenThrow(new IOException());
+
+        PowerMockito.mockStatic(JournalChannel.class);
+        
PowerMockito.when(JournalChannel.openFileChannel(Mockito.any(RandomAccessFile.class))).thenReturn(fileChannel);
+
+        Bookie b = new Bookie(conf);
 
 Review comment:
   Shall we stop the Bookie in a finally block?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to