Sha256: b2312085c17d4a23f40af000ded144065197c4c8cafda59ed954ad2b87c846f7

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'optparse'

describe Trinidad::Extensions::DaemonServerExtension do
  subject { Trinidad::Extensions::DaemonServerExtension.new({}) }

  before(:each) do
    @tomcat = Trinidad::Tomcat::Tomcat.new
  end

  it "bypass the control to the daemon" do
    daemon = subject.configure(@tomcat)
    daemon.should_not be_nil
    daemon.should be_instance_of(org.jruby.trinidad.TrinidadDaemon)
  end

  it "uses a temporal directory to write the pid file by default" do
    daemon = subject.configure(@tomcat)
    daemon.pid_file.should =~ /trinidad.pid$/
  end

  it "can use a given pid file" do
    extension = Trinidad::Extensions::DaemonServerExtension.new(:pid_file => 'trinidad_pid.txt')
    daemon = extension.configure(@tomcat)
    daemon.pid_file.should =~ /trinidad_pid.txt$/
  end

  it "allows to pass jvm arguments to the daemon" do
    extension = Trinidad::Extensions::DaemonServerExtension.new({
      :jvm_args => '-Xmx=2048m -XX:MaxPermSize=2048m'
    })

    extension.jvm_args.should have(2).arguments
  end
end

describe Trinidad::Extensions::DaemonOptionsExtension do
  it "allows to specify a command line option to run the daemon" do
    parser = OptionParser.new
    options = {}

    subject.configure(parser, options)
    parser.parse! '--daemonize /tmp/trinidad.pid'.split

    options[:extensions].keys.should include(:daemon)
    options[:extensions][:daemon].should include(:pid_file)
    options[:extensions][:daemon][:pid_file].should == '/tmp/trinidad.pid'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trinidad_daemon_extension-0.2.10 spec/trinidad_daemon_extension_spec.rb
trinidad_daemon_extension-0.2.9 spec/trinidad_daemon_extension_spec.rb
trinidad_daemon_extension-0.2.8 spec/trinidad_daemon_extension_spec.rb
trinidad_daemon_extension-0.2.7 spec/trinidad_daemon_extension_spec.rb