trinidad 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.9.0 (2010-04-28)
2
+
3
+ * Tomcat updated to version 6.0.26, added constant to get its version.
4
+ * Jars cleaned, 300kb less to load :)
5
+ * Default configuration file name moved from tomcat.yml to trinidad.yml
6
+ * Fixes bug merging configuration files
7
+ * Configuring application through web.xml to avoid weird lifecycle problems
8
+
1
9
  == 0.8.3 (2010-04-17)
2
10
 
3
11
  * Extensions improvements:
data/README.rdoc CHANGED
@@ -26,7 +26,7 @@ Trinidad allows you to configure some parameters when the server is started from
26
26
  * --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
27
27
  * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
28
28
  * -t, --threadsafe => shortcut to work in threadsafe mode. Setting jruby_min_runtimes and jruby_max_runtimes to 1 in the configuration file the server behaves as the same way.
29
- * -l, --load [EXTENSION_NAME] => loads an extension to use its command line options.
29
+ * -l, --load EXTENSION_NAME => loads an extension to use its command line options.
30
30
 
31
31
  The server can also be configured from a yaml file. If a file is not especified, the server tries to load the file <em>config/tomcat.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
32
32
 
@@ -42,8 +42,10 @@ Other advanced options can be found in the wiki: http://wiki.github.com/calavera
42
42
  From the version 0.8.0 Trinidad allows to extend the server with more Tomcat features, here there is a list with the current available extensions:
43
43
 
44
44
  * Database connection pooling: http://github.com/calavera/trinidad-dbpool
45
+ * Daemon, run Trinidad as a daemon: http://github.com/calavera/trinidad_daemon_extension
46
+ * Hot deploy, do hot deploys monitorizing a temporal file, ala Passenger: http://github.com/calavera/trinidad_hotdeploy_extension
45
47
 
46
- You can find further information on how to write your onw extension in the wiki: http://wiki.github.com/calavera/trinidad/extensions
48
+ You can find further information on how to write your own extension in the wiki: http://wiki.github.com/calavera/trinidad/extensions
47
49
 
48
50
  == Copyright
49
51
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.3
1
+ 0.9.0
data/bin/trinidad CHANGED
@@ -5,5 +5,5 @@ $:.unshift(File.dirname(__FILE__) + '/../trinidad-libs')
5
5
 
6
6
  require "trinidad"
7
7
 
8
- opts = Trinidad::CommandLineParser.parse
9
- Trinidad::Server.new(opts).start
8
+ opts = Trinidad::CommandLineParser.parse(ARGV)
9
+ Trinidad::Server.new(opts).start
data/lib/trinidad.rb CHANGED
@@ -17,4 +17,5 @@ require 'trinidad/rackup_web_app'
17
17
 
18
18
  module Trinidad
19
19
  VERSION = File.read(File.expand_path('../../VERSION', __FILE__))
20
+ TOMCAT_VERSION = '6.0.26'
20
21
  end
@@ -1,22 +1,44 @@
1
1
  module Trinidad
2
2
  require 'optparse'
3
3
  require 'yaml'
4
-
4
+
5
5
  class CommandLineParser
6
+ attr_reader :default_options
7
+
8
+ def self.parse(argv)
9
+ CommandLineParser.new.parse!(argv)
10
+ end
6
11
 
