@@ -555,7 +555,7 @@ def createRackServletWrapper(runtime, rackup, filename)
555555describe org . jruby . rack . PoolingRackApplicationFactory do
556556
557557 before :each do
558- @factory = double ( "factory" ) . as_null_object
558+ @factory = double "factory"
559559 @pooling_factory = org . jruby . rack . PoolingRackApplicationFactory . new @factory
560560 @pooling_factory . context = @rack_context
561561 end
@@ -638,7 +638,7 @@ def createRackServletWrapper(runtime, rackup, filename)
638638 it "forces the maximum size to be greater or equal to the initial size" do
639639 allow ( @factory ) . to receive ( :init )
640640 allow ( @factory ) . to receive ( :newApplication ) do
641- app = double ( "app" ) . as_null_object
641+ app = double "app"
642642 expect ( app ) . to receive ( :init )
643643 app
644644 end
@@ -652,15 +652,15 @@ def createRackServletWrapper(runtime, rackup, filename)
652652 end
653653
654654 it "retrieves the error application from the delegate factory" do
655- app = double ( "app" ) . as_null_object
655+ app = double "app"
656656 expect ( @factory ) . to receive ( :getErrorApplication ) . and_return app
657657 expect ( @pooling_factory . getErrorApplication ) . to eq app
658658 end
659659
660660 it "waits till initial runtimes get initialized (with wait set to true)" do
661661 allow ( @factory ) . to receive ( :init )
662662 allow ( @factory ) . to receive ( :newApplication ) do
663- app = double ( "app" ) . as_null_object
663+ app = double "app"
664664 allow ( app ) . to receive ( :init ) do
665665 sleep ( 0.05 )
666666 end
@@ -680,7 +680,7 @@ def createRackServletWrapper(runtime, rackup, filename)
680680 allow ( @factory ) . to receive ( :init )
681681 app_count = java . util . concurrent . atomic . AtomicInteger . new ( 0 )
682682 allow ( @factory ) . to receive ( :newApplication ) do
683- app = double ( "app" ) . as_null_object
683+ app = double "app"
684684 allow ( app ) . to receive ( :init ) do
685685 if app_count . addAndGet ( 1 ) == 2
686686 raise org . jruby . rack . RackInitializationException . new ( 'failed app init' )
@@ -761,6 +761,17 @@ def createRackServletWrapper(runtime, rackup, filename)
761761 expect ( @pooling_factory . getApplication ) . to eq app2
762762 end
763763
764+ class ThreadSafeMock
765+ def initialize ( obj )
766+ @delegate = obj
767+ @lock = Mutex . new
768+ end
769+
770+ def method_missing ( name , *args , &block )
771+ @lock . synchronize { @delegate . send ( name , *args , &block ) }
772+ end
773+ end
774+
764775 it "gets and initializes new applications until maximum allows to create more" do
765776 app_init_secs = 0.1
766777 allow ( @factory ) . to receive ( :init )
@@ -796,7 +807,7 @@ def createRackServletWrapper(runtime, rackup, filename)
796807 end
797808
798809 it "initializes initial runtimes in parallel (with wait set to false)" do
799- app_init_secs = 0.15
810+ app_init_secs = 0.05
800811 allow ( @factory ) . to receive ( :init )
801812 allow ( @factory ) . to receive ( :newApplication ) do
802813 app = double "app"
@@ -826,7 +837,7 @@ def createRackServletWrapper(runtime, rackup, filename)
826837 app_init_secs = 0.05
827838 allow ( @factory ) . to receive ( :init )
828839 allow ( @factory ) . to receive ( :newApplication ) do
829- app = double ( "app" ) . as_null_object
840+ app = double "app"
830841 allow ( app ) . to receive ( :init ) { sleep ( app_init_secs ) ; raise "app.init raising" }
831842 app
832843 end
0 commit comments