@ -30,41 +30,36 @@ public class BackupEngineOptionsTest {
@Test
public void backupDir ( ) {
try ( final BackupEngineOptions backupableDBOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupableDBOptions . backupDir ( ) ) .
isEqualTo ( ARBITRARY_PATH ) ;
try ( final BackupEngineOptions backupEngineOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupEngineOptions . backupDir ( ) ) . isEqualTo ( ARBITRARY_PATH ) ;
}
}
@Test
public void env ( ) {
try ( final BackupEngineOptions backupableDBOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupableDBOptions . backupEnv ( ) ) .
isNull ( ) ;
try ( final BackupEngineOptions backupEngineOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupEngineOptions . backupEnv ( ) ) . isNull ( ) ;
try ( final Env env = new RocksMemEnv ( Env . getDefault ( ) ) ) {
backupableDBOptions . setBackupEnv ( env ) ;
assertThat ( backupableDBOptions . backupEnv ( ) )
. isEqualTo ( env ) ;
backupEngineOptions . setBackupEnv ( env ) ;
assertThat ( backupEngineOptions . backupEnv ( ) ) . isEqualTo ( env ) ;
}
}
}
@Test
public void shareTableFiles ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final boolean value = rand . nextBoolean ( ) ;
backupableDBOptions . setShareTableFiles ( value ) ;
assertThat ( backupableDBOptions . shareTableFiles ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setShareTableFiles ( value ) ;
assertThat ( backupEngineOptions . shareTableFiles ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void infoLog ( ) {
try ( final BackupEngineOptions backupableDBOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupableDBOptions . infoLog ( ) ) .
isNull ( ) ;
try ( final BackupEngineOptions backupEngineOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupEngineOptions . infoLog ( ) ) . isNull ( ) ;
try ( final Options options = new Options ( ) ;
final Logger logger = new Logger ( options ) {
@ -73,127 +68,113 @@ public class BackupEngineOptionsTest {
}
} ) {
backupableDBOptions . setInfoLog ( logger ) ;
assertThat ( backupableDBOptions . infoLog ( ) )
. isEqualTo ( logger ) ;
backupEngineOptions . setInfoLog ( logger ) ;
assertThat ( backupEngineOptions . infoLog ( ) ) . isEqualTo ( logger ) ;
}
}
}
@Test
public void sync ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final boolean value = rand . nextBoolean ( ) ;
backupableDB Options . setSync ( value ) ;
assertThat ( backupableDB Options . sync ( ) ) . isEqualTo ( value ) ;
backupEngine Options . setSync ( value ) ;
assertThat ( backupEngine Options . sync ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void destroyOldData ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ; ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ; ) {
final boolean value = rand . nextBoolean ( ) ;
backupableDBOptions . setDestroyOldData ( value ) ;
assertThat ( backupableDBOptions . destroyOldData ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setDestroyOldData ( value ) ;
assertThat ( backupEngineOptions . destroyOldData ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void backupLogFiles ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final boolean value = rand . nextBoolean ( ) ;
backupableDBOptions . setBackupLogFiles ( value ) ;
assertThat ( backupableDBOptions . backupLogFiles ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setBackupLogFiles ( value ) ;
assertThat ( backupEngineOptions . backupLogFiles ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void backupRateLimit ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final long value = Math . abs ( rand . nextLong ( ) ) ;
backupableDBOptions . setBackupRateLimit ( value ) ;
assertThat ( backupableDBOptions . backupRateLimit ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setBackupRateLimit ( value ) ;
assertThat ( backupEngineOptions . backupRateLimit ( ) ) . isEqualTo ( value ) ;
// negative will be mapped to 0
backupableDBOptions . setBackupRateLimit ( - 1 ) ;
assertThat ( backupableDBOptions . backupRateLimit ( ) ) .
isEqualTo ( 0 ) ;
backupEngineOptions . setBackupRateLimit ( - 1 ) ;
assertThat ( backupEngineOptions . backupRateLimit ( ) ) . isEqualTo ( 0 ) ;
}
}
@Test
public void backupRateLimiter ( ) {
try ( final BackupEngineOptions backupableDBOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupableDBOptions . backupEnv ( ) ) .
isNull ( ) ;
try ( final BackupEngineOptions backupEngineOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupEngineOptions . backupEnv ( ) ) . isNull ( ) ;
try ( final RateLimiter backupRateLimiter =
new RateLimiter ( 999 ) ) {
backupableDBOptions . setBackupRateLimiter ( backupRateLimiter ) ;
assertThat ( backupableDBOptions . backupRateLimiter ( ) )
. isEqualTo ( backupRateLimiter ) ;
backupEngineOptions . setBackupRateLimiter ( backupRateLimiter ) ;
assertThat ( backupEngineOptions . backupRateLimiter ( ) ) . isEqualTo ( backupRateLimiter ) ;
}
}
}
@Test
public void restoreRateLimit ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final long value = Math . abs ( rand . nextLong ( ) ) ;
backupableDBOptions . setRestoreRateLimit ( value ) ;
assertThat ( backupableDBOptions . restoreRateLimit ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setRestoreRateLimit ( value ) ;
assertThat ( backupEngineOptions . restoreRateLimit ( ) ) . isEqualTo ( value ) ;
// negative will be mapped to 0
backupableDBOptions . setRestoreRateLimit ( - 1 ) ;
assertThat ( backupableDBOptions . restoreRateLimit ( ) ) .
isEqualTo ( 0 ) ;
backupEngineOptions . setRestoreRateLimit ( - 1 ) ;
assertThat ( backupEngineOptions . restoreRateLimit ( ) ) . isEqualTo ( 0 ) ;
}
}
@Test
public void restoreRateLimiter ( ) {
try ( final BackupEngineOptions backupableDBOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupableDBOptions . backupEnv ( ) ) .
isNull ( ) ;
try ( final BackupEngineOptions backupEngineOptions = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
assertThat ( backupEngineOptions . backupEnv ( ) ) . isNull ( ) ;
try ( final RateLimiter restoreRateLimiter =
new RateLimiter ( 911 ) ) {
backupableDBOptions . setRestoreRateLimiter ( restoreRateLimiter ) ;
assertThat ( backupableDBOptions . restoreRateLimiter ( ) )
. isEqualTo ( restoreRateLimiter ) ;
backupEngineOptions . setRestoreRateLimiter ( restoreRateLimiter ) ;
assertThat ( backupEngineOptions . restoreRateLimiter ( ) ) . isEqualTo ( restoreRateLimiter ) ;
}
}
}
@Test
public void shareFilesWithChecksum ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
boolean value = rand . nextBoolean ( ) ;
backupableDBOptions . setShareFilesWithChecksum ( value ) ;
assertThat ( backupableDBOptions . shareFilesWithChecksum ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setShareFilesWithChecksum ( value ) ;
assertThat ( backupEngineOptions . shareFilesWithChecksum ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void maxBackgroundOperations ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final int value = rand . nextInt ( ) ;
backupableDBOptions . setMaxBackgroundOperations ( value ) ;
assertThat ( backupableDBOptions . maxBackgroundOperations ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setMaxBackgroundOperations ( value ) ;
assertThat ( backupEngineOptions . maxBackgroundOperations ( ) ) . isEqualTo ( value ) ;
}
}
@Test
public void callbackTriggerIntervalSize ( ) {
try ( final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
try ( final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ) {
final long value = rand . nextLong ( ) ;
backupableDBOptions . setCallbackTriggerIntervalSize ( value ) ;
assertThat ( backupableDBOptions . callbackTriggerIntervalSize ( ) ) .
isEqualTo ( value ) ;
backupEngineOptions . setCallbackTriggerIntervalSize ( value ) ;
assertThat ( backupEngineOptions . callbackTriggerIntervalSize ( ) ) . isEqualTo ( value ) ;
}
}
@ -311,9 +292,9 @@ public class BackupEngineOptionsTest {
}
private BackupEngineOptions setupUninitializedBackupEngineOptions ( ExpectedException exception ) {
final BackupEngineOptions backupableDB Options = new BackupEngineOptions ( ARBITRARY_PATH ) ;
backupableDB Options . close ( ) ;
final BackupEngineOptions backupEngine Options = new BackupEngineOptions ( ARBITRARY_PATH ) ;
backupEngine Options . close ( ) ;
exception . expect ( AssertionError . class ) ;
return backupableDB Options ;
return backupEngine Options ;
}
}