Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safety check for JDK 8 on non-Oracle #154

Merged
merged 1 commit into from
Mar 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']}"
27 changes: 27 additions & 0 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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