@ -27,7 +27,7 @@ public class InfoLogLevelTest {
try {
try {
db = RocksDB . open ( dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ;
db = RocksDB . open ( dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ;
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
assertThat ( getLogContents ( ) ) . isNotEmpty ( ) ;
assertThat ( getLogContentsWithoutHeader ( ) ) . isNotEmpty ( ) ;
} finally {
} finally {
if ( db ! = null ) {
if ( db ! = null ) {
db . close ( ) ;
db . close ( ) ;
@ -51,7 +51,7 @@ public class InfoLogLevelTest {
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
// As InfoLogLevel is set to FATAL_LEVEL, here we expect the log
// As InfoLogLevel is set to FATAL_LEVEL, here we expect the log
// content to be empty.
// content to be empty.
assertThat ( getLogContents ( ) ) . isEmpty ( ) ;
assertThat ( getLogContentsWithoutHeader ( ) ) . isEmpty ( ) ;
} finally {
} finally {
if ( db ! = null ) {
if ( db ! = null ) {
db . close ( ) ;
db . close ( ) ;
@ -81,7 +81,7 @@ public class InfoLogLevelTest {
db = RocksDB . open ( options ,
db = RocksDB . open ( options ,
dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ;
dbFolder . getRoot ( ) . getAbsolutePath ( ) ) ;
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
db . put ( "key" . getBytes ( ) , "value" . getBytes ( ) ) ;
assertThat ( getLogContents ( ) ) . isEmpty ( ) ;
assertThat ( getLogContentsWithoutHeader ( ) ) . isEmpty ( ) ;
} finally {
} finally {
if ( db ! = null ) {
if ( db ! = null ) {
db . close ( ) ;
db . close ( ) ;
@ -112,8 +112,23 @@ public class InfoLogLevelTest {
* @return LOG file contents as String .
* @return LOG file contents as String .
* @throws IOException if file is not found .
* @throws IOException if file is not found .
* /
* /
private String getLogContents ( ) throws IOException {
private String getLogContentsWithoutHeader ( ) throws IOException {
return new String ( readAllBytes ( get (
final String separator = System . getProperty ( "line.separator" ) ;
dbFolder . getRoot ( ) . getAbsolutePath ( ) + "/LOG" ) ) ) ;
final String [ ] lines = new String ( readAllBytes ( get (
dbFolder . getRoot ( ) . getAbsolutePath ( ) + "/LOG" ) ) ) . split ( separator ) ;
int first_non_header = lines . length ;
// Identify the last line of the header
for ( int i = lines . length - 1 ; i > = 0 ; - - i ) {
if ( lines [ i ] . indexOf ( "Options." ) > = 0 & & lines [ i ] . indexOf ( ':' ) > = 0 ) {
first_non_header = i + 1 ;
break ;
}
}
StringBuilder builder = new StringBuilder ( ) ;
for ( int i = first_non_header ; i < lines . length ; + + i ) {
builder . append ( lines [ i ] ) . append ( separator ) ;
}
return builder . toString ( ) ;
}
}
}
}