torquebox-core 3.2.0-java → 4.0.0.alpha1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/torquebox +20 -0
  3. data/lib/resources/logback-cli.xml +12 -0
  4. data/lib/torquebox-core.jar +0 -0
  5. data/lib/torquebox-core.rb +51 -10
  6. data/lib/torquebox/cli.rb +129 -0
  7. data/lib/torquebox/cli/jar.rb +336 -0
  8. data/lib/torquebox/cli/war.rb +140 -0
  9. data/lib/torquebox/codecs.rb +35 -36
  10. data/lib/torquebox/codecs/edn.rb +39 -24
  11. data/lib/torquebox/codecs/json.rb +45 -44
  12. data/lib/torquebox/codecs/marshal.rb +25 -25
  13. data/lib/torquebox/codecs/marshal_base64.rb +26 -25
  14. data/lib/torquebox/codecs/marshal_smart.rb +34 -33
  15. data/lib/torquebox/codecs/text.rb +35 -0
  16. data/lib/torquebox/logger.rb +19 -129
  17. data/lib/torquebox/option_utils.rb +72 -0
  18. data/lib/torquebox/spec_helpers.rb +48 -0
  19. data/lib/torquebox/version.rb +20 -0
  20. data/lib/wunderboss-jars/jboss-logging-3.1.4.GA.jar +0 -0
  21. data/lib/wunderboss-jars/logback-classic-1.1.2.jar +0 -0
  22. data/lib/wunderboss-jars/logback-core-1.1.2.jar +0 -0
  23. data/lib/wunderboss-jars/slf4j-api-1.7.5.jar +0 -0
  24. data/lib/wunderboss-jars/wunderboss-core-1.x.incremental.174.jar +0 -0
  25. data/lib/wunderboss-jars/wunderboss-ruby-1.x.incremental.174.jar +0 -0
  26. data/lib/wunderboss-jars/wunderboss-wildfly-1.x.incremental.174.jar +0 -0
  27. metadata +71 -61
  28. data/lib/gem_hook.rb +0 -18
  29. data/lib/torquebox/component_manager.rb +0 -32
  30. data/lib/torquebox/core.rb +0 -29
  31. data/lib/torquebox/injectors.rb +0 -81
  32. data/lib/torquebox/kernel.rb +0 -47
  33. data/lib/torquebox/msc.rb +0 -98
  34. data/lib/torquebox/registry.rb +0 -52
  35. data/lib/torquebox/scheduled_job.rb +0 -245
  36. data/lib/torquebox/service.rb +0 -77
  37. data/lib/torquebox/service_registry.rb +0 -68
  38. data/licenses/cc0-1.0.txt +0 -121
  39. data/spec/codecs_spec.rb +0 -87
  40. data/spec/injectors_spec.rb +0 -28
  41. data/spec/kernel_spec.rb +0 -47
  42. data/spec/logger_spec.rb +0 -103
  43. data/spec/scheduled_job_spec.rb +0 -57
  44. data/spec/service_registry_spec.rb +0 -52
