aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoretienne-chrp <66628513+etienne-chrp@users.noreply.github.com>2022-11-17 03:46:30 +0300
committerGitHub <noreply@github.com>2022-11-17 03:46:30 +0300
commitbe4f0498e4ad7948804d4be70093c1da8722d222 (patch)
treea50ac3ee2038a5b4130b7bdfcace59b4140efc5b /test
parentbff31788373499fdc903bad8f1b300d579c42d39 (diff)
Add Gradle and Maven version parameters to Java (#263)
* Refactor java feature tests grep syntax The grep with pipe syntax was creating problems with the check helper Change them in favour of process substitution syntax * Fix java feature tests about java version Java 18 is not available anymore in SDKMAN Some tests asserts were generating false positives * Add Gradle and Maven version parameters to Java
Diffstat (limited to 'test')
-rw-r--r--test/java/install_additional_java.sh6
-rw-r--r--test/java/install_from_non_default_distro.sh2
-rw-r--r--test/java/install_gradle_and_maven.sh6
-rw-r--r--test/java/install_gradle_and_maven_for_user.sh6
-rw-r--r--test/java/install_gradle_and_maven_with_specific_version.sh21
-rw-r--r--test/java/scenarios.json18
6 files changed, 46 insertions, 13 deletions
diff --git a/test/java/install_additional_java.sh b/test/java/install_additional_java.sh
index fcfd6bd..882c49d 100644
--- a/test/java/install_additional_java.sh
+++ b/test/java/install_additional_java.sh
@@ -5,9 +5,9 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-check "java version 18 installed as default" java --version | grep 18
-check "java version 11 installed" ls /usr/local/sdkman/candidates/java | grep 11
-check "java version 8 installed" ls /usr/local/sdkman/candidates/java | grep 8
+check "java version 11 installed as default" grep "11\." <(java --version)
+check "java version 17 installed" grep "^17\." <(ls /usr/local/sdkman/candidates/java)
+check "java version 8 installed" grep "^8\." <(ls /usr/local/sdkman/candidates/java)
# Report result
reportResults
diff --git a/test/java/install_from_non_default_distro.sh b/test/java/install_from_non_default_distro.sh
index e45f9dd..d4f5381 100644
--- a/test/java/install_from_non_default_distro.sh
+++ b/test/java/install_from_non_default_distro.sh
@@ -5,7 +5,7 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-check "java version 18 installed as default" java --version | grep 18
+check "java version openjdk 11 installed" grep "openjdk 11." <(java --version)
# Report result
reportResults
diff --git a/test/java/install_gradle_and_maven.sh b/test/java/install_gradle_and_maven.sh
index c6aa3e5..636fd92 100644
--- a/test/java/install_gradle_and_maven.sh
+++ b/test/java/install_gradle_and_maven.sh
@@ -5,17 +5,17 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-check "user is root" whoami | grep root
+check "user is root" grep root <(whoami)
check "java" java --version
check "gradle" gradle --version
cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test
-check "GRADLE_USER_HOME exists" ls -la /root | grep ".gradle"
+check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root)
check "maven" mvn --version
cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
-check "m2 exists" ls -la /root | grep ".m2"
+check "m2 exists" grep ".m2" <(ls -la /root)
# Report result
reportResults
diff --git a/test/java/install_gradle_and_maven_for_user.sh b/test/java/install_gradle_and_maven_for_user.sh
index c724092..b6ea426 100644
--- a/test/java/install_gradle_and_maven_for_user.sh
+++ b/test/java/install_gradle_and_maven_for_user.sh
@@ -5,17 +5,17 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-check "user is vscode" whoami | grep vscode
+check "user is vscode" grep vscode <(whoami)
check "java" java --version
check "gradle" gradle --version
cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test
-check "GRADLE_USER_HOME exists" ls -la /home/vscode | grep ".gradle"
+check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /home/vscode)
check "maven" mvn --version
cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
-check "m2 exists" ls -la /home/vscode | grep ".m2"
+check "m2 exists" grep ".m2" <(ls -la /home/vscode)
# Report result
reportResults
diff --git a/test/java/install_gradle_and_maven_with_specific_version.sh b/test/java/install_gradle_and_maven_with_specific_version.sh
new file mode 100644
index 0000000..c6ae6160
--- /dev/null
+++ b/test/java/install_gradle_and_maven_with_specific_version.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+check "user is root" grep root <(whoami)
+
+check "java" java --version
+check "gradle version" grep "Gradle 6.8.3" <(gradle --version)
+
+cd /tmp && gradle init --type basic --dsl groovy --project-name test
+check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root)
+
+check "maven version" grep "Apache Maven 3.6.3" <(mvn --version)
+cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
+check "m2 exists" grep ".m2" <(ls -la /root)
+
+# Report result
+reportResults
diff --git a/test/java/scenarios.json b/test/java/scenarios.json
index eec7ba5..c33a0a7 100644
--- a/test/java/scenarios.json
+++ b/test/java/scenarios.json
@@ -3,7 +3,7 @@
"image": "ubuntu:focal",
"features": {
"java": {
- "version": "18",
+ "version": "11",
"jdkDistro": "open"
}
}
@@ -12,8 +12,8 @@
"image": "ubuntu:focal",
"features": {
"java": {
- "version": "18",
- "additionalVersions": "11,8"
+ "version": "11",
+ "additionalVersions": "17,8"
}
}
},
@@ -40,5 +40,17 @@
"installMaven": true
}
}
+ },
+ "install_gradle_and_maven_with_specific_version": {
+ "image": "ubuntu:focal",
+ "features": {
+ "java": {
+ "version": "latest",
+ "installGradle": "true",
+ "gradleVersion": "6.8.3",
+ "installMaven": "true",
+ "mavenVersion": "3.6.3"
+ }
+ }
}
}