trinidad 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/README.rdoc +2 -1
- data/lib/trinidad.rb +1 -1
- data/lib/trinidad/command_line_parser.rb +4 -0
- data/lib/trinidad/server.rb +1 -0
- metadata +23 -56
- data/VERSION +0 -1
- data/spec/fixtures/trinidad_foo_extension.rb +0 -23
- data/spec/fixtures/trinidad_override_tomcat_extension.rb +0 -11
- data/spec/spec_helper.rb +0 -21
- data/spec/trinidad/command_line_parser_spec.rb +0 -124
- data/spec/trinidad/extensions_spec.rb +0 -58
- data/spec/trinidad/fakeapp.rb +0 -87
- data/spec/trinidad/server_spec.rb +0 -178
- data/spec/trinidad/web_app_lifecycle_listener_spec.rb +0 -179
- data/spec/trinidad/web_app_spec.rb +0 -175
data/History.txt
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
== 0.9.7 (2010-09-27)
|
|
2
|
+
|
|
3
|
+
* add option --adress to set the Trinidad's host
|
|
4
|
+
|
|
5
|
+
== Trinidad_jars 0.3.2 (2010-09-26)
|
|
6
|
+
|
|
7
|
+
* fix TRINIDAD-21: trinidad_jars 0.3.1 breaks logging extension
|
|
8
|
+
|
|
1
9
|
== 0.9.6 (2010-09-12)
|
|
2
10
|
|
|
3
11
|
* add option to specify the application directory path from the command line
|
data/README.rdoc
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Mail list: http://groups.google.com/group/rails-trinidad
|
|
6
|
+
Bug tracker: http://github.com/calavera/trinidad/issues
|
|
6
7
|
|
|
7
8
|
== INSTALL:
|
|
8
9
|
|
data/lib/trinidad.rb
CHANGED
|
@@ -111,6 +111,10 @@ module Trinidad
|
|
|
111
111
|
default_options[:jruby_max_runtimes] = 1
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
+
opts.on('--address', '--address ADDRESS', 'Trinidad host address', 'default: localhost') do |v|
|
|
115
|
+
default_options[:address] = v
|
|
116
|
+
end
|
|
117
|
+
|
|
114
118
|
opts.on('-v', '--version', 'display the current version') do
|
|
115
119
|
puts "trinidad #{Trinidad::VERSION} (tomcat #{Trinidad::TOMCAT_VERSION})"
|
|
116
120
|
exit
|
data/lib/trinidad/server.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trinidad
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 53
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
9
|
+
- 7
|
|
10
|
+
version: 0.9.7
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- David Calavera
|
|
@@ -15,22 +15,23 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-09-
|
|
18
|
+
date: 2010-09-26 00:00:00 +02:00
|
|
19
19
|
default_executable: trinidad
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
22
|
-
name:
|
|
22
|
+
name: trinidad_jars
|
|
23
23
|
prerelease: false
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
25
|
none: false
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
hash:
|
|
29
|
+
hash: 19
|
|
30
30
|
segments:
|
|
31
|
-
- 1
|
|
32
31
|
- 0
|
|
33
|
-
|
|
32
|
+
- 3
|
|
33
|
+
- 0
|
|
34
|
+
version: 0.3.0
|
|
34
35
|
type: :runtime
|
|
35
36
|
version_requirements: *id001
|
|
36
37
|
- !ruby/object:Gem::Dependency
|
|
@@ -49,26 +50,10 @@ dependencies:
|
|
|
49
50
|
version: 1.0.2
|
|
50
51
|
type: :runtime
|
|
51
52
|
version_requirements: *id002
|
|
52
|
-
- !ruby/object:Gem::Dependency
|
|
53
|
-
name: trinidad_jars
|
|
54
|
-
prerelease: false
|
|
55
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
|
56
|
-
none: false
|
|
57
|
-
requirements:
|
|
58
|
-
- - ">="
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
hash: 19
|
|
61
|
-
segments:
|
|
62
|
-
- 0
|
|
63
|
-
- 3
|
|
64
|
-
- 0
|
|
65
|
-
version: 0.3.0
|
|
66
|
-
type: :runtime
|
|
67
|
-
version_requirements: *id003
|
|
68
53
|
- !ruby/object:Gem::Dependency
|
|
69
54
|
name: rspec
|
|
70
55
|
prerelease: false
|
|
71
|
-
requirement: &
|
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
72
57
|
none: false
|
|
73
58
|
requirements:
|
|
74
59
|
- - ">="
|
|
@@ -78,11 +63,11 @@ dependencies:
|
|
|
78
63
|
- 0
|
|
79
64
|
version: "0"
|
|
80
65
|
type: :development
|
|
81
|
-
version_requirements: *
|
|
66
|
+
version_requirements: *id003
|
|
82
67
|
- !ruby/object:Gem::Dependency
|
|
83
68
|
name: mocha
|
|
84
69
|
prerelease: false
|
|
85
|
-
requirement: &
|
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
86
71
|
none: false
|
|
87
72
|
requirements:
|
|
88
73
|
- - ">="
|
|
@@ -92,11 +77,11 @@ dependencies:
|
|
|
92
77
|
- 0
|
|
93
78
|
version: "0"
|
|
94
79
|
type: :development
|
|
95
|
-
version_requirements: *
|
|
80
|
+
version_requirements: *id004
|
|
96
81
|
- !ruby/object:Gem::Dependency
|
|
97
82
|
name: fakefs
|
|
98
83
|
prerelease: false
|
|
99
|
-
requirement: &
|
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
100
85
|
none: false
|
|
101
86
|
requirements:
|
|
102
87
|
- - ">="
|
|
@@ -106,23 +91,22 @@ dependencies:
|
|
|
106
91
|
- 0
|
|
107
92
|
version: "0"
|
|
108
93
|
type: :development
|
|
109
|
-
version_requirements: *
|
|
110
|
-
description:
|
|
94
|
+
version_requirements: *id005
|
|
95
|
+
description: Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container
|
|
111
96
|
email: calavera@apache.org
|
|
112
97
|
executables:
|
|
113
98
|
- trinidad
|
|
114
99
|
extensions: []
|
|
115
100
|
|
|
116
101
|
extra_rdoc_files:
|
|
117
|
-
- LICENSE
|
|
118
102
|
- README.rdoc
|
|
103
|
+
- LICENSE
|
|
119
104
|
files:
|
|
105
|
+
- bin/trinidad
|
|
106
|
+
- lib/trinidad.rb
|
|
120
107
|
- History.txt
|
|
121
108
|
- LICENSE
|
|
122
109
|
- README.rdoc
|
|
123
|
-
- VERSION
|
|
124
|
-
- bin/trinidad
|
|
125
|
-
- lib/trinidad.rb
|
|
126
110
|
- lib/trinidad/command_line_parser.rb
|
|
127
111
|
- lib/trinidad/core_ext.rb
|
|
128
112
|
- lib/trinidad/extensions.rb
|
|
@@ -131,17 +115,8 @@ files:
|
|
|
131
115
|
- lib/trinidad/server.rb
|
|
132
116
|
- lib/trinidad/web_app.rb
|
|
133
117
|
- lib/trinidad/web_app_lifecycle_listener.rb
|
|
134
|
-
- spec/fixtures/trinidad_foo_extension.rb
|
|
135
|
-
- spec/fixtures/trinidad_override_tomcat_extension.rb
|
|
136
|
-
- spec/spec_helper.rb
|
|
137
|
-
- spec/trinidad/command_line_parser_spec.rb
|
|
138
|
-
- spec/trinidad/extensions_spec.rb
|
|
139
|
-
- spec/trinidad/fakeapp.rb
|
|
140
|
-
- spec/trinidad/server_spec.rb
|
|
141
|
-
- spec/trinidad/web_app_lifecycle_listener_spec.rb
|
|
142
|
-
- spec/trinidad/web_app_spec.rb
|
|
143
118
|
has_rdoc: true
|
|
144
|
-
homepage: http://
|
|
119
|
+
homepage: http://github.com/calavera/trinidad
|
|
145
120
|
licenses: []
|
|
146
121
|
|
|
147
122
|
post_install_message:
|
|
@@ -172,15 +147,7 @@ requirements: []
|
|
|
172
147
|
rubyforge_project: trinidad
|
|
173
148
|
rubygems_version: 1.3.7
|
|
174
149
|
signing_key:
|
|
175
|
-
specification_version:
|
|
150
|
+
specification_version: 2
|
|
176
151
|
summary: Simple library to run rails applications into an embedded Tomcat
|
|
177
|
-
test_files:
|
|
178
|
-
|
|
179
|
-
- spec/fixtures/trinidad_override_tomcat_extension.rb
|
|
180
|
-
- spec/spec_helper.rb
|
|
181
|
-
- spec/trinidad/command_line_parser_spec.rb
|
|
182
|
-
- spec/trinidad/extensions_spec.rb
|
|
183
|
-
- spec/trinidad/fakeapp.rb
|
|
184
|
-
- spec/trinidad/server_spec.rb
|
|
185
|
-
- spec/trinidad/web_app_lifecycle_listener_spec.rb
|
|
186
|
-
- spec/trinidad/web_app_spec.rb
|
|
152
|
+
test_files: []
|
|
153
|
+
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.9.6
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Trinidad
|
|
2
|
-
module Extensions
|
|
3
|
-
class FooWebAppExtension < WebAppExtension
|
|
4
|
-
def configure(tomcat, app_context)
|
|
5
|
-
app_context.doc_base = 'foo_app_extension' if app_context
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class FooServerExtension < ServerExtension
|
|
10
|
-
def configure(tomcat)
|
|
11
|
-
@options
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class FooOptionsExtension < OptionsExtension
|
|
16
|
-
def configure(parser, default_options)
|
|
17
|
-
parser.on('--foo') do
|
|
18
|
-
default_options[:bar] = true
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'spec'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
require 'rubygems'
|
|
5
|
-
gem 'rspec'
|
|
6
|
-
require 'spec'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
10
|
-
$:.unshift(File.dirname(__FILE__) + '/../trinidad-libs')
|
|
11
|
-
$:.unshift(File.dirname(__FILE__) + '/fixtures')
|
|
12
|
-
|
|
13
|
-
require 'java'
|
|
14
|
-
require 'trinidad'
|
|
15
|
-
require 'mocha'
|
|
16
|
-
|
|
17
|
-
Spec::Runner.configure do |config|
|
|
18
|
-
config.mock_with :mocha
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
MOCK_WEB_APP_DIR = File.join(File.dirname(__FILE__), 'web_app_mock')
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
require File.dirname(__FILE__) + '/fakeapp'
|
|
3
|
-
|
|
4
|
-
include FakeApp
|
|
5
|
-
|
|
6
|
-
describe Trinidad::CommandLineParser do
|
|
7
|
-
subject { Trinidad::CommandLineParser }
|
|
8
|
-
|
|
9
|
-
it "overrides classes option" do
|
|
10
|
-
args = "--classes my_classes".split
|
|
11
|
-
|
|
12
|
-
options = subject.parse(args)
|
|
13
|
-
options[:classes_dir].should == 'my_classes'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "overrides libs option with lib option" do
|
|
17
|
-
args = "--lib my_libs".split
|
|
18
|
-
|
|
19
|
-
options = subject.parse(args)
|
|
20
|
-
options[:libs_dir].should == 'my_libs'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "overrides libs option with jar option" do
|
|
24
|
-
args = "--jars my_jars".split
|
|
25
|
-
|
|
26
|
-
options = subject.parse(args)
|
|
27
|
-
options[:libs_dir].should == 'my_jars'
|
|
28
|
-
end
|
|
29
|
-
|
|
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
|
|
44
|
-
|
|
45
|
-
options = subject.parse(args)
|
|
46
|
-
options[:environment].should == 'production'
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "adds default ssl port to options" do
|
|
51
|
-
args = '--ssl'.split
|
|
52
|
-
|
|
53
|
-
options = subject.parse(args)
|
|
54
|
-
options[:ssl].should == {:port => 8443}
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "adds custom ssl port to options" do
|
|
58
|
-
args = '--ssl 8843'.split
|
|
59
|
-
|
|
60
|
-
options = subject.parse(args)
|
|
61
|
-
options[:ssl].should == {:port => 8843}
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "adds ajp connection with default port to options" do
|
|
65
|
-
args = '--ajp'.split
|
|
66
|
-
|
|
67
|
-
options = subject.parse(args)
|
|
68
|
-
options[:ajp].should == {:port => 8009}
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "adds ajp connection with coustom port to options" do
|
|
72
|
-
args = '--ajp 8099'.split
|
|
73
|
-
|
|
74
|
-
options = subject.parse(args)
|
|
75
|
-
options[:ajp].should == {:port => 8099}
|
|
76
|
-
end
|
|
77
|
-
|
|
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
|
|
82
|
-
|
|
83
|
-
options = subject.parse(args)
|
|
84
|
-
options[:ajp][:port].should == 8099
|
|
85
|
-
options[:ajp][:secure].should == true
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "uses default rackup file to configure the server" do
|
|
90
|
-
args = "--rackup".split
|
|
91
|
-
options = subject.parse(args)
|
|
92
|
-
options[:rackup].should == 'config.ru'
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "uses a custom rackup file if it's provided" do
|
|
96
|
-
args = "--rackup custom_config.ru".split
|
|
97
|
-
options = subject.parse(args)
|
|
98
|
-
options[:rackup].should == 'custom_config.ru'
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it "uses a custom public directory" do
|
|
102
|
-
args = "--public web".split
|
|
103
|
-
options = subject.parse(args)
|
|
104
|
-
options[:public].should == 'web'
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "works on threadsafe mode using the shortcut" do
|
|
108
|
-
args = '--threadsafe'.split
|
|
109
|
-
options = subject.parse(args)
|
|
110
|
-
options[:jruby_min_runtimes].should == 1
|
|
111
|
-
options[:jruby_max_runtimes].should == 1
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "loads a given extension to add its options to the parser" do
|
|
115
|
-
args = "--load foo --foo".split
|
|
116
|
-
options = subject.parse(args)
|
|
117
|
-
options.has_key?(:bar).should be_true
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "adds the application directory path with the option --dir" do
|
|
121
|
-
args = "--dir #{MOCK_WEB_APP_DIR}".split
|
|
122
|
-
subject.parse(args)[:web_app_dir].should == MOCK_WEB_APP_DIR
|
|
123
|
-
end
|
|
124
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
require 'optparse'
|
|
3
|
-
|
|
4
|
-
describe Trinidad::Extensions do
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@extensions = {:foo => {:bar => :bazz}}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "configures the server with new stuff" do
|
|
11
|
-
lambda {Trinidad::Extensions.configure_server_extensions(@extensions, nil)}.should_not raise_error
|
|
12
|
-
lambda {Trinidad::Extensions.const_get(:FooServerExtension)}.should_not raise_error
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "configures the webapp with new stuff" do
|
|
16
|
-
lambda {Trinidad::Extensions.configure_webapp_extensions(@extensions, nil, nil)}.should_not raise_error
|
|
17
|
-
lambda {Trinidad::Extensions.const_get(:FooWebAppExtension)}.should_not raise_error
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "adds options to the command line parser" do
|
|
21
|
-
options = {}
|
|
22
|
-
parser = OptionParser.new
|
|
23
|
-
lambda {
|
|
24
|
-
Trinidad::Extensions.configure_options_extensions({:foo => {}}, parser, options)
|
|
25
|
-
}.should_not raise_error
|
|
26
|
-
|
|
27
|
-
lambda {
|
|
28
|
-
parser.parse! ['--foo']
|
|
29
|
-
options.has_key?(:bar).should be_true
|
|
30
|
-
}.should_not raise_error
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "allows to override the tomcat's instance" do
|
|
34
|
-
extensions = {:override_tomcat => {}}
|
|
35
|
-
tomcat = Trinidad::Tomcat::Tomcat.new
|
|
36
|
-
|
|
37
|
-
extended = Trinidad::Extensions.configure_server_extensions(extensions, tomcat)
|
|
38
|
-
extended.should_not equal(tomcat)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "ignores extensions that don't exist for that scope" do
|
|
42
|
-
extensions = {:override_tomcat => {}}
|
|
43
|
-
tomcat = Trinidad::Tomcat::Tomcat.new
|
|
44
|
-
|
|
45
|
-
lambda {
|
|
46
|
-
Trinidad::Extensions.configure_webapp_extensions(extensions, tomcat, nil)
|
|
47
|
-
}.should_not raise_error
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "raises an error when the extension doesn't exist" do
|
|
51
|
-
extensions = {:foo_bar => {}}
|
|
52
|
-
tomcat = Trinidad::Tomcat::Tomcat.new
|
|
53
|
-
|
|
54
|
-
lambda {
|
|
55
|
-
Trinidad::Extensions.configure_webapp_extensions(extensions, tomcat, nil)
|
|
56
|
-
}.should raise_error
|
|
57
|
-
end
|
|
58
|
-
end
|
data/spec/trinidad/fakeapp.rb
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
def create_rails_web_xml
|
|
21
|
-
@rails_web_xml ||= config_file 'config/web.xml', <<-EOF
|
|
22
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
23
|
-
<web-app>
|
|
24
|
-
<servlet>
|
|
25
|
-
<servlet-name>RackServlet</servlet-name>
|
|
26
|
-
<servlet-class>org.jruby.rack.RackServlet</servlet-class>
|
|
27
|
-
</servlet>
|
|
28
|
-
|
|
29
|
-
<servlet-mapping>
|
|
30
|
-
<servlet-name>RackServlet</servlet-name>
|
|
31
|
-
<url-pattern>/*</url-pattern>
|
|
32
|
-
</servlet-mapping>
|
|
33
|
-
|
|
34
|
-
<listener>
|
|
35
|
-
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
|
|
36
|
-
</listener>
|
|
37
|
-
|
|
38
|
-
</web-app>
|
|
39
|
-
EOF
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def create_rackup_web_xml
|
|
43
|
-
@rackup_web_xml ||= config_file 'config/web.xml', <<-EOF
|
|
44
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
45
|
-
<web-app>
|
|
46
|
-
<context-param>
|
|
47
|
-
<param-name>jruby.min.runtimes</param-name>
|
|
48
|
-
<param-value>1<param-value>
|
|
49
|
-
</context-param>
|
|
50
|
-
|
|
51
|
-
<context-param>
|
|
52
|
-
<param-name>jruby.max.runtimes</param-name>
|
|
53
|
-
<param-value>1</param-value>
|
|
54
|
-
</context-param>
|
|
55
|
-
|
|
56
|
-
<servlet>
|
|
57
|
-
<servlet-name>RackServlet</servlet-name>
|
|
58
|
-
<servlet-class>org.jruby.rack.RackServlet</servlet-class>
|
|
59
|
-
</servlet>
|
|
60
|
-
|
|
61
|
-
<servlet-mapping>
|
|
62
|
-
<servlet-name>RackServlet</servlet-name>
|
|
63
|
-
<url-pattern>/*</url-pattern>
|
|
64
|
-
</servlet-mapping>
|
|
65
|
-
|
|
66
|
-
<listener>
|
|
67
|
-
<listener-class>org.jruby.rack.RackServletContextListener</listener-class>
|
|
68
|
-
</listener>
|
|
69
|
-
|
|
70
|
-
</web-app>
|
|
71
|
-
EOF
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def create_rackup_file(path = 'config')
|
|
75
|
-
@rackup ||= config_file File.join(path, 'config.ru'), <<-EOF
|
|
76
|
-
require 'rubygems'
|
|
77
|
-
require 'sinatra'
|
|
78
|
-
|
|
79
|
-
run App
|
|
80
|
-
EOF
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
private
|
|
84
|
-
def config_file(path, content)
|
|
85
|
-
File.open(path, 'w') {|io| io.write(content) }
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
JSystem = java.lang.System
|
|
4
|
-
JContext = javax.naming.Context
|
|
5
|
-
|
|
6
|
-
describe Trinidad::Server do
|
|
7
|
-
|
|
8
|
-
it "always uses symbols as configuration keys" do
|
|
9
|
-
server = Trinidad::Server.new({'port' => 4000})
|
|
10
|
-
server.config[:port].should == 4000
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "enables catalina naming" do
|
|
14
|
-
Trinidad::Server.new
|
|
15
|
-
JSystem.get_property(JContext.URL_PKG_PREFIXES).should include("org.apache.naming")
|
|
16
|
-
JSystem.get_property(JContext.INITIAL_CONTEXT_FACTORY).should == "org.apache.naming.java.javaURLContextFactory"
|
|
17
|
-
JSystem.get_property("catalina.useNaming").should == "true"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "disables ssl when config param is nil" do
|
|
21
|
-
server = Trinidad::Server.new
|
|
22
|
-
server.ssl_enabled?.should be_false
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "disables ajp when config param is nil" do
|
|
26
|
-
server = Trinidad::Server.new
|
|
27
|
-
server.ajp_enabled?.should be_false
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "enables ssl when config param is a number" do
|
|
31
|
-
begin
|
|
32
|
-
server = Trinidad::Server.new({:ssl => {:port => 8443},
|
|
33
|
-
:web_app_dir => MOCK_WEB_APP_DIR})
|
|
34
|
-
|
|
35
|
-
server.ssl_enabled?.should be_true
|
|
36
|
-
File.exist?('ssl').should be_true
|
|
37
|
-
ensure
|
|
38
|
-
require 'fileutils'
|
|
39
|
-
FileUtils.rm_rf(File.expand_path('../../ssl', File.dirname(__FILE__)))
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "enables ajp when config param is a number" do
|
|
44
|
-
server = Trinidad::Server.new({:ajp => {:port => 8009}})
|
|
45
|
-
|
|
46
|
-
server.ajp_enabled?.should be_true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "includes a connector with https scheme when ssl is enabled" do
|
|
50
|
-
server = Trinidad::Server.new({:ssl => {:port => 8443},
|
|
51
|
-
:web_app_dir => MOCK_WEB_APP_DIR})
|
|
52
|
-
|
|
53
|
-
connectors = server.tomcat.service.find_connectors
|
|
54
|
-
connectors.should have(1).connector
|
|
55
|
-
connectors[0].scheme.should == 'https'
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "includes a connector with protocol AJP when ajp is enabled" do
|
|
59
|
-
server = Trinidad::Server.new({:ajp => {:port => 8009}})
|
|
60
|
-
|
|
61
|
-
connectors = server.tomcat.service.find_connectors
|
|
62
|
-
connectors.should have(1).connector
|
|
63
|
-
connectors[0].protocol.should == 'AJP/1.3'
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "loads one application for each option present into :web_apps" do
|
|
67
|
-
server = Trinidad::Server.new({
|
|
68
|
-
:web_apps => {
|
|
69
|
-
:mock1 => {
|
|
70
|
-
:context_path => '/mock1',
|
|
71
|
-
:web_app_dir => MOCK_WEB_APP_DIR
|
|
72
|
-
},
|
|
73
|
-
:mock2 => {
|
|
74
|
-
:web_app_dir => MOCK_WEB_APP_DIR
|
|
75
|
-
},
|
|
76
|
-
:default => {
|
|
77
|
-
:web_app_dir => MOCK_WEB_APP_DIR
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
context_loaded = server.tomcat.host.find_children
|
|
83
|
-
context_loaded.should have(3).web_apps
|
|
84
|
-
|
|
85
|
-
expected = ['/mock1', '/mock2', '/']
|
|
86
|
-
context_loaded.each do |context|
|
|
87
|
-
expected.delete(context.path).should == context.path
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "loads the default application from the current directory if :web_apps is not present" do
|
|
92
|
-
server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
|
|
93
|
-
|
|
94
|
-
default_context_should_be_loaded(server.tomcat.host.find_children)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "removes default servlets from the application" do
|
|
98
|
-
server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
|
|
99
|
-
app = server.tomcat.host.find_child('/')
|
|
100
|
-
|
|
101
|
-
app.find_child('default').should be_nil
|
|
102
|
-
app.find_child('jsp').should be_nil
|
|
103
|
-
|
|
104
|
-
app.find_servlet_mapping('*.jsp').should be_nil
|
|
105
|
-
app.find_servlet_mapping('*.jspx').should be_nil
|
|
106
|
-
|
|
107
|
-
app.process_tlds.should be_false
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "uses the default HttpConnector when http is not configured" do
|
|
111
|
-
server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
|
|
112
|
-
server.http_configured?.should be_false
|
|
113
|
-
|
|
114
|
-
server.tomcat.connector.protocol_handler_class_name.should == 'org.apache.coyote.http11.Http11Protocol'
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "uses the NioConnector when the http configuration sets nio to true" do
|
|
118
|
-
server = Trinidad::Server.new({
|
|
119
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
120
|
-
:http => {:nio => true}
|
|
121
|
-
})
|
|
122
|
-
server.http_configured?.should be_true
|
|
123
|
-
|
|
124
|
-
server.tomcat.connector.protocol_handler_class_name.should == 'org.apache.coyote.http11.Http11NioProtocol'
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "configures NioConnector with http option values" do
|
|
128
|
-
server = Trinidad::Server.new({
|
|
129
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
130
|
-
:http => {
|
|
131
|
-
:nio => true,
|
|
132
|
-
'maxKeepAliveRequests' => 4,
|
|
133
|
-
'socket.bufferPool' => 1000
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
connector = server.tomcat.connector
|
|
137
|
-
connector.get_property('maxKeepAliveRequests').should == 4
|
|
138
|
-
connector.get_property('socket.bufferPool').should == '1000'
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "adds the WebAppLifecycleListener to each webapp" do
|
|
142
|
-
server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
|
|
143
|
-
app_context = server.tomcat.host.find_child('/')
|
|
144
|
-
|
|
145
|
-
app_context.find_lifecycle_listeners.map {|l| l.class.name }.should include('Trinidad::WebAppLifecycleListener')
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "loads application extensions from the root of the configuration" do
|
|
149
|
-
server = Trinidad::Server.new({
|
|
150
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
151
|
-
:extensions => { :foo => {} }
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
app_context = server.tomcat.host.find_child('/')
|
|
155
|
-
app_context.doc_base.should == 'foo_app_extension'
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "doesn't create a default keystore when the option SSLCertificateFile is present in the ssl configuration options" do
|
|
159
|
-
require 'fileutils'
|
|
160
|
-
FileUtils.rm_rf 'ssl'
|
|
161
|
-
|
|
162
|
-
server = Trinidad::Server.new({
|
|
163
|
-
:ssl => {
|
|
164
|
-
:port => 8443,
|
|
165
|
-
:SSLCertificateFile => '/usr/local/ssl/server.crt'
|
|
166
|
-
},
|
|
167
|
-
:web_app_dir => MOCK_WEB_APP_DIR})
|
|
168
|
-
|
|
169
|
-
File.exist?('ssl').should be_false
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def default_context_should_be_loaded(children)
|
|
173
|
-
children.should have(1).web_apps
|
|
174
|
-
children[0].doc_base.should == MOCK_WEB_APP_DIR
|
|
175
|
-
children[0].path.should == '/'
|
|
176
|
-
children[0]
|
|
177
|
-
end
|
|
178
|
-
end
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
require File.dirname(__FILE__) + '/fakeapp'
|
|
3
|
-
|
|
4
|
-
include FakeApp
|
|
5
|
-
|
|
6
|
-
# adding accessor for tests
|
|
7
|
-
class Trinidad::WebAppLifecycleListener
|
|
8
|
-
attr_accessor :context
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
import org.apache.catalina.Lifecycle
|
|
12
|
-
|
|
13
|
-
describe Trinidad::WebAppLifecycleListener do
|
|
14
|
-
before do
|
|
15
|
-
@mock = mock
|
|
16
|
-
@mock.stubs(:type).returns(Lifecycle::BEFORE_START_EVENT)
|
|
17
|
-
@mock.stubs(:lifecycle).returns(Trinidad::Tomcat::StandardContext.new)
|
|
18
|
-
|
|
19
|
-
@tomcat = Trinidad::Tomcat::Tomcat.new
|
|
20
|
-
@tomcat.host.app_base = Dir.pwd
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "ignores the event when it's not BEFORE_START_EVENT" do
|
|
24
|
-
listener = Trinidad::WebAppLifecycleListener.new(nil)
|
|
25
|
-
@mock.stubs(:type).returns(Lifecycle::BEFORE_STOP_EVENT)
|
|
26
|
-
lambda {
|
|
27
|
-
listener.lifecycleEvent(@mock)
|
|
28
|
-
}.should_not raise_error
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "tries to initialize the context when the event is BEFORE_START_EVENT" do
|
|
32
|
-
listener = Trinidad::WebAppLifecycleListener.new(nil)
|
|
33
|
-
lambda {
|
|
34
|
-
listener.lifecycleEvent(@mock)
|
|
35
|
-
}.should raise_error
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "doesn't load a default web xml when the deployment descriptor is not provided" do
|
|
39
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RailsWebApp.new({}, {}))
|
|
40
|
-
listener.configure_deployment_descriptor.should be_nil
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "loads a default web xml when the deployment descriptor is provided" do
|
|
44
|
-
FakeFS do
|
|
45
|
-
create_rails_web_xml
|
|
46
|
-
|
|
47
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RailsWebApp.new({}, {
|
|
48
|
-
:web_app_dir => Dir.pwd,
|
|
49
|
-
:default_web_xml => 'config/web.xml'
|
|
50
|
-
}))
|
|
51
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
52
|
-
|
|
53
|
-
expected_xml = File.join(Dir.pwd, 'config/web.xml')
|
|
54
|
-
listener.configure_deployment_descriptor.should == expected_xml
|
|
55
|
-
listener.context.default_web_xml.should == expected_xml
|
|
56
|
-
|
|
57
|
-
listener.context.find_lifecycle_listeners.
|
|
58
|
-
map {|l| l.class.name }.should include('Java::OrgApacheCatalinaStartup::ContextConfig')
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "adds the rack servlet and the mapping for /*" do
|
|
63
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RailsWebApp.new({}, {}))
|
|
64
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
65
|
-
|
|
66
|
-
listener.configure_rack_servlet
|
|
67
|
-
|
|
68
|
-
servlet = listener.context.find_child('RackServlet')
|
|
69
|
-
servlet.should_not be_nil
|
|
70
|
-
servlet.servlet_class.should == 'org.jruby.rack.RackServlet'
|
|
71
|
-
|
|
72
|
-
listener.context.find_servlet_mapping('/*').should == 'RackServlet'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "configures the rack context listener from the web app" do
|
|
76
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RackupWebApp.new({}, {}))
|
|
77
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
78
|
-
listener.configure_rack_listener
|
|
79
|
-
|
|
80
|
-
listener.context.find_application_listeners.should include('org.jruby.rack.RackServletContextListener')
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "adds context parameters from the web app" do
|
|
84
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RailsWebApp.new({}, {
|
|
85
|
-
:jruby_min_runtimes => 1
|
|
86
|
-
}))
|
|
87
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
88
|
-
listener.configure_init_params
|
|
89
|
-
|
|
90
|
-
listener.context.find_parameter('jruby.min.runtimes').should == '1'
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "ignores parameters already present in the deployment descriptor" do
|
|
94
|
-
listener = Trinidad::WebAppLifecycleListener.new(Trinidad::RailsWebApp.new({}, {
|
|
95
|
-
:jruby_max_runtimes => 1,
|
|
96
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
97
|
-
:default_web_xml => 'config/web.xml'
|
|
98
|
-
}))
|
|
99
|
-
listener.init_defaults(@tomcat.add_webapp('/', Dir.pwd))
|
|
100
|
-
|
|
101
|
-
listener.context.find_parameter('jruby.max.runtimes').should be_nil
|
|
102
|
-
listener.context.start
|
|
103
|
-
listener.context.find_parameter('jruby.max.runtimes').should == '8'
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "doesn't load classes into a jar when the libs directory is not present" do
|
|
107
|
-
web_app = Trinidad::RailsWebApp.new({}, {})
|
|
108
|
-
|
|
109
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
110
|
-
listener.add_application_jars(web_app.class_loader)
|
|
111
|
-
|
|
112
|
-
lambda {
|
|
113
|
-
web_app.class_loader.find_class('org.ho.yaml.Yaml')
|
|
114
|
-
}.should raise_error
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "loads classes into a jar when the libs directory is provided" do
|
|
118
|
-
web_app = Trinidad::RailsWebApp.new({}, {
|
|
119
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
120
|
-
:libs_dir => 'lib'
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
124
|
-
listener.add_application_jars(web_app.class_loader)
|
|
125
|
-
|
|
126
|
-
lambda {
|
|
127
|
-
web_app.class_loader.find_class('org.ho.yaml.Yaml').should_not be_nil
|
|
128
|
-
}.should_not raise_error
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "doesn't load java classes when the classes directory is not present" do
|
|
132
|
-
web_app = Trinidad::RailsWebApp.new({}, {})
|
|
133
|
-
|
|
134
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
135
|
-
listener.add_application_java_classes(web_app.class_loader)
|
|
136
|
-
|
|
137
|
-
lambda {
|
|
138
|
-
web_app.class_loader.find_class('HelloTomcat')
|
|
139
|
-
}.should raise_error
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "loads java classes when the classes directory is provided" do
|
|
143
|
-
web_app = Trinidad::RailsWebApp.new({}, {
|
|
144
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
145
|
-
:classes_dir => 'classes'
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
149
|
-
listener.add_application_java_classes(web_app.class_loader)
|
|
150
|
-
|
|
151
|
-
lambda {
|
|
152
|
-
web_app.class_loader.find_class('HelloTomcat').should_not be_nil
|
|
153
|
-
}.should_not raise_error
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "creates a WebappLoader with the JRuby class loader" do
|
|
157
|
-
web_app = Trinidad::RailsWebApp.new({}, {})
|
|
158
|
-
|
|
159
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
160
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
161
|
-
listener.configure_context_loader
|
|
162
|
-
|
|
163
|
-
loader = listener.context.loader
|
|
164
|
-
|
|
165
|
-
loader.should be_instance_of(Java::OrgApacheCatalinaLoader::WebappLoader)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "loads the default application from the current directory using the rackup file if :web_apps is not present" do
|
|
169
|
-
web_app = Trinidad::RackupWebApp.new({
|
|
170
|
-
:web_app_dir => MOCK_WEB_APP_DIR,
|
|
171
|
-
:rackup => 'config.ru'
|
|
172
|
-
}, {})
|
|
173
|
-
listener = Trinidad::WebAppLifecycleListener.new(web_app)
|
|
174
|
-
listener.context = Trinidad::Tomcat::StandardContext.new
|
|
175
|
-
listener.configure_init_params
|
|
176
|
-
|
|
177
|
-
listener.context.find_parameter('rackup.path').should == "config.ru"
|
|
178
|
-
end
|
|
179
|
-
end
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
require File.dirname(__FILE__) + '/fakeapp'
|
|
3
|
-
|
|
4
|
-
include FakeApp
|
|
5
|
-
|
|
6
|
-
describe Trinidad::WebApp do
|
|
7
|
-
it "creates a RailsWebApp if rackup option is not present" do
|
|
8
|
-
app = Trinidad::WebApp.create({}, {})
|
|
9
|
-
app.should be_an_instance_of(Trinidad::RailsWebApp)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "creates a RackupWebApp if rackup option is present" do
|
|
13
|
-
app = Trinidad::WebApp.create({}, {:rackup => 'config.ru'})
|
|
14
|
-
app.should be_an_instance_of(Trinidad::RackupWebApp)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "ignores rack_servlet when a deployment descriptor already provides it" do
|
|
18
|
-
FakeFS do
|
|
19
|
-
create_rails_web_xml
|
|
20
|
-
|
|
21
|
-
app = Trinidad::WebApp.create({}, {
|
|
22
|
-
:web_app_dir => Dir.pwd,
|
|
23
|
-
:default_web_xml => 'config/web.xml'
|
|
24
|
-
})
|
|
25
|
-
app.servlet.should be_nil
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "ignores rack_listener when a deployment descriptor already provides it" do
|
|
30
|
-
FakeFS do
|
|
31
|
-
create_rails_web_xml
|
|
32
|
-
|
|
33
|
-
app = Trinidad::WebApp.create({}, {
|
|
34
|
-
:web_app_dir => Dir.pwd,
|
|
35
|
-
:default_web_xml => 'config/web.xml'
|
|
36
|
-
})
|
|
37
|
-
app.rack_listener.should be_nil
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "uses rack_servlet as the default servlet when a deployment descriptor is not provided" do
|
|
42
|
-
app = Trinidad::WebApp.create({}, {})
|
|
43
|
-
app.servlet.should_not be_nil
|
|
44
|
-
app.servlet[:name].should == 'RackServlet'
|
|
45
|
-
app.servlet[:class].should == 'org.jruby.rack.RackServlet'
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "uses rack_listener as the default listener when a deployment descriptor is not provided" do
|
|
49
|
-
app = Trinidad::WebApp.create({}, {})
|
|
50
|
-
app.rack_listener.should == 'org.jruby.rack.rails.RailsServletContextListener'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "loads the context parameters from the configuration when a deployment descriptor is not provided" do
|
|
54
|
-
app = Trinidad::WebApp.create({}, {
|
|
55
|
-
:jruby_min_runtimes => 1,
|
|
56
|
-
:jruby_max_runtimes => 1,
|
|
57
|
-
:public => 'foo',
|
|
58
|
-
:environment => :production
|
|
59
|
-
})
|
|
60
|
-
parameters = app.init_params
|
|
61
|
-
parameters['jruby.min.runtimes'].should == '1'
|
|
62
|
-
parameters['jruby.initial.runtimes'].should == '1'
|
|
63
|
-
parameters['jruby.max.runtimes'].should == '1'
|
|
64
|
-
parameters['public.root'].should == '/foo'
|
|
65
|
-
parameters['rails.env'].should == 'production'
|
|
66
|
-
parameters['rails.root'].should == '/'
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "adds the rackup script as a context parameter when it's provided" do
|
|
70
|
-
FakeFS do
|
|
71
|
-
create_rackup_file
|
|
72
|
-
app = Trinidad::WebApp.create({}, {
|
|
73
|
-
:web_app_dir => Dir.pwd,
|
|
74
|
-
:rackup => 'config/config.ru'
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
parameters = app.init_params
|
|
78
|
-
parameters['rackup.path'].should == 'config/config.ru'
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "ignores parameters from configuration when the deployment descriptor already contains them" do
|
|
83
|
-
FakeFS do
|
|
84
|
-
create_rackup_web_xml
|
|
85
|
-
|
|
86
|
-
app = Trinidad::WebApp.create({}, {
|
|
87
|
-
:web_app_dir => Dir.pwd,
|
|
88
|
-
:default_web_xml => 'config/web.xml',
|
|
89
|
-
:jruby_min_runtimes => 2,
|
|
90
|
-
:jruby_max_runtimes => 5
|
|
91
|
-
})
|
|
92
|
-
parameters = app.init_params
|
|
93
|
-
|
|
94
|
-
parameters['jruby.min.runtimes'].should be_nil
|
|
95
|
-
parameters['jruby.max.runtimes'].should be_nil
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "ignores the deployment descriptor when it doesn't exist" do
|
|
100
|
-
app = Trinidad::WebApp.create({}, {
|
|
101
|
-
:web_app_dir => Dir.pwd,
|
|
102
|
-
:default_web_xml => 'config/web.xml'
|
|
103
|
-
})
|
|
104
|
-
app.default_deployment_descriptor.should be_nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "doesn't load any web.xml when the deployment descriptor doesn't exist" do
|
|
108
|
-
app = Trinidad::WebApp.create({}, {
|
|
109
|
-
:web_app_dir => Dir.pwd,
|
|
110
|
-
:default_web_xml => 'config/web.xml'
|
|
111
|
-
})
|
|
112
|
-
app.rack_servlet_configured?.should be_false
|
|
113
|
-
app.rack_listener_configured?.should be_false
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "uses `public` as default public root directory" do
|
|
117
|
-
app = Trinidad::WebApp.create({}, {})
|
|
118
|
-
app.public_root.should == 'public'
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "uses extensions from the global configuration" do
|
|
122
|
-
config = { :extensions => {:hotdeploy => {}} }
|
|
123
|
-
app = Trinidad::WebApp.create(config, {})
|
|
124
|
-
app.extensions.should include(:hotdeploy)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "overrides global extensions with application extensions" do
|
|
128
|
-
config = { :extensions => {:hotdeploy => {}} }
|
|
129
|
-
app_config = { :extensions => {:hotdeploy => {:delay => 30000}} }
|
|
130
|
-
app = Trinidad::WebApp.create(config, app_config)
|
|
131
|
-
app.extensions[:hotdeploy].should include(:delay)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it "creates a rackup application when the rackup file is under WEB-INF directory" do
|
|
135
|
-
FakeFS do
|
|
136
|
-
create_rackup_file('WEB-INF')
|
|
137
|
-
app = Trinidad::WebApp.create({}, {})
|
|
138
|
-
|
|
139
|
-
app.should be_an_instance_of(Trinidad::RackupWebApp)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "doesn't add the rackup init parameter when the rackup file is under WEB-INF directory" do
|
|
144
|
-
FakeFS do
|
|
145
|
-
create_rackup_file('WEB-INF')
|
|
146
|
-
app = Trinidad::WebApp.create({}, {})
|
|
147
|
-
|
|
148
|
-
app.init_params.should_not include('rackup.path')
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "loads rackup file from a given directory" do
|
|
153
|
-
FakeFS do
|
|
154
|
-
create_rackup_file('rack')
|
|
155
|
-
app = Trinidad::WebApp.create({}, {
|
|
156
|
-
:web_app_dir => Dir.pwd,
|
|
157
|
-
:rackup => 'rack'
|
|
158
|
-
})
|
|
159
|
-
app.init_params.should include('rackup.path')
|
|
160
|
-
app.init_params['rackup.path'].should == 'rack/config.ru'
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it "allows to configure the servlet from the configuration options" do
|
|
165
|
-
app = Trinidad::WebApp.create({}, {
|
|
166
|
-
:servlet => {
|
|
167
|
-
:class => 'org.jruby.trinidad.FakeServlet',
|
|
168
|
-
:name => 'FakeServlet'
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
app.servlet[:class].should == 'org.jruby.trinidad.FakeServlet'
|
|
173
|
-
app.servlet[:name].should == 'FakeServlet'
|
|
174
|
-
end
|
|
175
|
-
end
|