install_spec.rb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. require 'spec_helper'
  2. describe 'fmw_jdk::install' , :type => :class do
  3. describe 'When all attributes are default, on an unspecified platform' do
  4. it do
  5. expect { should contain_package('xxx')
  6. }.to raise_error(Puppet::Error, /Not supported Operation System, please use it on windows, linux or solaris host/)
  7. end
  8. end
  9. describe 'With attributes, on an unspecified platform' do
  10. let(:params){{
  11. :java_home_dir => '/usr/java/jdk1.8.0_XX',
  12. :source_file => '/software/jdk-8u40-linux-x64.rpm',
  13. }}
  14. it do
  15. expect { should contain_package('xxx')
  16. }.to raise_error(Puppet::Error, /Not supported Operation System, please use it on windows, linux or solaris host/)
  17. end
  18. end
  19. describe 'With attributes and extra source_x64_file, on a linux platform' do
  20. let(:facts) {{ operatingsystem: 'CentOS',
  21. kernel: 'Linux',
  22. osfamily: 'RedHat',
  23. operatingsystemmajrelease: '6' }}
  24. let(:params){{
  25. :java_home_dir => '/usr/java/jdk1.7.0_XX',
  26. :source_file => '/software/jdk-7u75-solaris-i586.tar.gz',
  27. :source_x64_file => '/software/jdk-7u75-solaris-x64.tar.gz',
  28. }}
  29. it do
  30. expect { should contain_package('xxx')
  31. }.to raise_error(Puppet::Error, /source_x64_file is only used in solaris for installing JDK x64 extension/)
  32. end
  33. end
  34. describe 'With attributes, rpm on CentOS platform' do
  35. let(:facts) {{ operatingsystem: 'CentOS',
  36. kernel: 'Linux',
  37. osfamily: 'RedHat',
  38. operatingsystemmajrelease: '6' }}
  39. let(:params){{
  40. :java_home_dir => '/usr/java/jdk1.8.0_XX',
  41. :source_file => '/software/jdk-8u40-linux-x64.rpm'
  42. }}
  43. it { should contain_fmw_jdk_linux_rpm('/usr/java/jdk1.8.0_XX').with(
  44. ensure: 'present',
  45. java_home_dir: '/usr/java/jdk1.8.0_XX',
  46. source_file: '/software/jdk-8u40-linux-x64.rpm'
  47. )
  48. }
  49. end
  50. describe 'With default attributes, on CentOS platform' do
  51. let(:facts) {{ operatingsystem: 'CentOS',
  52. kernel: 'Linux',
  53. osfamily: 'RedHat',
  54. operatingsystemmajrelease: '6' }}
  55. it do
  56. expect { should contain_package('xxx')
  57. }.to raise_error(Puppet::Error, /java_home_dir parameter cannot be empty/)
  58. end
  59. end
  60. describe 'With java_home_dir attribute, on CentOS platform' do
  61. let(:facts) {{ operatingsystem: 'CentOS',
  62. kernel: 'Linux',
  63. osfamily: 'RedHat',
  64. operatingsystemmajrelease: '6' }}
  65. let(:params){{
  66. :java_home_dir => '/usr/java/jdk1.8.0_XX'
  67. }}
  68. it do
  69. expect { should contain_package('xxx')
  70. }.to raise_error(Puppet::Error, /source_file parameter cannot be empty/)
  71. end
  72. end
  73. describe 'With attributes, tar.gz on CentOS platform' do
  74. let(:facts) {{ operatingsystem: 'CentOS',
  75. kernel: 'Linux',
  76. osfamily: 'RedHat',
  77. operatingsystemmajrelease: '6' }}
  78. let(:params){{
  79. :java_home_dir => '/usr/java/jdk1.7.0_XX',
  80. :source_file => '/software/jdk-7u75-linux-x64.tar.gz',
  81. }}
  82. it { should contain_class('fmw_jdk::internal::jdk_linux').with(
  83. java_home_dir: '/usr/java/jdk1.7.0_XX',
  84. source_file: '/software/jdk-7u75-linux-x64.tar.gz'
  85. )
  86. }
  87. end
  88. describe 'With attributes, on Windows platform' do
  89. let(:facts) {{ kernel: 'windows', }}
  90. let(:params){{
  91. :java_home_dir => 'C:/java/jdk1.7.0_XX',
  92. :source_file => 'C:/software/jdk-7u75-windows-x64.exe',
  93. }}
  94. it { should contain_class('fmw_jdk::internal::jdk_windows').with(
  95. java_home_dir: 'C:/java/jdk1.7.0_XX',
  96. source_file: 'C:/software/jdk-7u75-windows-x64.exe'
  97. )
  98. }
  99. end
  100. describe 'With attributes and extra source_x64_file, on a Solaris platform' do
  101. let(:facts) {{ operatingsystem: 'Solaris',
  102. kernel: 'SunOS',
  103. osfamily: 'SunOS',
  104. operatingsystemmajrelease: '5.11' }}
  105. let(:params){{
  106. :java_home_dir => '/usr/java/jdk1.7.0_XX',
  107. :source_file => '/software/jdk-7u75-solaris-i586.tar.gz',
  108. :source_x64_file => '/software/jdk-7u75-solaris-x64.tar.gz'
  109. }}
  110. it { should contain_class('fmw_jdk::internal::jdk_solaris').with(
  111. java_home_dir: '/usr/java/jdk1.7.0_XX',
  112. source_file: '/software/jdk-7u75-solaris-i586.tar.gz',
  113. source_x64_file: '/software/jdk-7u75-solaris-x64.tar.gz'
  114. )
  115. }
  116. end
  117. describe 'With attributes, tar.Z, on a Solaris platform' do
  118. let(:facts) {{ operatingsystem: 'Solaris',
  119. kernel: 'SunOS',
  120. osfamily: 'SunOS',
  121. operatingsystemmajrelease: '5.11' }}
  122. let(:params){{
  123. :java_home_dir => '/usr/java/jdk1.8.0_XX',
  124. :source_file => '/software/jdk-8u40-solaris-x64.tar.Z',
  125. }}
  126. it { should contain_class('fmw_jdk::internal::jdk_solaris_z').with(
  127. java_home_dir: '/usr/java/jdk1.8.0_XX',
  128. source_file: '/software/jdk-8u40-solaris-x64.tar.Z',
  129. )
  130. }
  131. end
  132. end