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 the default-java symlink to Oracle JDK #143

Merged
merged 2 commits into from
Mar 15, 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
7 changes: 7 additions & 0 deletions recipes/default_java_symlink.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if platform_family?('debian')
link '/usr/lib/jvm/default-java' do
to node['java']['java_home']
not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' }
end
end

7 changes: 1 addition & 6 deletions recipes/openjdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@
end
end

if platform_family?('debian')
link '/usr/lib/jvm/default-java' do
to node['java']['java_home']
not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' }
end
end
include_recipe 'java::default_java_symlink'

# We must include this recipe AFTER updating the alternatives or else JAVA_HOME
# will not point to the correct java.
Expand Down
1 change: 1 addition & 0 deletions recipes/oracle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@
action :install
end

include_recipe 'java::default_java_symlink'
2 changes: 2 additions & 0 deletions recipes/oracle_i386.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@
action :install
default false
end

include_recipe 'java::default_java_symlink'
31 changes: 31 additions & 0 deletions spec/oracle_i386_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,35 @@
end
end
end

describe 'default-java' do
context 'ubuntu' do
let(:chef_run) do
ChefSpec::Runner.new(
:platform => 'ubuntu',
:version => '12.04'
).converge(described_recipe)
end

it 'symlinks /usr/lib/jvm/default-java' do
link = chef_run.link('/usr/lib/jvm/default-java')
expect(link).to link_to(chef_run.node['java']['java_home'])
end
end

context 'centos' do
let(:chef_run) do
ChefSpec::Runner.new(
:platform => 'centos',
:version => '6.4'
).converge(described_recipe)
end

it 'does not symlink /usr/lib/jvm/default-java' do
link = chef_run.link('/usr/lib/jvm/default-java')
expect(link).not_to link_to(chef_run.node['java']['java_home'])
end
end
end

end
31 changes: 31 additions & 0 deletions spec/oracle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,35 @@
end
end
end

describe 'default-java' do
context 'ubuntu' do
let(:chef_run) do
ChefSpec::Runner.new(
:platform => 'ubuntu',
:version => '12.04'
).converge(described_recipe)
end

it 'symlinks /usr/lib/jvm/default-java' do
link = chef_run.link('/usr/lib/jvm/default-java')
expect(link).to link_to(chef_run.node['java']['java_home'])
end
end

context 'centos' do
let(:chef_run) do
ChefSpec::Runner.new(
:platform => 'centos',
:version => '6.4'
).converge(described_recipe)
end

it 'does not symlink /usr/lib/jvm/default-java' do
link = chef_run.link('/usr/lib/jvm/default-java')
expect(link).not_to link_to(chef_run.node['java']['java_home'])
end
end
end

end