data/spec/codecs_spec.rb DELETED
@@ -1,87 +0,0 @@
1
- require 'torquebox/codecs'
2
- require 'torquebox/codecs/json'
3
-
4
- def define_JSON
5
- klass = Class.new {
6
- def self.fast_generate(_)
7
- end
8
- }
9
- Object.const_set(:JSON, klass)
10
- end
11
-
12
- describe TorqueBox::Codecs do
13
-
14
- context "json" do
15
- it "should decode an encoded array" do
16
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode(['abc'], :json), :json).should eql(['abc'])
17
- end
18
-
19
- if RUBY_VERSION >= '1.9'
20
- it "should decode an encoded string" do
21
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode('abc', :json), :json).should eql('abc')
22
- end
23
- end
24
-
25
- context "requiring json" do
26
- before(:each) do
27
- Object.send(:remove_const, :JSON) if defined?(JSON)
28
- end
29
-
30
- it "should raise if json isn't available" do
31
- TorqueBox::Codecs::JSON.should_receive(:require).with('json').and_raise(LoadError.new)
32
- lambda { TorqueBox::Codecs.encode('abc', :json) }.should raise_error( RuntimeError )
33
- end
34
-
35
- it "should not raise if json is available" do
36
- TorqueBox::Codecs::JSON.should_receive(:require).with('json').and_return { define_JSON }
37
- lambda { TorqueBox::Codecs.encode('abc', :json ) }.should_not raise_error
38
- end
39
-
40
- it "should only require json once" do
41
- TorqueBox::Codecs::JSON.should_receive(:require).once.with('json').and_return { define_JSON }
42
- TorqueBox::Codecs.encode('abc', :json)
43
- TorqueBox::Codecs.encode('abc', :json)
44
- end
45
- end
46
- end
47
-
48
- context "edn" do
49
- it "should decode what it encodes" do
50
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode('abc', :edn), :edn).should eql('abc')
51
- end
52
- end
53
-
54
- context "marshal" do
55
- it "should decode what it encodes" do
56
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode('abc', :marshal), :marshal).should eql('abc')
57
- end
58
-
59
- it "should decode and encode Time objects" do
60
- now = Time.now
61
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode(now, :marshal), :marshal).should eql(now)
62
- end
63
- end
64
-
65
- context "marshal base64" do
66
- it "should decode what it encodes" do
67
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode('abc', :marshal_base64), :marshal_base64).should eql('abc')
68
- end
69
-
70
- it "should decode and encode Time objects" do
71
- now = Time.now
72
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode(now, :marshal_base64), :marshal_base64).should eql(now)
73
- end
74
- end
75
-
76
- context "marshal_smart" do
77
- it "should decode what it encodes" do
78
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode('abc', :marshal_smart), :marshal_smart).should eql('abc')
79
- end
80
-
81
- it "should decode and encode Time objects" do
82
- now = Time.now
83
- TorqueBox::Codecs.decode(TorqueBox::Codecs.encode(now, :marshal_smart), :marshal_smart).should eql(now)
84
- end
85
- end
86
-
87
- end
@@ -1,28 +0,0 @@
1
-
2
- require 'torquebox/injectors'
3
-
4
- describe TorqueBox::Injectors do
5
-
6
- include TorqueBox::Injectors
7
-
8
- it 'should return the same thing for all fetch types' do
9
- TorqueBox::Registry.merge!('this' => :that)
10
- TorqueBox::Registry['this'].should == :that
11
- fetch('this').should == :that
12
- fetch_msc('this').should == :that
13
- fetch_service('this').should == :that
14
- fetch_cdi(:this).should == :that
15
- fetch_jndi('this').should == :that
16
- fetch_queue('this').should == :that
17
- fetch_topic('this').should == :that
18
- end
19
-
20
- end
21
-
22
- describe 'TorqueBox::Injectors without include' do
23
- it 'should work' do
24
- TorqueBox::Registry.merge!('this' => :that)
25
- TorqueBox::Registry['this'].should == :that
26
- TorqueBox.fetch('this').should == :that
27
- end
28
- end
data/spec/kernel_spec.rb DELETED
@@ -1,47 +0,0 @@
1
-
2
- require 'torquebox/kernel'
3
-
4
- describe TorqueBox::Kernel do
5
-
6
- it "should return nil lookup if registry unavailable" do
7
- TorqueBox::ServiceRegistry.service_registry = nil
8
- TorqueBox::Kernel.lookup('foo').should be_nil
9
- end
10
-
11
- it "should return value from registry" do
12
- @registry["foo"] = "bar"
13
- TorqueBox::Kernel.lookup("foo").should eql("bar")
14
- end
15
-
16
- it "should yield value from from block when registry contains key" do
17
- @registry["foo"] = "bar"
18
- TorqueBox::Kernel.lookup("foo") {|x| "baz" }.should eql("baz")
19
- end
20
-
21
- it "should defer block execution if registry unavailable" do
22
- TorqueBox::ServiceRegistry.service_registry = nil
23
- @registry["foo"] = "bar"
24
- TorqueBox::Kernel.lookup("foo") { |foo| @foo = foo }.should be_nil
25
- TorqueBox::Kernel.blocks.should_not be_empty
26
- @foo = nil
27
- TorqueBox::ServiceRegistry.service_registry = @service_registry
28
- TorqueBox::Kernel.blocks.should be_empty
29
- @foo.should eql("bar")
30
- end
31
-
32
- # Mock a JBoss ServiceRegistry backed by a simple member Hash,
33
- # @registry, that holds the fixtures for the tests.
34
- before(:each) do
35
- TorqueBox::ServiceRegistry.stub!(:service_name_for).and_return { |name| name }
36
- TorqueBox::ServiceRegistry.service_registry = nil
37
- @registry = {}
38
- @service_registry = mock("service_registry")
39
- @service_registry.stub!(:getService).and_return { |name|
40
- service = mock("service")
41
- service.stub!(:getValue).and_return(@registry[name])
42
- service
43
- }
44
- TorqueBox::ServiceRegistry.service_registry = @service_registry
45
- end
46
-
47
- end
data/spec/logger_spec.rb DELETED
@@ -1,103 +0,0 @@
1
-
2
- require 'torquebox/logger'
3
- require 'fileutils'
4
- require 'logger'
5
-
6
- shared_examples_for 'a torquebox logger' do
7
- it "should look nice for class objects" do
8
- require 'torquebox/service_registry'
9
- logger = TorqueBox::Logger.new(TorqueBox::ServiceRegistry)
10
- logger.error("JC: log for cache store")
11
- end
12
-
13
- it "should support the various boolean methods" do
14
- logger.should respond_to(:debug?)
15
- logger.should respond_to(:info?)
16
- logger.should respond_to(:warn?)
17
- logger.should respond_to(:error?)
18
- logger.should respond_to(:fatal?)
19
- end
20
-
21
- it "should not barf on meaningless level setting" do
22
- logger.level = Logger::WARN
23
- logger.level.should == Logger::WARN
24
- end
25
-
26
- it "should deal with blocks correctly" do
27
- logger.error "JC: message zero"
28
- logger.error { "JC: message" }
29
- logger.error "JC: message too"
30
- end
31
-
32
- it "should handle nil parameters" do
33
- logger.info(nil)
34
- end
35
-
36
- it "should support the rack.errors interface" do
37
- logger.should respond_to(:puts)
38
- logger.should respond_to(:write)
39
- logger.should respond_to(:flush)
40
- end
41
-
42
- it "should have a formatter" do
43
- logger.should respond_to(:formatter)
44
- logger.formatter.should_not be_nil
45
- end
46
- end
47
-
48
- describe TorqueBox::Logger do
49
-
50
- let(:logger) { TorqueBox::Logger.new }
51
-
52
- it_should_behave_like 'a torquebox logger'
53
-
54
- it "should support the trace boolean method" do
55
- logger.should respond_to(:trace?)
56
- end
57
-
58
- it "should support the add method" do
59
- fake_logger = mock('logger')
60
- org.jboss.logging::Logger.stub!(:getLogger).and_return(fake_logger)
61
- logger = TorqueBox::Logger.new
62
-
63
- fake_logger.should_receive(:debug).with('debug')
64
- logger.add(Logger::DEBUG, 'debug', nil)
65
-
66
- fake_logger.should_receive(:info).with('info')
67
- logger.add(Logger::INFO, 'info', nil)
68
-
69
- fake_logger.should_receive(:warn).with('warning')
70
- logger.add(Logger::WARN, 'warning', nil)
71
-
72
- fake_logger.should_receive(:error).with('error')
73
- logger.add(Logger::ERROR, 'error', nil)
74
-
75
- fake_logger.should_receive(:warn).with('unknown')
76
- logger.add(Logger::UNKNOWN, 'unknown', nil)
77
-
78
- fake_logger.should_receive(:warn).with('block')
79
- logger.add(Logger::WARN, nil, nil) { 'block' }
80
- end
81
- end
82
-
83
- describe TorqueBox::FallbackLogger do
84
- before(:each) do
85
- @log_path = File.expand_path(File.join(File.dirname(__FILE__), '..',
86
- 'target',
87
- 'logger_spec_output.log'))
88
- ENV['TORQUEBOX_FALLBACK_LOGFILE'] = @log_path
89
- end
90
-
91
- after(:each) do
92
- FileUtils.rm_f(@log_path)
93
- end
94
-
95
- let(:logger) { TorqueBox::FallbackLogger.new }
96
-
97
- it_should_behave_like 'a torquebox logger'
98
-
99
- it "should let users override the fallback log file" do
100
- logger.info('testing fallback log file')
101
- File.read(@log_path).should include('testing fallback log file')
102
- end
103
- end
@@ -1,57 +0,0 @@
1
- require 'torquebox/scheduled_job'
2
-
3
- describe TorqueBox::ScheduledJob do
4
- context "'at' jobs" do
5
- it "should raise if no options are specified" do
6
- lambda {
7
- TorqueBox::ScheduledJob.at('Class', nil)
8
- }.should raise_error("Invalid options for scheduling the job")
9
- end
10
-
11
- it "should raise if invalid options are specified" do
12
- lambda {
13
- TorqueBox::ScheduledJob.at('Class', "something")
14
- }.should raise_error("Invalid options for scheduling the job")
15
- end
16
-
17
- it "should raise if :at and :in options are both specified" do
18
- lambda {
19
- TorqueBox::ScheduledJob.at('Class', :at => Time.now, :in => 2_000)
20
- }.should raise_error("You can't specify both :at and :in")
21
- end
22
-
23
- it "should raise if :repeat is used without :every" do
24
- lambda {
25
- TorqueBox::ScheduledJob.at('Class', :at => Time.now, :repeat => 2_000)
26
- }.should raise_error("You can't specify :repeat without :every")
27
- end
28
-
29
- it "should raise if :until is used without :every" do
30
- lambda {
31
- TorqueBox::ScheduledJob.at('Class', :at => Time.now, :until => Time.now + 2)
32
- }.should raise_error("You can't specify :until without :every")
33
- end
34
-
35
- it "should raise if the :in parameter is not an Fixnum" do
36
- lambda {
37
- TorqueBox::ScheduledJob.at('Class', :in => Time.now)
38
- }.should raise_error("Invalid type for :in, should be a Fixnum")
39
-
40
- end
41
- end
42
-
43
- context "scheduled job" do
44
- it "should raise if the job class is not provided" do
45
- lambda {
46
- TorqueBox::ScheduledJob.schedule(nil, '')
47
- }.should raise_error("No job class name provided")
48
- end
49
-
50
- it "should raise if the cron expression is not provided" do
51
- lambda {
52
- TorqueBox::ScheduledJob.schedule('Class', nil)
53
- }.should raise_error("No cron expression provided")
54
- end
55
- end
56
- end
57
-
@@ -1,52 +0,0 @@
1
-
2
- require 'torquebox/service_registry'
3
-
4
- describe TorqueBox::ServiceRegistry do
5
-
6
- it "should return nil lookup if registry unavailable" do
7
- TorqueBox::ServiceRegistry.lookup('foo').should be_nil
8
- end
9
-
10
- it "should return value from registry" do
11
- @registry["foo"] = "bar"
12
- TorqueBox::ServiceRegistry.service_registry = @service_registry
13
- TorqueBox::ServiceRegistry.lookup("foo").should eql("bar")
14
- end
15
-
16
- it "should yield value from from block when registry contains key" do
17
- @registry["foo"] = "bar"
18
- TorqueBox::ServiceRegistry.service_registry = @service_registry
19
- TorqueBox::ServiceRegistry.lookup("foo") {|x| "baz" }.should eql("baz")
20
- end
21
-
22
- it "should defer block execution if registry unavailable" do
23
- @registry["foo"] = "bar"
24
- TorqueBox::ServiceRegistry.lookup("foo") { |foo| @foo = foo }.should be_nil
25
- TorqueBox::ServiceRegistry.blocks.should_not be_empty
26
- @foo = nil
27
- TorqueBox::ServiceRegistry.service_registry = @service_registry
28
- TorqueBox::ServiceRegistry.blocks.should be_empty
29
- @foo.should eql("bar")
30
- end
31
-
32
- it "should make the registry available" do
33
- TorqueBox::ServiceRegistry.service_registry = @service_registry
34
- TorqueBox::ServiceRegistry.registry.should == @service_registry
35
- end
36
-
37
- # Mock a JBoss ServiceRegistry backed by a simple member Hash,
38
- # @registry, that holds the fixtures for the tests.
39
- before(:each) do
40
- TorqueBox::ServiceRegistry.stub!(:service_name_for).and_return { |name| name }
41
- TorqueBox::ServiceRegistry.service_registry = nil
42
- @registry = {}
43
- @service_registry = mock("service_registry")
44
- @service_registry.stub!(:getService).and_return { |name|
45
- service = mock("service")
46
- service.stub!(:getValue).and_return(@registry[name])
47
- service
48
- }
49
- end
50
-
51
- end
52
-