diff --git a/recipes/default.rb b/recipes/default.rb index 5417e69b..b2447478 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,5 +18,9 @@ # limitations under the License. # +if node['java']['jdk_version'].to_i == 8 and node['java']['install_flavor'] != 'oracle' + Chef::Application.fatal!("JDK 8 is currently only provided with the Oracle JDK") +end + include_recipe "java::set_attributes_from_version" include_recipe "java::#{node['java']['install_flavor']}" diff --git a/spec/default_spec.rb b/spec/default_spec.rb index bb5e36a3..9eac5e30 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -83,4 +83,31 @@ end end + context 'Oracle JDK 8' do + let(:chef_run) do + runner = ChefSpec::Runner.new + runner.node.set['java']['install_flavor'] = 'oracle' + runner.node.set['java']['jdk_version'] = '8' + runner.converge(described_recipe) + end + + it 'should not error' do + expect{chef_run}.to_not raise_error + end + end + + context 'OpenJDK 8' do + let(:chef_run) do + runner = ChefSpec::Runner.new + runner.node.set['java']['install_flavor'] = 'openjdk' + runner.node.set['java']['jdk_version'] = '8' + runner.converge(described_recipe) + end + + it 'should error' do + expect{chef_run}.to raise_error + end + end + + end