trinidad_jars 0.3.2 → 0.3.3

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/lib/trinidad/jars.rb CHANGED
@@ -4,7 +4,8 @@ $:.unshift(TRINIDAD_LIBS) unless
4
4
 
5
5
  module Trinidad
6
6
  require 'tomcat-core'
7
- TOMCAT_VERSION = '7.0.2' unless defined?(Trinidad::TOMCAT_VERSION)
7
+ TRINIDAD_JARS_VERSION = '0.3.3'
8
+ TOMCAT_VERSION = '7.0.4' unless defined?(Trinidad::TOMCAT_VERSION)
8
9
 
9
10
  module Tomcat
10
11
  include_package 'org.apache.catalina'
Binary file
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Calavera
@@ -14,45 +14,31 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-26 00:00:00 +02:00
18
- default_executable: trinidad
17
+ date: 2010-11-11 00:00:00 -06:00
18
+ default_executable:
19
19
  dependencies: []
20
20
 
21
- description:
21
+ description: Bundled version of Tomcat packed for Trinidad
22
22
  email: calavera@apache.org
23
- executables:
24
- - trinidad
23
+ executables: []
24
+
25
25
  extensions: []
26
26
 
27
- extra_rdoc_files:
28
- - LICENSE
29
- - README.rdoc
27
+ extra_rdoc_files: []
28
+
30
29
  files:
31
30
  - lib/trinidad/jars.rb
32
31
  - trinidad-libs/tomcat-core.jar
33
- - LICENSE
34
- - README.rdoc
35
- - spec/spec_helper.rb
36
- - spec/fixtures/trinidad_foo_extension.rb
37
- - spec/fixtures/trinidad_override_tomcat_extension.rb
38
- - spec/trinidad/command_line_parser_spec.rb
39
- - spec/trinidad/extensions_spec.rb
40
- - spec/trinidad/fakeapp.rb
41
- - spec/trinidad/server_spec.rb
42
- - spec/trinidad/web_app_lifecycle_listener_spec.rb
43
- - spec/trinidad/web_app_spec.rb
44
- - bin/trinidad
45
32
  has_rdoc: true
46
- homepage: http://calavera.github.com/trinidad
33
+ homepage: http://github.com/calavera/trinidad
47
34
  licenses: []
48
35
 
49
36
  post_install_message:
50
- rdoc_options:
51
- - --charset=UTF-8
37
+ rdoc_options: []
38
+
52
39
  require_paths:
53
40
  - lib
54
41
  required_ruby_version: !ruby/object:Gem::Requirement
55
- none: false
56
42
  requirements:
57
43
  - - ">="
58
44
  - !ruby/object:Gem::Version
@@ -60,7 +46,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
46
  - 0
61
47
  version: "0"
62
48
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
49
  requirements:
65
50
  - - ">="
66
51
  - !ruby/object:Gem::Version
@@ -70,17 +55,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
55
  requirements: []
71
56
 
72
57
  rubyforge_project: trinidad_jars
73
- rubygems_version: 1.3.7
58
+ rubygems_version: 1.3.6
74
59
  signing_key:
