@ -9,7 +9,6 @@ import org.junit.BeforeClass;
import org.junit.Test ;
import org.junit.Test ;
import java.lang.reflect.Field ;
import java.lang.reflect.Field ;
import java.lang.reflect.Modifier ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThat ;
@ -37,18 +36,21 @@ public class EnvironmentTest {
isEqualTo ( ".jnilib" ) ;
isEqualTo ( ".jnilib" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-osx.jnilib" ) ;
isEqualTo ( "librocksdbjni-osx.jnilib" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.dylib" ) ;
isEqualTo ( "librocksdbjni.dylib" ) ;
}
}
@Test
@Test
public void mac64 ( ) {
public void mac64_x86_64 ( ) {
setEnvironmentClassFields ( "mac" , "x86- 64" ) ;
setEnvironmentClassFields ( "mac" , "x86_ 64" ) ;
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . getJniLibraryExtension ( ) ) .
assertThat ( Environment . getJniLibraryExtension ( ) ) .
isEqualTo ( ".jnilib" ) ;
isEqualTo ( ".jnilib" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
isEqualTo ( "librocksdbjni-osx.jnilib" ) ;
. isEqualTo ( "librocksdbjni-osx-x86_64.jnilib" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-osx.jnilib" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.dylib" ) ;
isEqualTo ( "librocksdbjni.dylib" ) ;
}
}
@ -59,7 +61,9 @@ public class EnvironmentTest {
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . getJniLibraryExtension ( ) ) . isEqualTo ( ".jnilib" ) ;
assertThat ( Environment . getJniLibraryExtension ( ) ) . isEqualTo ( ".jnilib" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-osx-aarch64.jnilib" ) ;
. isEqualTo ( "librocksdbjni-osx-arm64.jnilib" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-osx.jnilib" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.dylib" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.dylib" ) ;
}
}
@ -73,6 +77,7 @@ public class EnvironmentTest {
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-linux32.so" ) ;
isEqualTo ( "librocksdbjni-linux32.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.so" ) ;
isEqualTo ( "librocksdbjni.so" ) ;
// Linux musl-libc (Alpine)
// Linux musl-libc (Alpine)
@ -103,7 +108,8 @@ public class EnvironmentTest {
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . isWindows ( ) ) . isFalse ( ) ;
assertThat ( Environment . getJniLibraryExtension ( ) ) .
assertThat ( Environment . getJniLibraryExtension ( ) ) .
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
Environment . getJniLibraryFileName ( "rocksdb" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "blah" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
}
}
@Test
@Test
@ -115,6 +121,7 @@ public class EnvironmentTest {
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-linux64.so" ) ;
isEqualTo ( "librocksdbjni-linux64.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.so" ) ;
isEqualTo ( "librocksdbjni.so" ) ;
// Linux musl-libc (Alpine)
// Linux musl-libc (Alpine)
@ -124,6 +131,7 @@ public class EnvironmentTest {
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-linux64-musl.so" ) ;
isEqualTo ( "librocksdbjni-linux64-musl.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.so" ) ;
isEqualTo ( "librocksdbjni.so" ) ;
// UNIX
// UNIX
@ -134,6 +142,7 @@ public class EnvironmentTest {
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-linux64.so" ) ;
isEqualTo ( "librocksdbjni-linux64.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.so" ) ;
isEqualTo ( "librocksdbjni.so" ) ;
// AIX
// AIX
@ -143,6 +152,7 @@ public class EnvironmentTest {
isEqualTo ( ".so" ) ;
isEqualTo ( ".so" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-aix64.so" ) ;
isEqualTo ( "librocksdbjni-aix64.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.so" ) ;
isEqualTo ( "librocksdbjni.so" ) ;
}
}
@ -161,6 +171,7 @@ public class EnvironmentTest {
isEqualTo ( ".dll" ) ;
isEqualTo ( ".dll" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni-win64.dll" ) ;
isEqualTo ( "librocksdbjni-win64.dll" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) .
isEqualTo ( "librocksdbjni.dll" ) ;
isEqualTo ( "librocksdbjni.dll" ) ;
}
}
@ -177,6 +188,7 @@ public class EnvironmentTest {
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-ppc64le" ) ;
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-ppc64le" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-linux-ppc64le.so" ) ;
. isEqualTo ( "librocksdbjni-linux-ppc64le.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
// Linux musl-libc (Alpine)
// Linux musl-libc (Alpine)
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , true ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , true ) ;
@ -189,6 +201,7 @@ public class EnvironmentTest {
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-ppc64le-musl" ) ;
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-ppc64le-musl" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-linux-ppc64le-musl.so" ) ;
. isEqualTo ( "librocksdbjni-linux-ppc64le-musl.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , false ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , false ) ;
}
}
@ -205,6 +218,7 @@ public class EnvironmentTest {
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-aarch64" ) ;
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-aarch64" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-linux-aarch64.so" ) ;
. isEqualTo ( "librocksdbjni-linux-aarch64.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
// Linux musl-libc (Alpine)
// Linux musl-libc (Alpine)
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , true ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , true ) ;
@ -217,6 +231,7 @@ public class EnvironmentTest {
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-aarch64-musl" ) ;
assertThat ( Environment . getJniLibraryName ( "rocksdb" ) ) . isEqualTo ( "rocksdbjni-linux-aarch64-musl" ) ;
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
assertThat ( Environment . getJniLibraryFileName ( "rocksdb" ) )
. isEqualTo ( "librocksdbjni-linux-aarch64-musl.so" ) ;
. isEqualTo ( "librocksdbjni-linux-aarch64-musl.so" ) ;
assertThat ( Environment . getFallbackJniLibraryFileName ( "rocksdb" ) ) . isNull ( ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
assertThat ( Environment . getSharedLibraryFileName ( "rocksdb" ) ) . isEqualTo ( "librocksdbjni.so" ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , false ) ;
setEnvironmentClassField ( MUSL_LIBC_FIELD_NAME , false ) ;
}
}