From 80cb5d580aae5bbfc3bb108f4b3b83e0c26d2de0 Mon Sep 17 00:00:00 2001 From: Andrew Lee Rubinger Date: Tue, 30 Jul 2024 01:47:35 -0700 Subject: [PATCH] Issue #94: Add an acceptance test for Kotlin --- .gitignore | 5 ++++ tests/jvm/README.md | 42 ++++++++++++++++++++++++++++++ tests/jvm/TbdexAcceptanceTest.java | 20 ++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/jvm/README.md create mode 100755 tests/jvm/TbdexAcceptanceTest.java diff --git a/.gitignore b/.gitignore index 5fe34dd2..5b27dba2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,15 @@ Cargo.lock bound/kt/src/main/resources/*.dylib bound/kt/src/main/resources/*.so +# .class file for acceptance test +tests/jvm/**.class + + # --- .hermit/ build/ .gradle/ **/.idea/ +**/**.iml **/.DS_Store diff --git a/tests/jvm/README.md b/tests/jvm/README.md new file mode 100644 index 00000000..2c717c8d --- /dev/null +++ b/tests/jvm/README.md @@ -0,0 +1,42 @@ +# tbDEX Kotlin Acceptance Test + +This is a simple Java main class which acts as an acceptance smoke test +for the tbDEX Kotlin binary distribution. The Kotlin unit tests execute in +Maven using the `classpath` as set by the Maven build process (ie. +`target/classes`). This test intentionally lives outside of the Kotlin tbDEX +project to test that it may be consumed as built (ie. the distributable JAR) +and contains the native libraries necessary to run. + +This acceptance test is run by the CI jobs after building the Kotlin +distribution to ensure it may be run in all supported environments. + +## Building + +From this folder, run: + +```shell +javac TbdexAcceptanceTest.java \ + -cp ../../bound/kt/target/tbdex-0.0.0-main-SNAPSHOT-jar-with-dependencies.jar +``` + +You may need to replace the filename of this JAR with the version as built from +Maven (note that this includes the version). + +## Running + +From this folder, run: + +```shell +java -classpath \ + ../../bound/kt/target/tbdex-0.0.0-main-SNAPSHOT-jar-with-dependencies.jar:. \ + TbdexAcceptanceTest +``` + +You may need to replace the filename of this JAR with the version as built from +Maven (note that this includes the version). + +You should see output similar to: + +```shell +Successfully loaded shared library for tbdex_uniffi_aarch64_apple_darwin +``` \ No newline at end of file diff --git a/tests/jvm/TbdexAcceptanceTest.java b/tests/jvm/TbdexAcceptanceTest.java new file mode 100755 index 00000000..f439a078 --- /dev/null +++ b/tests/jvm/TbdexAcceptanceTest.java @@ -0,0 +1,20 @@ +import tbdex.sdk.rust.SystemArchitecture; +import tbdex.sdk.rust.UniffiLib; + +/** + * A simple main class to act as an acceptance smoke test for the Kotlin + * tbDEX binary. + * + * See README.md in this folder for usage and purpose. + */ +public class TbdexAcceptanceTest { + + public static void main(String... args) { + System.setProperty("TBDEX_SDK_LOG_LEVEL", "debug"); + SystemArchitecture.INSTANCE.set(); + UniffiLib.Companion.getINSTANCE$tbdex(); + System.out.println( + "Successfully loaded shared library for " + + System.getProperty("uniffi.component.tbdex.libraryOverride")); + } +}