diff options
| author | mo khan <mo.khan@gmail.com> | 2020-06-05 14:03:06 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-06-05 14:03:06 -0600 |
| commit | 812d23695017ae34f196d19742821f20167c3704 (patch) | |
| tree | ff9294fbffb2fa13014126b82a72361361632cad /spec/integration/java | |
| parent | 12ef778891c4bf9fae19ffdc9d566fc7ab309957 (diff) | |
Launch the desired Java version
Diffstat (limited to 'spec/integration/java')
| -rw-r--r-- | spec/integration/java/maven_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/integration/java/maven_spec.rb b/spec/integration/java/maven_spec.rb index 85637b2..1e0e4e4 100644 --- a/spec/integration/java/maven_spec.rb +++ b/spec/integration/java/maven_spec.rb @@ -100,4 +100,46 @@ RSpec.describe "maven" do specify { expect(report.dependency_names).to match_array(['jackson-core']) } specify { expect(report.licenses_for('jackson-core')).to match_array(['Apache-2.0']) } end + + context "when specifying the version of java using environment variables" do + let(:output_file) { Pathname.new(runner.project_path.join('output.txt')) } + + before do + runner.add_file('custom.sh') do + <<~SCRIPT + #!/bin/bash -l + + java -version 2> '#{output_file}' + SCRIPT + end + end + + it 'prioritizes `LM_JAVA_VERSION` over the `ASDF_JAVA_VERSION`' do + runner.scan(env: { + 'ASDF_JAVA_VERSION' => 'adopt-openjdk-11.0.7+10', + 'LM_JAVA_VERSION' => '8', + 'SETUP_CMD' => 'bash custom.sh' + }) + + expect(output_file).to exist + expect(output_file.read).to include('openjdk version "1.8.0_242"') + end + + it 'reads the ASDF_JAVA_VERSION' do + runner.scan(env: { + 'ASDF_JAVA_VERSION' => 'adopt-openjdk-11.0.7+10', + 'SETUP_CMD' => 'bash custom.sh' + }) + + expect(output_file).to exist + expect(output_file.read).to include('openjdk version "11.0.7"') + end + + it 'defaults to java 8' do + runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) + + expect(output_file).to exist + expect(output_file.read).to include('openjdk version "1.8.0_242"') + end + end end |