75
- specification_version: 3
76
- summary: Common jars for Trinidad
77
- test_files:
78
- - spec/spec_helper.rb
79
- - spec/fixtures/trinidad_foo_extension.rb
80
- - spec/fixtures/trinidad_override_tomcat_extension.rb
81
- - spec/trinidad/command_line_parser_spec.rb
82
- - spec/trinidad/extensions_spec.rb
83
- - spec/trinidad/fakeapp.rb
84
- - spec/trinidad/server_spec.rb
85
- - spec/trinidad/web_app_lifecycle_listener_spec.rb
86
- - spec/trinidad/web_app_spec.rb
60
+ specification_version: 2
61
+ summary: Tomcat's jars packed for Trinidad
62
+ test_files: []
63
+
data/LICENSE DELETED
@@ -1,26 +0,0 @@
1
- == Trinidad
2
-
3
- Copyright (c) 2009 David Calavera
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
-
24
- == Additional Bundled Software
25
-
26
- Apache Tomcat is licensed according to the terms of Apache License, Version 2.0 (current). See http://www.apache.org/licenses/LICENSE-2.0 for details.
data/README.rdoc DELETED
@@ -1,74 +0,0 @@
1
- = trinidad
2
-
3
- Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
4
-
5
- Mail list: http://groups.google.com/group/rails-trinidad
6
- Bug tracker: http://github.com/calavera/trinidad/issues
7
-
8
- == INSTALL:
9
-
10
- jgem install trinidad
11
-
12
- == USAGE:
13
-
14
- Rails applications:
15
-
16
- $ cd myrailsapp
17
- $ jruby -S trinidad
18
-
19
- Rack applications:
20
-
21
- $ cd myrackapplication
22
-
23
- $ jruby -S trinidad -r path_to_rackup/rackup_file
24
-
25
- or if the name of the file is config.ru
26
-
27
- $ jruby -S trinidad -r path_to_rackup
28
-
29
- or if config.ru is in the base directory
30
-
31
- $ jruby -S trinidad -r
32
-
33
- or if config.ru is under the directory WEB-INF
34
-
35
- $ jruby -S trinidad
36
-
37
- == CONFIGURATION:
38
-
39
- Trinidad allows you to configure some parameters when the server is started from the command line, the following is a list of the currently supported options:
40
-
41
- * -p, --port PORT => port to bind to.
42
- * -e, --env ENVIRONMENT => rails environment.
43
- * -c, --context CONTEXT => application context path.
44
- * --lib, --jars LIBS_DIR => directory containing jars.
45
- * --classes CLASSES_DIR => directory containing classes.
46
- * -r, --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
47
- * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
48
- * -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.
49
- * -l, --load EXTENSION_NAME => loads an extension to use its command line options.
50
-
51
- 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/trinidad.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
52
-
53
- jruby -S trinidad -f
54
- jruby -S trinidad --config my_custom_configuration.yml
55
-
56
- You can also specify a default web.xml to config your web application. By default the server tries to load the file <em>config/web.xml</em> but you can modify this path adding the option <em>default_web_xml</em> within your configuration file.
57
-
58
- Other advanced options can be found in the wiki: http://wiki.github.com/calavera/trinidad/advanced-configuration
59
-
60
- == EXTENSIONS:
61
-
62
- 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:
63
-
64
- * Database connection pooling: http://github.com/calavera/trinidad-dbpool
65
- * Daemon, run Trinidad as a daemon: http://github.com/calavera/trinidad_daemon_extension
66
- * Hot deploy, do hot deploys monitorizing a temporal file, ala Passenger: http://github.com/calavera/trinidad_hotdeploy_extension
67
- * Sandbox, management console and REST api: http://github.com/calavera/trinidad_sandbox_extension
68
- * Logging, enhance the Trinidad's logging system: http://github.com/calavera/trinidad_logging_extension
69
-
70
- You can find further information on how to write your own extension in the wiki: http://wiki.github.com/calavera/trinidad/extensions
71
-
72
- == Copyright
73
-
74
- Copyright (c) 2010 David Calavera<calavera@apache.org>. See LICENSE for details.
data/bin/trinidad DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env jruby
2
-
3
- $:.unshift(File.dirname(__FILE__) + '/../lib')
4
- $:.unshift(File.dirname(__FILE__) + '/../trinidad-libs')
5
-
6
- require "trinidad"
7
-
8
- opts = Trinidad::CommandLineParser.parse(ARGV)
9
- Trinidad::Server.new(opts).start
@@ -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
@@ -1,11 +0,0 @@
1
- module Trinidad
2
- module Extensions
3
- class OverrideTomcatServerExtension < ServerExtension
4
- def configure(tomcat)
5
- Trinidad::Tomcat::Tomcat.new
6
- end
7
-
8
- def override_tomcat?; true; end
9
- end
10
- end
11
- 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
@@ -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