7
- def self.parse
8
- default_options = {
12
+ def initialize
13
+ @default_options = {
9
14
  :port => 3000,
10
15
  :environment => 'development',
11
16
  :context_path => '/',
12
17
  :libs_dir => 'lib',
13
18
  :classes_dir => 'classes',
14
- :config => 'config/tomcat.yml',
15
19
  :ssl_port => 8443,
16
20
  :ajp_port => 8009
17
21
  }
18
-
19
- parser = OptionParser.new do |opts|
22
+ end
23
+
24
+ def parse!(argv)
25
+ begin
26
+ options_parser.parse!(argv)
27
+ rescue OptionParser::InvalidOption => e
28
+ p e, options_parser
29
+ exit(1)
30
+ end
31
+
32
+ if default_options.has_key?(:config)
33
+ config_options = YAML.load_file(default_options[:config])
34
+ default_options.deep_merge!(config_options.symbolize!)
35
+ end
36
+
37
+ default_options
38
+ end
39
+
40
+ def options_parser
41
+ @parser ||= OptionParser.new do |opts|
20
42
  opts.banner = 'Trinidad server default options:'
21
43
  opts.separator ''
22
44
 
@@ -43,7 +65,7 @@ module Trinidad
43
65
  opts.on('--classes', '--classes CLASSES_DIR', 'Directory containing classes used by the application',
44
66
  "default: #{default_options[:classes_dir]}") do |v|
45
67
  default_options[:classes_dir] = v
46
- end
68
+ end
47
69
 
48
70
  opts.on('-s', '--ssl [SSL_PORT]', 'Enable secure socket layout',
49
71
  "default port: #{default_options[:ssl_port]}") do |v|
@@ -58,14 +80,21 @@ module Trinidad
58
80
  end
59
81
 
60
82
  opts.on('-f', '--config [CONFIG_FILE]', 'Configuration file',
61
- "default: #{default_options[:config]}") do |v|
62
- default_options[:config] = v if v
63
- default_options.deep_merge! YAML.load_file(default_options[:config])
83
+ "default: #{default_options[:config]}") do |file|
84
+ default_options[:config] = 'config/trinidad.yml'
85
+
86
+ if file
87
+ default_options[:config] = file
88
+ elsif File.exist?('config/tomcat.yml') && !File.exist?(default_options[:config])
89
+ puts "[WARNING] Default configuration file name has been moved to trinidad.yml, tomcat.yml will not be supported in future versions."
90
+ puts "\tYou still can use tomcat.yml passing it as the file name to this option: -f config/tomcat.yml"
91
+ default_options[:config] = 'config/tomcat.yml'
92
+ end
64
93
  end
65
94
 
66
95
  opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file',
67
96
  'default: config.ru') do |v|
68
- default_options[:rackup] = v || 'config.ru'
97
+ default_options[:rackup] = v || 'config.ru'
69
98
  end
70
99
 
71
100
  opts.on('--public', '--public DIRECTORY', 'Public directory', 'default: public') do |v|
@@ -90,11 +119,7 @@ module Trinidad
90
119
  puts opts
91
120
  exit
92
121
  end
93
-
94
- opts.parse!(ARGV)
95
122
  end
96
-
97
- default_options
98
123
  end
99
124
  end
100
125
  end
@@ -39,7 +39,7 @@ module Trinidad
39
39
 
40
40
  class Extension
41
41
  def initialize(options = {})
42
- @options = options.dup
42
+ @options = options ? options.dup : {}
43
43
  end
44
44
  end
