diff --git a/spec/classes/collectd_plugin_java_spec.rb b/spec/classes/collectd_plugin_java_spec.rb index 86bddfd04..69c92cffc 100644 --- a/spec/classes/collectd_plugin_java_spec.rb +++ b/spec/classes/collectd_plugin_java_spec.rb @@ -12,7 +12,6 @@ :path => '/etc/collectd.d/10-java.conf', }) - should contain_file('java.load').with_content(//) should contain_file('java.load').without_content(/JVMArg/) end end @@ -53,5 +52,15 @@ should contain_file('java.load').without_content(/(.*JVMArg.*){2,}/) end end + + context 'jvmarg parameter empty' do + let (:params) {{ + :jvmarg => [], + }} + + it 'will not have a stanza' do + should contain_file('java.load').without_content(//) + end + end end diff --git a/templates/plugin/java.conf.erb b/templates/plugin/java.conf.erb index bf7d2ce8c..0ab321810 100644 --- a/templates/plugin/java.conf.erb +++ b/templates/plugin/java.conf.erb @@ -1,7 +1,7 @@ +<% if !Array(@jvmarg).empty? -%> - <% if @jvmarg -%> - <% Array(@jvmarg).each do |arg| -%> + <% Array(@jvmarg).each do |arg| -%> JVMArg "<%= arg %>" - <% end -%> <% end -%> +<% end -%>