diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d3840f..ea08ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## Supported Release 2.1.0 +### Summary +This release adds fixes to restore the ability to install Oracle Java. It also +fixes the paths for the latest RHEL 7 1.7.0 and 1.8.0 OpenJDKs. + +### Added +- java::oracle parameter `url` +- java::oracle parameter `url_hash` + +### Fixed +- Let `java_default_home` fact work when /usr/bin/java doesn't exist +- Add puppet 4 parameter types +- Use `/usr/lib/jvm/java-1.x.0` symlinks for `java_home` defaults. + ## Supported Release 2.0.0 ### Summary diff --git a/README.markdown b/README.markdown index 836e363..eec77f6 100644 --- a/README.markdown +++ b/README.markdown @@ -13,7 +13,7 @@ ## Overview -Installs the correct Java package on various platforms. +Installs the correct Java package on various platforms. ## Module Description @@ -22,29 +22,30 @@ The java module can automatically install Java jdk or jre on a wide variety of s ## Setup ### Beginning with the java module + To install the correct Java package on your system, include the `java` class: `include java`. ## Usage The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter: -~~~ +```puppet class { 'java': distribution => 'jre', } -~~~ +``` -To install the latest patch version of Java 8 on CentOS +To install the latest patch version of Java 8 on CentOS -~~~ +```puppet class { 'java' : package => 'java-1.8.0-openjdk-devel', } -~~~ +``` The defined type `java::oracle` installs one or more versions of Oracle Java SE. `java::oracle` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive). By using `java::oracle` you agree to Oracle's licensing terms for Java SE. -~~~ +```puppet java::oracle { 'jdk6' : ensure => 'present', version => '6', @@ -56,18 +57,18 @@ java::oracle { 'jdk8' : version => '8', java_se => 'jdk', } -~~~ +``` To install a specific release of a Java version, e.g. 8u101-b13, provide both parameters `version_major` and `version_minor` as follows: -~~~ +```puppet java::oracle { 'jdk8' : ensure => 'present', version_major => '8u101', version_minor => 'b13', java_se => 'jdk', } -~~~ +``` ## Reference @@ -85,26 +86,32 @@ java::oracle { 'jdk8' : #### Parameters + The following parameters are available in `java`: ##### `distribution` -Specifies the Java distribution to install. + +Specifies the Java distribution to install. Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'. ##### `java_alternative` -Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.* + +Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.* Valid options: Run command `update-java-alternatives -l` for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others. -##### `java_alternative_path` -*Required when `java_alternative` is specified.* Defines the path to the `java` command. +##### `java_alternative_path` + +*Required when `java_alternative` is specified.* Defines the path to the `java` command. Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others. ##### `package` -Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing. -Valid option: String. Default: undef. + +Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing. +Valid option: String. Default: undef. ##### `version` -Sets the version of Java to install, if you want to ensure a particular version. + +Sets the version of Java to install, if you want to ensure a particular version. Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9a-zA-Z:-]+$/`. Default: 'present'. #### Public defined types @@ -119,26 +126,41 @@ The following parameters are available in `java::oracle`: Version of Java Standard Edition (SE) to install. 6, 7 or 8. ##### `version_major` + Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'. ##### `version_minor` + Minor version (or build version) of the Java Standard Edition (SE) to install. Must be used together with `version_major`. For example, 'b13'. ##### `java_se` + Type of Java SE to install, jdk or jre. ##### `ensure` + Install or remove the package. ##### `oracle_url` + Official Oracle URL to download the binaries from. ##### `proxy_server` + Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive) ##### `proxy_type` + Proxy server type (none|http|https|ftp). (passed to archive) +##### `url` + +Pass an entire URL to download the installer from rather than building the complete URL from other parameters. This will allow the module to be used even if the URLs are changed by Oracle. If this parameter is used, matching `version_major` and `version_minor` parameters must also be passed to the class. + +##### `url_hash` + +Directory hash used by the download.oracle.com site. This value is a 32 character string which is part of the file URL returned by the JDK download site. + ### Facts The java module includes a few facts to describe the version of Java installed on the system: @@ -153,7 +175,7 @@ The java module includes a few facts to describe the version of Java installed o ## Limitations -This module cannot guarantee installation of Java versions that are not available on platform repositories. +This module cannot guarantee installation of Java versions that are not available on platform repositories. This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system. @@ -161,7 +183,7 @@ Oracle Java packages are not included in Debian 7 and Ubuntu 12.04/14.04 reposit This module is officially [supported](https://forge.puppetlabs.com/supported) for the following Java versions and platforms: -OpenJDK is supported on: +OpenJDK is supported on: * Red Hat Enterprise Linux (RHEL) 5, 6, 7 * CentOS 5, 6, 7 @@ -173,15 +195,18 @@ OpenJDK is supported on: * SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2 * OpenBSD 5.6, 5.7 -Sun Java is supported on: +Sun Java is supported on: * Debian 6 Oracle Java is supported on: + * CentOS 6 ### Known issues +Where Oracle change the format of the URLs to different installer packages, the curl to fetch the package may fail with a HTTP/404 error. In this case, passing a full known good URL using the `url` parameter will allow the module to still be able to install specific versions of the JRE/JDK. Note the `version_major` and `version_minor` parameters must be passed and must match the version downloaded using the known URL in the `url` parameter. + #### OpenBSD OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking diff --git a/lib/facter/java_default_home.rb b/lib/facter/java_default_home.rb index 9a70934..330f037 100644 --- a/lib/facter/java_default_home.rb +++ b/lib/facter/java_default_home.rb @@ -15,7 +15,9 @@ Facter.add(:java_default_home) do setcode do if Facter::Util::Resolution.which('readlink') java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip - if java_bin =~ %r(/jre/) + if java_bin.empty? + nil + elsif java_bin =~ %r(/jre/) java_default_home = File.dirname(File.dirname(File.dirname(java_bin))) else java_default_home = File.dirname(File.dirname(java_bin)) diff --git a/manifests/init.pp b/manifests/init.pp index 2a8efd6..2a9a7d9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,22 +46,16 @@ # Sample Usage: # class java( - $distribution = 'jdk', - $version = 'present', - $package = undef, - $package_options = undef, - $java_alternative = undef, - $java_alternative_path = undef, - $java_home = undef + String $distribution = 'jdk', + Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present', + Optional[String] $package = undef, + Optional[Array] $package_options = undef, + Optional[String] $java_alternative = undef, + Optional[String] $java_alternative_path = undef, + Optional[String] $java_home = undef ) { include java::params - validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:~-]+$') - - if $package_options != undef { - validate_array($package_options) - } - if has_key($java::params::java, $distribution) { $default_package_name = $java::params::java[$distribution]['package'] $default_alternative = $java::params::java[$distribution]['alternative'] diff --git a/manifests/oracle.pp b/manifests/oracle.pp index af9e5f3..198f105 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -10,7 +10,7 @@ # the licensing terms. # wget --no-cookies --no-check-certificate --header \ # "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ -# "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.tar.gz" +# "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz" # # Parameters # [*version*] @@ -80,7 +80,12 @@ # # [*url*] # Full URL, including oracle_url, release_major, release_minor and package_name, to -# download the Oracle java_se installer. +# download the Oracle java_se installer. Originally present but not used, activated +# to workaround MODULES-5058 +# +# [*url_hash*] +# Directory hash used by the download.oracle.com site. This value is a 32 character string +# which is part of the file URL returned by the JDK download site. # # ### Author # mike@marseglia.org @@ -94,6 +99,8 @@ define java::oracle ( $oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/', $proxy_server = undef, $proxy_type = undef, + $url = undef, + $url_hash = undef, ) { # archive module is used to download the java package @@ -108,8 +115,11 @@ define java::oracle ( # determine Oracle Java major and minor version, and installation path if $version_major and $version_minor { + $release_major = $version_major $release_minor = $version_minor + $release_hash = $url_hash + if $release_major =~ /(\d+)u(\d+)/ { $install_path = "${java_se}1.${1}.0_${2}" } else { @@ -122,21 +132,25 @@ define java::oracle ( $release_major = '6u45' $release_minor = 'b06' $install_path = "${java_se}1.6.0_45" + $release_hash = undef } '7' : { $release_major = '7u80' $release_minor = 'b15' $install_path = "${java_se}1.7.0_80" + $release_hash = undef } '8' : { - $release_major = '8u51' - $release_minor = 'b16' - $install_path = "${java_se}1.8.0_51" + $release_major = '8u131' + $release_minor = 'b11' + $install_path = "${java_se}1.8.0_131" + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } default : { - $release_major = '8u51' - $release_minor = 'b16' - $install_path = "${java_se}1.8.0_51" + $release_major = '8u131' + $release_minor = 'b11' + $install_path = "${java_se}1.8.0_131" + $release_hash = 'd54c1d3a095b4ff2b6607d096fa80163' } } } @@ -175,11 +189,11 @@ define java::oracle ( } # following are based on this example: - # http://download.oracle.com/otn/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm + # http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm # # JaveSE 6 distributed in .bin format - # http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin - # http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin + # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin + # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin # package name to download from Oracle's website case $package_type { 'bin' : { @@ -196,6 +210,15 @@ define java::oracle ( } } + # if complete URL is provided, use this value for source in archive resource + if $url { + $source = $url + } elsif $release_hash != undef { + $source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}" + } else { + $source = "${oracle_url}/${release_major}-${release_minor}/${package_name}" + } + # full path to the installer $destination = "${destination_dir}${package_name}" notice ("Destination is ${destination}") @@ -219,7 +242,7 @@ define java::oracle ( 'present' : { archive { $destination : ensure => present, - source => "${oracle_url}${release_major}-${release_minor}/${package_name}", + source => $source, cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', extract_path => '/tmp', cleanup => false, @@ -233,7 +256,7 @@ define java::oracle ( path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', command => $install_command, creates => $creates_path, - require => Archive[$destination] + require => Archive[$destination], } } default : { diff --git a/manifests/params.pp b/manifests/params.pp index 9e7a30d..6aa558a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,20 +21,22 @@ class java::params { $jre_package = 'java-1.6.0-sun' $java_home = '/usr/lib/jvm/java-1.6.0-sun/jre/' } + # See cde7046 for why >= 5.0 < 6.3 elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) { $jdk_package = 'java-1.6.0-openjdk-devel' $jre_package = 'java-1.6.0-openjdk' - $java_home = "/usr/lib/jvm/java-1.6.0-openjdk-${::architecture}/" + $java_home = '/usr/lib/jvm/java-1.6.0/' } + # See PR#160 / c8e46b5 for why >= 6.3 < 7.1 elsif (versioncmp($::operatingsystemrelease, '7.1') < 0) { $jdk_package = 'java-1.7.0-openjdk-devel' $jre_package = 'java-1.7.0-openjdk' - $java_home = "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/" + $java_home = '/usr/lib/jvm/java-1.7.0/' } else { $jdk_package = 'java-1.8.0-openjdk-devel' $jre_package = 'java-1.8.0-openjdk' - $java_home = "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/" + $java_home = '/usr/lib/jvm/java-1.8.0/' } } 'Fedora': { diff --git a/metadata.json b/metadata.json index eeb2b4a..0e3362c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-java", - "version": "2.0.0", + "version": "2.1.0", "author": "puppetlabs", "summary": "Installs the correct Java package on various platforms.", "license": "Apache-2.0", @@ -89,7 +89,13 @@ } ], "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 2.4.0 < 5.0.0"}, - {"name":"puppet/archive","version_requirement":">= 1.1.0 < 2.0.0"} + { + "name":"puppetlabs/stdlib", + "version_requirement": ">= 4.13.1 < 5.0.0" + }, + { + "name":"puppet/archive", + "version_requirement": ">= 1.1.0 < 2.0.0" + } ] } diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index a4d2e7b..ff56262 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -5,19 +5,19 @@ describe 'java', :type => :class do context 'select openjdk for Centos 5.8' do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8', :architecture => 'x86_64'} } it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-x86_64/') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0/') } end context 'select openjdk for Centos 6.3' do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3', :architecture => 'x86_64'} } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') } end context 'select openjdk for Centos 7.1.1503' do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503', :architecture => 'x86_64'} } it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-x86_64/') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0/') } end context 'select openjdk for Centos 6.2' do @@ -193,14 +193,14 @@ describe 'java', :type => :class do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:params) { { 'distribution' => 'jre' } } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') } end context 'select passed value for Scientific Linux CERN (SLC)' do let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:params) { { 'distribution' => 'jre' } } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } - it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') } end context 'select default for OpenSUSE 12.3' do diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index f2f4da3..7115657 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -23,9 +23,9 @@ describe 'java::oracle', :type => :define do context 'Oracle Java SE 8 JDK' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-x64.rpm')} - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-x64.rpm]') } + it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm')} + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') } end context 'Oracle Java SE 6 JRE' do @@ -47,11 +47,16 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JRE' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let :title do 'jre8' end - it { is_expected.to contain_archive('/tmp/jre-8u51-linux-x64.rpm')} - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-x64.rpm]') } + it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.rpm')} + it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') } end + context 'Pass URL to url parameter' do + let(:params) { {:ensure => 'present', :version_major => '8u131', :version_minor => 'b11', :java_se => 'jdk', :url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm'} } + let :title do 'jdk8' end + it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm')} + end end context 'On CentOS 32-bit' do @@ -76,9 +81,9 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-i586.rpm')} - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-i586.rpm]') } + it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-i586.rpm')} + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') } end context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do @@ -100,9 +105,9 @@ describe 'java::oracle', :type => :define do context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let :title do 'jdk8' end - it { is_expected.to contain_archive('/tmp/jre-8u51-linux-i586.rpm')} - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-i586.rpm]') } + it { is_expected.to contain_archive('/tmp/jre-8u131-linux-i586.rpm')} + it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') } end end diff --git a/spec/unit/facter/java_default_home_spec.rb b/spec/unit/facter/java_default_home_spec.rb index b7b7bbe..41be89e 100644 --- a/spec/unit/facter/java_default_home_spec.rb +++ b/spec/unit/facter/java_default_home_spec.rb @@ -29,6 +29,14 @@ describe Facter::Util::Fact do end end end + context 'returns nil when readlink is present but java is not' do + it do + java_path_output = "" + Facter::Util::Resolution.expects(:which).with("readlink").returns(true) + Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output) + expect(Facter.value(:java_default_home)).to be_nil + end + end context 'returns nil when readlink not present' do it do