45
45
 
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <web-app>
3
+ <servlet>
4
+ <servlet-name>RackServlet</servlet-name>
5
+ <servlet-class>org.jruby.rack.RackServlet</servlet-class>
6
+ </servlet>
7
+
8
+ <servlet-mapping>
9
+ <servlet-name>RackServlet</servlet-name>
10
+ <url-pattern>/*</url-pattern>
11
+ </servlet-mapping>
12
+
13
+ <listener>
14
+ <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
15
+ </listener>
16
+
17
+ </web-app>
@@ -4,7 +4,7 @@ module Trinidad
4
4
  def add_init_params
5
5
  super
6
6
  add_parameter_unless_exist('rackup', rackup_script)
7
- end
7
+ end
8
8
 
9
9
  def context_listener
10
10
  'org.jruby.rack.RackServletContextListener'
@@ -13,5 +13,7 @@ module Trinidad
13
13
  def rackup_script
14
14
  IO.read(File.join(@app[:web_app_dir], @app[:rackup]))
15
15
  end
16
+
17
+ def provided_web_xml; 'rackup_web.xml'; end
16
18
  end
17
19
  end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <web-app>
3
+ <servlet>
4
+ <servlet-name>RackServlet</servlet-name>
5
+ <servlet-class>org.jruby.rack.RackServlet</servlet-class>
6
+ </servlet>
7
+
8
+ <servlet-mapping>
9
+ <servlet-name>RackServlet</servlet-name>
10
+ <url-pattern>/*</url-pattern>
11
+ </servlet-mapping>
12
+
13
+ <listener>
14
+ <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
15
+ </listener>
16
+
17
+ </web-app>
@@ -10,5 +10,7 @@ module Trinidad
10
10
  def context_listener
11
11
  'org.jruby.rack.rails.RailsServletContextListener'
12
12
  end
13
+
14
+ def provided_web_xml; 'rails_web.xml'; end
13
15
  end
14
16
  end
@@ -31,8 +31,9 @@ module Trinidad
31
31
 
32
32
  def load_tomcat_server
33
33
  @tomcat = Trinidad::Tomcat::Tomcat.new
34
- @tomcat.setPort(@config[:port].to_i)
35
- @tomcat.setBaseDir(Dir.pwd)
34
+ @tomcat.port = @config[:port].to_i
35
+ @tomcat.base_dir = Dir.pwd
36
+ @tomcat.host.app_base = Dir.pwd
36
37
  enable_naming
37
38
 
38
39
  add_ssl_connector if ssl_enabled?
@@ -42,20 +43,20 @@ module Trinidad
42
43
  end
43
44
 
44
45
  def create_web_apps
45
- @config[:web_apps].each do |name, app|
46
- app[:context_path] ||= (name.to_s == 'default' ? '/' : "/#{name.to_s}")
47
- app[:web_app_dir] ||= Dir.pwd
46
+ @config[:web_apps].each do |name, app_config|
47
+ app_config[:context_path] ||= (name.to_s == 'default' ? '/' : "/#{name.to_s}")
48
+ app_config[:web_app_dir] ||= Dir.pwd
48
49
 
49
- tomcat_app = @tomcat.addWebapp(app[:context_path].to_s, app[:web_app_dir])
50
+ app_context = @tomcat.addWebapp(app_config[:context_path], app_config[:web_app_dir])
51
+ remove_defaults(app_context)
50
52
 
51
- web_app = WebApp.create(tomcat_app, @config, app)
53
+ web_app = WebApp.create(app_context, @config, app_config)
52
54
 
53
55
  web_app.load_default_web_xml
54
- web_app.add_rack_filter
56
+ web_app.configure_rack
55
57
  web_app.configure_extensions(@tomcat)
56
58
  web_app.add_context_loader
57
59
  web_app.add_init_params
58
- web_app.add_web_dir_resources
59
60
 
60
61
  web_app.add_rack_context_listener
61
62
  end
@@ -158,5 +159,13 @@ module Trinidad
158
159
  JSystem.setProperty(JContext.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory")
159
160
  end
160
161
  end
162
+
163
+ def remove_defaults(app_context)
164
+ default_servlet = app_context.find_child('default')
165
+ app_context.remove_child(default_servlet) if default_servlet
166
+
167
+ jsp_servlet = app_context.find_child('jsp')
168
+ app_context.remove_child(jsp_servlet) if jsp_servlet
169
+ end
161
170
  end
162
171
  end
@@ -14,18 +14,14 @@ module Trinidad
14
14
  @class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
15
15
  end
16
16
 
17
- def add_rack_filter
18
- unless rack_filter_configured?
19
- filter_def = Trinidad::Tomcat::FilterDef.new
20
- filter_def.setFilterName('RackFilter')
21
- filter_def.setFilterClass('org.jruby.rack.RackFilter')
22
-
23
- filter_map = Trinidad::Tomcat::FilterMap.new
24
- filter_map.setFilterName('RackFilter')
25
- filter_map.addURLPattern('/*')
26
-
27
- @context.addFilterDef(filter_def)
28
- @context.addFilterMap(filter_map)
17
+ def configure_rack(servlet_class = 'org.jruby.rack.RackServlet', servlet_name = 'RackServlet')
18
+ unless rack_configured?
19
+ wrapper = @context.createWrapper()
20
+ wrapper.setServletClass(servlet_class)
21
+ wrapper.setName(servlet_name)
22
+
23
+ @context.addChild(wrapper)
24
+ @context.addServletMapping('/*', servlet_name)
29
25
  end
30
26
  end
31
27
 
@@ -46,11 +42,6 @@ module Trinidad
46
42
  add_parameter_unless_exist('public.root', File.join('/', public_root))
47
43
  end
48
44
 
49
- def add_web_dir_resources
50
- doc_base = File.join(@app[:web_app_dir], public_root)
51
- @context.setDocBase(doc_base) if File.exist?(doc_base)
52
- end
53
-
54
45
  def add_rack_context_listener
55
46
  unless rack_listener_configured?
56
47
  @context.addApplicationListener(context_listener)
@@ -72,19 +63,17 @@ module Trinidad
72
63
 
73
64
  def load_default_web_xml
74
65
  file = File.expand_path(File.join(@app[:web_app_dir], default_web_xml))
66
+ file = File.expand_path("../#{provided_web_xml}", __FILE__) unless File.exist?(file)
75
67
 
76
- if File.exist?(file)
77
- @context.setDefaultWebXml(file)
78
- @context.setDefaultContextXml(file)
68
+ @context.setDefaultWebXml(file)
79
69
 
80
- context_config = Trinidad::Tomcat::ContextConfig.new
81
- context_config.setDefaultWebXml(file)
70
+ context_config = Trinidad::Tomcat::ContextConfig.new
71
+ context_config.setDefaultWebXml(file)
82
72
 
83
- @context.addLifecycleListener(context_config)
84
- end
73
+ @context.addLifecycleListener(context_config)
85
74
  end
86
75
 
87
- def rack_filter_configured?
76
+ def rack_configured?
88
77
  return false if @context.getDefaultWebXml().nil?
89
78
 
90
79
  web_xml = IO.read(@context.getDefaultWebXml()).gsub(/\s+/, '')
@@ -1,99 +1,119 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/fakeapp'
3
+
4
+ include FakeApp
2
5
 
3
6
  describe Trinidad::CommandLineParser do
4
- it "should override classes option" do
5
- ARGV = "--classes my_classes".split
7
+ subject { Trinidad::CommandLineParser }
8
+
9
+ it "overrides classes option" do
10
+ args = "--classes my_classes".split
6
11
 
7
- options = Trinidad::CommandLineParser.parse
12
+ options = subject.parse(args)
8
13
  options[:classes_dir].should == 'my_classes'
9
14
  end
10
15
 
11
- it "should override libs option with lib option" do
12
- ARGV = "--lib my_libs".split
16
+ it "overrides libs option with lib option" do
17
+ args = "--lib my_libs".split
13
18
 
14
- options = Trinidad::CommandLineParser.parse
19
+ options = subject.parse(args)
15
20
  options[:libs_dir].should == 'my_libs'
16
21
  end
17
22
 
18
- it "should override libs option with jar option" do
19
- ARGV = "--jars my_jars".split
23
+ it "overrides libs option with jar option" do
24
+ args = "--jars my_jars".split
20
25
 
21
- options = Trinidad::CommandLineParser.parse
26
+ options = subject.parse(args)
22
27
  options[:libs_dir].should == 'my_jars'
23
28
  end
24
29
 
25
- it "should override the config file when it's especified" do
26
- ARGV = "-f #{File.join(MOCK_WEB_APP_DIR, 'tomcat.yml')}".split
30
+ it "uses config/trinidad.yml as the default configuration file name" do
31
+ FakeFS do
32
+ create_default_config_file
33
+ options = subject.parse(['-f'])
34
+
35
+ options[:config].should == 'config/trinidad.yml'
36
+ options[:port].should == 8080
37
+ end
38
+ end
39
+
40
+ it "overrides the config file when it's especified" do
41
+ FakeFS do
42
+ create_custom_config_file
43
+ args = "-f config/tomcat.yml".split
27
44
 
28
- options = Trinidad::CommandLineParser.parse
29
- options[:environment].should == 'production'
45
+ options = subject.parse(args)
46
+ options[:environment].should == 'production'
47
+ end
30
48
  end
31
49
 
32
- it "should add default ssl port to options" do
33
- ARGV = '--ssl'.split
50
+ it "adds default ssl port to options" do
51
+ args = '--ssl'.split
34
52
 
35
- options = Trinidad::CommandLineParser.parse
53
+ options = subject.parse(args)
36
54
  options[:ssl].should == {:port => 8443}
37
55
  end
38
56
 
39
- it "should add custom ssl port to options" do
40
- ARGV = '--ssl 8843'.split
57
+ it "adds custom ssl port to options" do
58
+ args = '--ssl 8843'.split
41
59
 
42
- options = Trinidad::CommandLineParser.parse
60
+ options = subject.parse(args)
43
61
  options[:ssl].should == {:port => 8843}
44
62
  end
45
63
 
46
- it "should add ajp connection with default port to options" do
47
- ARGV = '--ajp'.split
64
+ it "adds ajp connection with default port to options" do
65
+ args = '--ajp'.split
48
66
 
49
- options = Trinidad::CommandLineParser.parse
67
+ options = subject.parse(args)
50
68
  options[:ajp].should == {:port => 8009}
51
69
  end
52
70
 
53
- it "should add ajp connection with coustom port to options" do
54
- ARGV = '--ajp 8099'.split
71
+ it "adds ajp connection with coustom port to options" do
72
+ args = '--ajp 8099'.split
55
73
 
56
- options = Trinidad::CommandLineParser.parse
74
+ options = subject.parse(args)
57
75
  options[:ajp].should == {:port => 8099}
58
76
  end
59
77
 
60
- it "should merge ajp options from the config file" do
61
- ARGV = "--ajp 8099 -f #{File.join(MOCK_WEB_APP_DIR, 'tomcat.yml')}".split
78
+ it "merges ajp options from the config file" do
79
+ FakeFS do
80
+ create_custom_config_file
81
+ args = "--ajp 8099 -f config/tomcat.yml".split
62
82
 
63
- options = Trinidad::CommandLineParser.parse
64
- options[:ajp][:port].should == 8099
65
- options[:ajp][:secure].should == true
83
+ options = subject.parse(args)
84
+ options[:ajp][:port].should == 8099
85
+ options[:ajp][:secure].should == true
86
+ end
66
87
  end
67
88
 
68
89
  it "uses default rackup file to configure the server" do
69
- ARGV = "--rackup".split
70
- options = Trinidad::CommandLineParser.parse
90
+ args = "--rackup".split
91
+ options = subject.parse(args)
71
92
  options[:rackup].should == 'config.ru'
72
93
  end
73
94
 
74
95
  it "uses a custom rackup file if it's provided" do
75
- ARGV = "--rackup custom_config.ru".split
76
- options = Trinidad::CommandLineParser.parse
96
+ args = "--rackup custom_config.ru".split
97
+ options = subject.parse(args)
77
98
  options[:rackup].should == 'custom_config.ru'
78
99
  end
79
100
 
80
101
  it "uses a custom public directory" do
81
- ARGV = "--public web".split
82
- options = Trinidad::CommandLineParser.parse
102
+ args = "--public web".split
103
+ options = subject.parse(args)
83
104
  options[:public].should == 'web'
84
105
  end
85
106
 
86
107
  it "works on threadsafe mode using the shortcut" do
87
- ARGV = '--threadsafe'.split
88
- options = Trinidad::CommandLineParser.parse
108
+ args = '--threadsafe'.split
109
+ options = subject.parse(args)
89
110
  options[:jruby_min_runtimes].should == 1
90
111
  options[:jruby_max_runtimes].should == 1
91
112
  end
92
113
 
93
114
  it "loads a given extension to add its options to the parser" do
94
- ARGV = "--load foo --foo".split
95
- options = Trinidad::CommandLineParser.parse
115
+ args = "--load foo --foo".split
116
+ options = subject.parse(args)
96
117
  options.has_key?(:bar).should be_true
97
-
98
118
  end
99
119
  end
@@ -0,0 +1,24 @@
1
+ require 'fakefs/safe'
2
+ module FakeApp
3
+ def create_default_config_file
4
+ @default ||= config_file 'config/trinidad.yml', <<-EOF
5
+ ---
6
+ port: 8080
7
+ EOF
8
+ end
9
+
10
+ def create_custom_config_file
11
+ @custom ||= config_file 'config/tomcat.yml', <<-EOF
12
+ ---
13
+ environment: production
14
+ ajp:
15
+ port: 8099
16
+ secure: true
17
+ EOF
18
+ end
19
+
20
+ private
21
+ def config_file(path, options)
22
+ File.open(path, 'w') {|io| io.write(options) }
23
+ end
24
+ end
@@ -19,25 +19,25 @@ describe Trinidad::Server do
19
19
 
20
20
  it "should have ssl disabled when config param is nil" do
21
21
  server = Trinidad::Server.new
22
- server.ssl_enabled?.should == false
22
+ server.ssl_enabled?.should be_false
23
23
  end
24
24
 
25
25
  it "should have ajp disabled when config param is nil" do
26
26
  server = Trinidad::Server.new
27
- server.ajp_enabled?.should == false
27
+ server.ajp_enabled?.should be_false
28
28
  end
29
29
 
30
30
  it "should have ssl enabled when config param is a number" do
31
31
  server = Trinidad::Server.new({:ssl => {:port => 8443},
32
32
  :web_app_dir => MOCK_WEB_APP_DIR})
33
33
 
34
- server.ssl_enabled?.should == true
34
+ server.ssl_enabled?.should be_true
35
35
  end
36
36
 
37
37
  it "should have ajp enabled when config param is a number" do
38
38
  server = Trinidad::Server.new({:ajp => {:port => 8009}})
39
39
 
40
- server.ajp_enabled?.should == true
40
+ server.ajp_enabled?.should be_true
41
41
  end
42
42
 
43
43
  it "should have a connector with https scheme" do
@@ -96,6 +96,14 @@ describe Trinidad::Server do
96
96
  context.findParameter('rackup').gsub(/\s+/, ' ').should == "require 'rubygems' require 'sinatra'"
97
97
  end
98
98
 
99
+ it "removes default servlets from the application" do
100
+ server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
101
+ app = server.tomcat.host.find_child('/')
102
+
103
+ app.find_child('default').should be_nil
104
+ app.find_child('jsp').should be_nil
105
+ end
106
+
99
107
  def default_context_should_be_loaded(children)
100
108
  children.should have(1).web_apps
101
109
  children[0].getDocBase().should == MOCK_WEB_APP_DIR
@@ -3,7 +3,9 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Trinidad::WebApp do
4
4
  before do
5
5
  @tomcat = Trinidad::Tomcat::Tomcat.new
6
+ @tomcat.host.app_base = Dir.pwd
6
7
  @tomcat_web_app = @tomcat.addWebapp('/', File.dirname(__FILE__) + '/../../')
8
+
7
9
  @app = {
8
10
  :web_app_dir => MOCK_WEB_APP_DIR,
9
11
  :context_path => '/'
@@ -22,13 +24,15 @@ describe Trinidad::WebApp do
22
24
  end
23
25
 
24
26
  it "creates a RailsWebApp if rackup option is not present" do
25
- Trinidad::WebApp.create(@tomcat_web_app, @config, @app).is_a?(Trinidad::RailsWebApp).should be_true
27
+ app = Trinidad::WebApp.create(@tomcat_web_app, @config, @app)
28
+ app.should be_an_instance_of(Trinidad::RailsWebApp)
26
29
  end
27
30
 
28
31
  it "creates a RackupWebApp if rackup option is present" do
29
32
  rackup_app = {:rackup => 'config.ru'}
30
33
  @config.deep_merge({:web_apps => {:default => rackup_app}})
31
- Trinidad::WebApp.create(@tomcat_web_app, @config, rackup_app).is_a?(Trinidad::RackupWebApp).should be_true
34
+ app = Trinidad::WebApp.create(@tomcat_web_app, @config, rackup_app)
35
+ app.should be_an_instance_of(Trinidad::RackupWebApp)
32
36
  end
33
37
 
34
38
  it "should load custom jars" do
@@ -36,7 +40,7 @@ describe Trinidad::WebApp do
36
40
  @web_app.add_application_libs(class_loader)
37
41
 
38
42
  resource = class_loader.find_class('org.ho.yaml.Yaml')
39
- resource.should_not == nil
43
+ resource.should_not be_nil
40
44
  end
41
45
 
42
46
  it "should load custom classes" do
@@ -44,7 +48,7 @@ describe Trinidad::WebApp do
44
48
  @web_app.add_application_classes(class_loader)
45
49
 
46
50
  resource = class_loader.find_class('HelloTomcat')
47
- resource.should_not == nil
51
+ resource.should_not be_nil
48
52
  end
49
53
 
50
54
  it "should start application context without errors" do
@@ -80,32 +84,49 @@ describe Trinidad::WebApp do
80
84
  web_app.context.findParameter('jruby.max.runtimes').should == '8'
81
85
  end
82
86
 
83
- it "should configure rack filter" do
84
- @web_app.add_rack_filter
85
- @web_app.context.findFilterDefs().should have(1).filters
87
+ it "configures rack handler" do
88
+ @web_app.configure_rack
89
+ @web_app.context.findChild('RackServlet').should_not be_nil
86
90
  end
87
91
 
88
- it "should configure rack listener" do
92
+ it "configures rack listener" do
89
93
  @web_app.add_rack_context_listener
90
94
  @web_app.context.findApplicationListeners().should have(1).listeners
91
95
  end
92
96
 
93
- it "should have rack filter already configured" do
97
+ it "has rack handler already configured when web.xml includes it" do
94
98
  @web_app.load_default_web_xml
95
- @web_app.rack_filter_configured?().should == true
99
+ @web_app.rack_configured?().should be_true
96
100
 
97
- @web_app.add_rack_filter
98
- @web_app.context.findFilterDefs().should have(0).filters
101
+ @web_app.configure_rack
102
+ @web_app.context.findChild('RackServlet').should be_nil
99
103
  end
100
104
 
101
- it "should have rack listener already configured" do
105
+ it "has rack listener already configured when web.xml includes it" do
102
106
  @web_app.load_default_web_xml
103
- @web_app.rack_listener_configured?().should == true
107
+ @web_app.rack_listener_configured?().should be_true
104
108
 
105
109
  @web_app.add_rack_context_listener
106
110
  @web_app.context.findApplicationListeners().should have(0).listeners
107
111
  end
108
112
 
113
+ it "loads the provided web.xml for rails applications" do
114
+ @config[:default_web_xml] = 'config/foo.xml'
115
+ app = Trinidad::WebApp.create(@tomcat_web_app, @config, @app)
116
+
117
+ app.load_default_web_xml
118
+ app.context.default_web_xml.should =~ /rails_web.xml$/
119
+ end
120
+
121
+ it "loads the provided web.xml for rack applications" do
122
+ @config[:default_web_xml] = 'config/foo.xml'
123
+ @app[:rackup] = 'config.ru'
124
+
125
+ app = Trinidad::WebApp.create(@tomcat_web_app, @config, @app)
126
+ app.load_default_web_xml
127
+ app.context.default_web_xml.should =~ /rackup_web.xml$/
128
+ end
129
+
109
130
  def start_context_with_web_xml
110
131
  @web_app.load_default_web_xml
111
132
  start_context
@@ -120,5 +141,4 @@ describe Trinidad::WebApp do
120
141
  @web_app.config[:libs_dir] = File.join(File.dirname(__FILE__), '..', '..', 'tomcat-libs')
121
142
  @web_app.add_context_loader
122
143
  end
123
-
124
144
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 8
8
- - 3
9
- version: 0.8.3
7
+ - 9
8
+ - 0
9
+ version: 0.9.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Calavera
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-17 00:00:00 +02:00
17
+ date: 2010-04-28 00:00:00 +02:00
18
18
  default_executable: trinidad
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -51,9 +51,9 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  segments:
53
53
  - 0
54
- - 1
55
- - 1
56
- version: 0.1.1
54
+ - 2
55
+ - 0
56
+ version: 0.2.0
57
57
  type: :runtime
58
58
  version_requirements: *id003
59
59
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,18 @@ dependencies:
80
80
  version: "0"
81
81
  type: :development
82
82
  version_requirements: *id005
83
+ - !ruby/object:Gem::Dependency
84
+ name: fakefs
85
+ prerelease: false
86
+ requirement: &id006 !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :development
94
+ version_requirements: *id006
83
95
  description:
84
96
  email: calavera@apache.org
85
97
  executables:
@@ -99,7 +111,9 @@ files:
99
111
  - lib/trinidad/command_line_parser.rb
100
112
  - lib/trinidad/core_ext.rb
101
113
  - lib/trinidad/extensions.rb
114
+ - lib/trinidad/rackup_web.xml
102
115
  - lib/trinidad/rackup_web_app.rb
116
+ - lib/trinidad/rails_web.xml
103
117
  - lib/trinidad/rails_web_app.rb
104
118
  - lib/trinidad/server.rb
105
119
  - lib/trinidad/web_app.rb
@@ -139,5 +153,6 @@ test_files:
139
153
  - spec/spec_helper.rb
140
154
  - spec/trinidad/command_line_parser_spec.rb
141
155
  - spec/trinidad/extensions_spec.rb
156
+ - spec/trinidad/fakeapp.rb
142
157
  - spec/trinidad/server_spec.rb
143
158
  - spec/trinidad/web_app_spec.rb