Sha256: 6105da3099154f366e7a87a2bda137ad8c6658dc84d336316f45dfa8a0ba8af9

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

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

describe TomcatRails::WebApp do
  before do
    @tomcat = TomcatRails::Tomcat::Tomcat.new
    tomcat_web_app = @tomcat.addWebapp('/', File.dirname(__FILE__) + '/../../')
    config = { 
      :libs_dir => 'lib',
      :classes_dir => 'classes',
      :default_web_xml => 'config/web.xml',
      :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock'),
      :jruby_min_runtimes => 2,
      :jruby_max_runtimes => 6,
    }
    @web_app = TomcatRails::WebApp.new(tomcat_web_app, config)
  end
  
  it "should load custom jars" do 
    class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
    @web_app.add_application_libs(class_loader)
    
    resource = class_loader.find_class('org.ho.yaml.Yaml')
    resource.should_not == nil
  end

  it "should load custom classes" do
    class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
    @web_app.add_application_classes(class_loader)
    
    resource = class_loader.find_class('HelloTomcat')
    resource.should_not == nil    
  end

  it "should start application context without errors" do
    load_tomcat_libs
    lambda { @web_app.context.start }.should_not raise_error
  end

  it "should add a filter from the default web.xml" do
    load_tomcat_libs
    @web_app.load_default_web_xml
    lambda { @web_app.context.start }.should_not raise_error
    @web_app.context.findFilterDefs().size().should == 1
  end
  
  it "should load init params" do
    @web_app.add_init_params
    
    @web_app.context.findParameter('jruby.min.runtimes').should == '2'
    @web_app.context.findParameter('jruby.max.runtimes').should == '6'
  end

  def load_tomcat_libs
    @web_app.config[:libs_dir] = File.join(File.dirname(__FILE__), '..', '..', 'tomcat-libs')
    @web_app.add_context_loader
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calavera-tomcat-rails-0.2.0 spec/tomcat-rails/web_app_spec.rb