Skip to content

Latest commit

 

History

History
171 lines (131 loc) · 2.57 KB

test.clitest.md

File metadata and controls

171 lines (131 loc) · 2.57 KB

jvm test suite

This is the self-document test suite for JVM.

Initial setup

Just cleanup, variable setting and source what needs to be sourced.

$ ROOT="$(pwd)"
$ TESTS="tests"
$ find . -name '.java-version' -delete
$ source jvm.sh
$ export MAVEN_OPTS=""
$ echo "8=$(__jvm_javahome 7)" > ~/.jvmconfig
$

jvm global

Test setting a global version.

$ jvm global 7
$ jvm version
7
$

jvm local

Test setting a version to the current folder.

$ jvm local 7
$ jvm version
7
$

maven.compiler.source

Test a pom with a maven.compiler.source property set to Java 8.

$ cd "$ROOT/$TESTS/java8"
$ jvm reload
$ jvm version
8
$

java.version

Test a pom with a java.version property set to Java 7.

$ cd "$ROOT/$TESTS/java7"
$ jvm reload
$ jvm version
7
$

maven-compiler-plugin

Test reading the source tag from maven-compiler-plugin, which in this example is set to Java 7.

$ cd "$ROOT/$TESTS/grep"
$ jvm reload
$ jvm version
7
$

parent pom

Test a pom with no java config at all, the config is at its parent pom, therefore, this will run mvn help:evaluate and find out that the parent is using Java 8.

$ cd "$ROOT/$TESTS/java8/empty"
$ jvm reload
$ jvm version
8
$

simple build.gradle

Test a simple build.gradle with only one source/target Compatibility property set.

$ cd "$ROOT/$TESTS/gradle"
$ jvm reload
$ jvm version
7
$

complex build.gradle

Test a simple build.gradle with both source and target compatibility property set.

$ cd "$ROOT/$TESTS/complex-gradle"
$ jvm reload
$ jvm version
7
$

parent build.gradle

When the build.gradle in the current folder don't define the java version, look for files in the parent folder.

$ cd "$ROOT/$TESTS/complex-gradle/sub"
$ jvm reload
$ jvm version
7
$

jvmconfig

Test that jvm respects a custom java version in ~/.jvmconfig, in this case, pointing out Java 6 to use Java 7 home.

$ cd "$ROOT/$TESTS/grep"
$ echo "6=$(__jvm_javahome 7)" >> ~/.jvmconfig
$ jvm local 6
$ jvm reload
$ jvm version
6
$

nonjava

Test that a folder with a pom.xml, but which is not being used to compile java projects, will get an empty .java-version to avoid running mvn evaluate every time.

$ jvm global 7
$ cd "$ROOT/$TESTS/nonjava"
$ jvm reload
$ jvm version
7
$

Cleanup

Remove unneeded files after all tests ran.

$ cd "$ROOT"
$ find . -name '.java-version' -delete
$ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig
$ jvm global 8 2> /dev/null
$