Repository: deepjavalibrary/djl
Pull request #2228 (2022-12-14 23:13:41)

[tokenizer] Avoid unittest polluting cache directory.
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here


codecov-commenter: # [Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/2228?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) Report
Base: **72.08**% // Head: **71.55**% // Decreases project coverage by **`-0.53%`** :warning:
> Coverage data is based on head [(`52608ef`)](https://codecov.io/gh/deepjavalibrary/djl/pull/2228?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) compared to base [(`bb5073f`)](https://codecov.io/gh/deepjavalibrary/djl/commit/bb5073f7ffc33f1883621fc1783dbb01e70b418f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).
> Patch coverage: 73.63% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##             master    #2228      +/-   ##
============================================
- Coverage     72.08%   71.55%   -0.54%     
- Complexity     5126     6341    +1215     
============================================
  Files           473      631     +158     
  Lines         21970    28071    +6101     
  Branches       2351     2988     +637     
============================================
+ Hits          15838    20087    +4249     
- Misses         4925     6522    +1597     
- Partials       1207     1462     +255     
```


| [Impacted Files](https://codecov.io/gh/deepjavalibrary/djl/pull/2228?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | Coverage Δ | |
|---|---|---|
| [api/src/main/java/ai/djl/modality/cv/Image.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L0ltYWdlLmphdmE=) | `69.23% <ø> (-4.11%)` | :arrow_down: |
| [...rc/main/java/ai/djl/modality/cv/MultiBoxPrior.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L011bHRpQm94UHJpb3IuamF2YQ==) | `76.00% <ø> (ø)` | |
| [...rc/main/java/ai/djl/modality/cv/output/Joints.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9Kb2ludHMuamF2YQ==) | `71.42% <ø> (ø)` | |
| [.../main/java/ai/djl/modality/cv/output/Landmark.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9MYW5kbWFyay5qYXZh) | `100.00% <ø> (ø)` | |
| [...main/java/ai/djl/modality/cv/output/Rectangle.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L291dHB1dC9SZWN0YW5nbGUuamF2YQ==) | `72.41% <0.00%> (ø)` | |
| [...i/djl/modality/cv/translator/BigGANTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvQmlnR0FOVHJhbnNsYXRvci5qYXZh) | `21.42% <0.00%> (-5.24%)` | :arrow_down: |
| [.../modality/cv/translator/ImageFeatureExtractor.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvSW1hZ2VGZWF0dXJlRXh0cmFjdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [.../ai/djl/modality/cv/translator/YoloTranslator.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3RyYW5zbGF0b3IvWW9sb1RyYW5zbGF0b3IuamF2YQ==) | `27.77% <0.00%> (+18.95%)` | :arrow_up: |
| [...ain/java/ai/djl/modality/cv/util/NDImageUtils.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L2N2L3V0aWwvTkRJbWFnZVV0aWxzLmphdmE=) | `59.21% <0.00%> (ø)` | |
| [api/src/main/java/ai/djl/modality/nlp/Decoder.java](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary#diff-YXBpL3NyYy9tYWluL2phdmEvYWkvZGpsL21vZGFsaXR5L25scC9EZWNvZGVyLmphdmE=) | `63.63% <ø> (ø)` | |
| ... and [564 more](https://codecov.io/gh/deepjavalibrary/djl/pull/2228/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/deepjavalibrary/djl/pull/2228?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deepjavalibrary).


Patch:
diff --git a/basicdataset/build.gradle b/basicdataset/build.gradle
index eac450c4d..b0771cf0f 100644
--- a/basicdataset/build.gradle
+++ b/basicdataset/build.gradle
@@ -4,9 +4,6 @@ dependencies {
 
     // Add following dependency to your project for COCO dataset
     // runtimeOnly "com.twelvemonkeys.imageio:imageio-jpeg:3.5"
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 
     testImplementation project(":testing")
diff --git a/build.gradle b/build.gradle
index ec0e16c8f..ba56a4a96 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,12 +32,17 @@ def javaProjects() {
 
 configure(javaProjects()) {
     apply plugin: 'java-library'
-    sourceCompatibility = 1.8
-    targetCompatibility = 1.8
-    compileJava.options.encoding = "UTF-8"
-    compileTestJava.options.encoding = "UTF-8"
-    if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
-        compileJava.options.compilerArgs.addAll(["--release", "8"])
+    compileJava {
+        options.encoding = "UTF-8"
+        sourceCompatibility = JavaVersion.VERSION_1_8
+        targetCompatibility = JavaVersion.VERSION_1_8
+        options.compilerArgs << "--release" << "8" << "-proc:none" << "-Xlint:all,-options,-static" << "-Werror"
+    }
+    compileTestJava {
+        options.encoding = "UTF-8"
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static,-removal" << "-Werror"
     }
 
     apply plugin: 'eclipse'
@@ -60,13 +65,6 @@ configure(javaProjects()) {
     test {
         // tensorflow mobilenet and resnet require more cpu memory
         maxHeapSize = "4096m"
-        doFirst {
-            if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
-                jvmArgs = [
-                        '--add-opens', "java.base/jdk.internal.loader=ALL-UNNAMED"
-                ]
-            }
-        }
 
         useTestNG() {
             // suiteXmlFiles << new File(rootDir, "testng.xml") //This is how to add custom testng.xml
@@ -78,6 +76,9 @@ configure(javaProjects()) {
         }
 
         doFirst {
+            jvmArgs = [
+                    '--add-opens', "java.base/jdk.internal.loader=ALL-UNNAMED"
+            ]
             systemProperties System.getProperties()
             systemProperties.remove("user.dir")
             // systemProperty "ai.djl.logging.level", "debug"
@@ -97,14 +98,6 @@ configure(javaProjects()) {
         }
     }
 
-    compileJava {
-        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static" << "-Werror"
-    }
-
-    compileTestJava {
-        options.compilerArgs << "-proc:none" << "-Xlint:all,-options,-static,-removal" << "-Werror"
-    }
-
     jar {
         manifest {
             attributes(
diff --git a/docs/quick_start.md b/docs/quick_start.md
index c59352e75..f352a3915 100644
--- a/docs/quick_start.md
+++ b/docs/quick_start.md
@@ -10,7 +10,7 @@ You can also view our 1.5 hour long (in 8 x ~10 minute segments) DJL 101 tutoria
 
 ## Prerequisites
 
-* You need a Java Development Kit (JDK) installed on your system. We recommend using JDK 8, but any later version also works. For more information, see [Setup](development/setup.md).
+* You need a Java Development Kit (JDK) installed on your system. We recommend using JDK 11, but any later version also works. For more information, see [Setup](development/setup.md).
 * You need git installed on your system to clone the DJL repository.
 
 ## Try DJL
diff --git a/engines/ml/lightgbm/build.gradle b/engines/ml/lightgbm/build.gradle
index 86f5945d9..8cfb37726 100644
--- a/engines/ml/lightgbm/build.gradle
+++ b/engines/ml/lightgbm/build.gradle
@@ -5,9 +5,6 @@ dependencies {
     api "com.microsoft.ml.lightgbm:lightgbmlib:${lightgbm_version}"
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
 }
diff --git a/engines/ml/xgboost/build.gradle b/engines/ml/xgboost/build.gradle
index 36dd5f6c6..d736d4b96 100644
--- a/engines/ml/xgboost/build.gradle
+++ b/engines/ml/xgboost/build.gradle
@@ -27,9 +27,6 @@ dependencies {
     exclusion project(":api")
     exclusion "commons-logging:commons-logging:${commons_logging_version}"
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
     if (isGpu) {
diff --git a/engines/mxnet/mxnet-engine/build.gradle b/engines/mxnet/mxnet-engine/build.gradle
index a17c18618..f953817db 100644
--- a/engines/mxnet/mxnet-engine/build.gradle
+++ b/engines/mxnet/mxnet-engine/build.gradle
@@ -7,9 +7,6 @@ dependencies {
     testImplementation project(":model-zoo")
     testImplementation(project(":testing"))
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/mxnet/mxnet-model-zoo/build.gradle b/engines/mxnet/mxnet-model-zoo/build.gradle
index c0c3d8ed2..c87026e18 100644
--- a/engines/mxnet/mxnet-model-zoo/build.gradle
+++ b/engines/mxnet/mxnet-model-zoo/build.gradle
@@ -8,9 +8,6 @@ dependencies {
     testImplementation project(":model-zoo")
     testImplementation(project(":testing"))
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/onnxruntime/onnxruntime-engine/build.gradle b/engines/onnxruntime/onnxruntime-engine/build.gradle
index 162663344..b82b22f9f 100644
--- a/engines/onnxruntime/onnxruntime-engine/build.gradle
+++ b/engines/onnxruntime/onnxruntime-engine/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api "com.microsoft.onnxruntime:onnxruntime:${onnxruntime_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testImplementation project(":engines:pytorch:pytorch-engine")
 
diff --git a/engines/paddlepaddle/paddlepaddle-engine/build.gradle b/engines/paddlepaddle/paddlepaddle-engine/build.gradle
index 06b03aa02..7df5439f2 100644
--- a/engines/paddlepaddle/paddlepaddle-engine/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-engine/build.gradle
@@ -3,9 +3,6 @@ group "ai.djl.paddlepaddle"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation(project(":testing"))
 }
diff --git a/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle b/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
index 8e7bf3aa9..33adff4a0 100644
--- a/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
+++ b/engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
@@ -3,9 +3,7 @@ group 'ai.djl.paddlepaddle'
 
 dependencies {
     api project(":engines:paddlepaddle:paddlepaddle-engine")
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
+
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
     testRuntimeOnly project(":extensions:opencv")
diff --git a/engines/tensorflow/tensorflow-engine/build.gradle b/engines/tensorflow/tensorflow-engine/build.gradle
index 4166ef21d..1f3c0728c 100644
--- a/engines/tensorflow/tensorflow-engine/build.gradle
+++ b/engines/tensorflow/tensorflow-engine/build.gradle
@@ -5,9 +5,6 @@ dependencies {
     api project(":engines:tensorflow:tensorflow-api")
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/tensorflow/tensorflow-model-zoo/build.gradle b/engines/tensorflow/tensorflow-model-zoo/build.gradle
index 02e10135b..b8e9412ec 100644
--- a/engines/tensorflow/tensorflow-model-zoo/build.gradle
+++ b/engines/tensorflow/tensorflow-model-zoo/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":engines:tensorflow:tensorflow-engine")
 
     testImplementation(project(":testing"))
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
 }
 
diff --git a/engines/tflite/tflite-engine/build.gradle b/engines/tflite/tflite-engine/build.gradle
index bc548b1ae..03cce9293 100644
--- a/engines/tflite/tflite-engine/build.gradle
+++ b/engines/tflite/tflite-engine/build.gradle
@@ -3,10 +3,6 @@ group "ai.djl.tflite"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation(project(":testing"))
     testRuntimeOnly "org.slf4j:slf4j-simple:${slf4j_version}"
 }
diff --git a/examples/pom.xml b/examples/pom.xml
index f079672ea..f996872ea 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -8,8 +8,8 @@
     <version>0.21.0-SNAPSHOT</version>
 
     <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
         <djl.version>0.21.0-SNAPSHOT</djl.version>
         <exec.mainClass>ai.djl.examples.inference.ObjectDetection</exec.mainClass>
     </properties>
@@ -72,7 +72,7 @@
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <version>7.5</version>
+            <version>7.7.0</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/extensions/audio/build.gradle b/extensions/audio/build.gradle
index 266cb9dd4..4cadf47b9 100644
--- a/extensions/audio/build.gradle
+++ b/extensions/audio/build.gradle
@@ -25,9 +25,6 @@ dependencies {
     runtimeOnly "org.bytedeco:ffmpeg:5.0-1.5.7:linux-x86_64"
     runtimeOnly "org.bytedeco:ffmpeg:5.0-1.5.7:windows-x86_64"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
     testRuntimeOnly project(":engines:pytorch:pytorch-engine")
diff --git a/extensions/fasttext/build.gradle b/extensions/fasttext/build.gradle
index b3c16cfb4..c772abb1c 100644
--- a/extensions/fasttext/build.gradle
+++ b/extensions/fasttext/build.gradle
@@ -4,10 +4,6 @@ dependencies {
     api project(":api")
     api project(":basicdataset")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     // ModelZoo requires at least one engine in the class path
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation(project(":testing"))
diff --git a/extensions/hadoop/build.gradle b/extensions/hadoop/build.gradle
index 38a2760c3..c480a2835 100644
--- a/extensions/hadoop/build.gradle
+++ b/extensions/hadoop/build.gradle
@@ -12,7 +12,6 @@ dependencies {
     testImplementation "org.mockito:mockito-core:${mockito_version}"
     testImplementation(project(":testing"))
 
-    testImplementation "org.testng:testng:${testng_version}"
     testRuntimeOnly "junit:junit:${junit_version}" // hadoop-client test depends on junit
 }
 
diff --git a/extensions/opencv/build.gradle b/extensions/opencv/build.gradle
index 05dddad24..6c29f026a 100644
--- a/extensions/opencv/build.gradle
+++ b/extensions/opencv/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api "org.openpnp:opencv:4.5.1-2"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
 
diff --git a/extensions/sentencepiece/build.gradle b/extensions/sentencepiece/build.gradle
index 7dd054cff..1b9e2b313 100644
--- a/extensions/sentencepiece/build.gradle
+++ b/extensions/sentencepiece/build.gradle
@@ -3,10 +3,6 @@ group "ai.djl.sentencepiece"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation(project(":testing"))
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
diff --git a/extensions/spark/build.gradle b/extensions/spark/build.gradle
index 325f2a5cf..1f496df04 100644
--- a/extensions/spark/build.gradle
+++ b/extensions/spark/build.gradle
@@ -10,9 +10,6 @@ dependencies {
     api "org.apache.spark:spark-sql_2.12:${spark_version}"
     api "org.apache.spark:spark-mllib_2.12:${spark_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":testing")
     testRuntimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
 
diff --git a/extensions/tablesaw/build.gradle b/extensions/tablesaw/build.gradle
index 2e71879f9..85051e3d0 100644
--- a/extensions/tablesaw/build.gradle
+++ b/extensions/tablesaw/build.gradle
@@ -4,9 +4,6 @@ dependencies {
     api project(":api")
     api project(":basicdataset")
     api "tech.tablesaw:tablesaw-core:${tablesaw_version}"
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
 
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
diff --git a/extensions/timeseries/build.gradle b/extensions/timeseries/build.gradle
index f4aea7010..a19872062 100644
--- a/extensions/timeseries/build.gradle
+++ b/extensions/timeseries/build.gradle
@@ -6,10 +6,6 @@ dependencies {
     api "tech.tablesaw:tablesaw-core:${tablesaw_version}"
     api "tech.tablesaw:tablesaw-jsplot:${tablesaw_version}"
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
-
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
     testImplementation project(":testing")
 
diff --git a/extensions/tokenizers/build.gradle b/extensions/tokenizers/build.gradle
index d49146778..3a2f4313d 100644
--- a/extensions/tokenizers/build.gradle
+++ b/extensions/tokenizers/build.gradle
@@ -3,9 +3,6 @@ group "ai.djl.huggingface"
 dependencies {
     api project(":api")
 
-    testImplementation("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
     testImplementation project(":engines:pytorch:pytorch-engine")
     testImplementation project(":testing")
     testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
diff --git a/gradle.properties b/gradle.properties
index 856c25bad..6930a6271 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -43,6 +43,6 @@ tablesaw_version=0.43.1
 spark_version=3.2.2
 
 antlr_version=4.9.3
-testng_version=7.5
+testng_version=7.7.0
 junit_version=4.13.2
 mockito_version=4.8.0
diff --git a/integration/build.gradle b/integration/build.gradle
index 97fe0a499..0cb57bb6a 100644
--- a/integration/build.gradle
+++ b/integration/build.gradle
@@ -4,14 +4,11 @@ plugins {
 }
 
 dependencies {
-    api "commons-cli:commons-cli:${commons_cli_version}"
-    api "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
-    api project(":basicdataset")
-    api project(":model-zoo")
-    api project(":testing")
-    api("org.testng:testng:${testng_version}") {
-        exclude group: "junit", module: "junit"
-    }
+    implementation "commons-cli:commons-cli:${commons_cli_version}"
+    implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_slf4j_version}"
+    implementation project(":basicdataset")
+    implementation project(":model-zoo")
+    implementation project(":testing")
 
     runtimeOnly project(":engines:mxnet:mxnet-model-zoo")
     runtimeOnly project(":engines:pytorch:pytorch-model-zoo")
@@ -32,6 +29,14 @@ dependencies {
     }
 }
 
+java {
+    compileJava {
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs.removeAll(["--release", "8"])
+    }
+}
+
 task copyDependencies(type: Copy) {
     into "build/dependencies"
     from configurations.runtimeClasspath


Test patch:
diff --git a/extensions/tokenizers/src/test/java/ai/djl/huggingface/zoo/ModelZooTest.java b/extensions/tokenizers/src/test/java/ai/djl/huggingface/zoo/ModelZooTest.java
index ea9a5ca1b..89e19014d 100644
--- a/extensions/tokenizers/src/test/java/ai/djl/huggingface/zoo/ModelZooTest.java
+++ b/extensions/tokenizers/src/test/java/ai/djl/huggingface/zoo/ModelZooTest.java
@@ -17,6 +17,7 @@ import ai.djl.ModelException;
 import ai.djl.inference.Predictor;
 import ai.djl.modality.nlp.qa.QAInput;
 import ai.djl.repository.zoo.Criteria;
+import ai.djl.repository.zoo.ModelZoo;
 import ai.djl.repository.zoo.ZooModel;
 import ai.djl.testing.TestRequirements;
 import ai.djl.translate.TranslateException;
@@ -59,34 +60,40 @@ public class ModelZooTest {
 
     @Test
     public void testFutureVersion() throws IOException {
-        Map<String, Map<String, Object>> map = new ConcurrentHashMap<>();
-        Map<String, Object> model = new ConcurrentHashMap<>();
-        model.put("result", "failed");
-        map.put("model1", model);
+        System.setProperty("DJL_CACHE_DIR", "build/cache");
+        try {
+            Map<String, Map<String, Object>> map = new ConcurrentHashMap<>();
+            Map<String, Object> model = new ConcurrentHashMap<>();
+            model.put("result", "failed");
+            map.put("model1", model);
 
-        model = new ConcurrentHashMap<>();
-        model.put("requires", "10.100.0+");
-        map.put("model2", model);
+            model = new ConcurrentHashMap<>();
+            model.put("requires", "10.100.0+");
+            map.put("model2", model);
 
-        model = new ConcurrentHashMap<>();
-        model.put("requires", "0.19.0+");
-        map.put("model3", model);
-        map.put("model4", new ConcurrentHashMap<>());
+            model = new ConcurrentHashMap<>();
+            model.put("requires", "0.19.0+");
+            map.put("model3", model);
+            map.put("model4", new ConcurrentHashMap<>());
 
-        String path = "model/" + NLP.QUESTION_ANSWER.getPath() + "/ai/djl/huggingface/pytorch/";
-        Path dir = Utils.getCacheDir().resolve("cache/repo/" + path);
-        Files.createDirectories(dir);
-        Path file = dir.resolve("models.json");
-        try (Writer writer = Files.newBufferedWriter(file)) {
-            writer.write(JsonUtils.GSON_PRETTY.toJson(map));
-        }
-        HfModelZoo zoo = new HfModelZoo();
+            String path = "model/" + NLP.QUESTION_ANSWER.getPath() + "/ai/djl/huggingface/pytorch/";
+            Path dir = Utils.getCacheDir().resolve("cache/repo/" + path);
+            Files.createDirectories(dir);
+            Path file = dir.resolve("models.json");
+            try (Writer writer = Files.newBufferedWriter(file)) {
+                writer.write(JsonUtils.GSON_PRETTY.toJson(map));
+            }
 
-        Assert.assertNull(zoo.getModelLoader("model1"));
-        Assert.assertNull(zoo.getModelLoader("model2"));
-        Assert.assertNull(zoo.getModelLoader("model3"));
-        Assert.assertNotNull(zoo.getModelLoader("model4"));
+            // static variables cannot not be initialized properly if directly use new HfModelZoo()
+            ModelZoo.getModelZoo("ai.djl.huggingface.pytorch");
+            ModelZoo zoo = new HfModelZoo();
 
-        Utils.deleteQuietly(file);
+            Assert.assertNull(zoo.getModelLoader("model1"));
+            Assert.assertNull(zoo.getModelLoader("model2"));
+            Assert.assertNull(zoo.getModelLoader("model3"));
+            Assert.assertNotNull(zoo.getModelLoader("model4"));
+        } finally {
+            System.clearProperty("DJL_CACHE_DIR");
+        }
     }
 }
diff --git a/testing/build.gradle b/testing/build.gradle
index 9b2081f35..286600d4c 100644
--- a/testing/build.gradle
+++ b/testing/build.gradle
@@ -1,4 +1,14 @@
 dependencies {
     api project(":api")
-    api "org.testng:testng:${testng_version}"
+    api("org.testng:testng:${testng_version}") {
+        exclude group: "junit", module: "junit"
+    }
+}
+
+java {
+    compileJava {
+        sourceCompatibility = JavaVersion.VERSION_11
+        targetCompatibility = JavaVersion.VERSION_11
+        options.compilerArgs.removeAll(["--release", "8"])
+    }
 }