1-
2- require File . expand_path ( 'spec_helper' , File . dirname ( __FILE__ ) + '/../..' )
3- require 'jruby'
1+ require File . expand_path ( '../../spec_helper' , File . dirname ( __FILE__ ) )
42
53describe org . jruby . rack . embed . Config do
64
97 java . lang . System . set_property "foo" , "bar"
108 java . lang . System . set_property "truish" , "true"
119 java . lang . System . set_property "falsish" , "false"
12-
10+
1311 subject . get_property ( 'foo' ) . should == 'bar'
1412 subject . get_property ( 'foo' , 'BAR' ) . should == 'bar'
15-
13+
1614 subject . get_boolean_property ( 'truish' ) . should == true
1715 subject . get_boolean_property ( 'falsish' , true ) . should == false
1816 ensure
2220 end
2321 end
2422
25- it "honors properties from provided config if available" do
26- foo_config = org . jruby . rack . RackConfig . impl { }
27- def foo_config . getProperty ( name , default = nil )
28- name == 'foo' ? 'bar' : default
29- end
30-
31- constructor = org . jruby . rack . embed . Config . java_class . to_java .
32- getDeclaredConstructor ( [ org . jruby . rack . RackConfig . java_class ] . to_java :'java.lang.Class' )
33- constructor . setAccessible ( true )
34- config = constructor . newInstance ( foo_config ) # org.jruby.rack.embed.Config.new(foo_config)
35-
36- begin
37- java . lang . System . set_property "foo" , "BAR"
38- java . lang . System . set_property "bar" , "FOO"
39-
40- config . getProperty ( 'some' ) . should be nil
41-
42- config . getProperty ( 'foo' ) . should == 'bar'
43- config . getProperty ( 'bar' ) . should == 'FOO'
44- ensure
45- java . lang . System . clear_property "foo"
46- java . lang . System . clear_property "bar"
47- end
48- end
49-
23+ # it "honors properties from provided config if available" do
24+ # foo_config = org.jruby.rack.RackConfig.impl {}
25+ # def foo_config.getProperty(name, default = nil)
26+ # name == 'foo' ? 'bar' : default
27+ # end
28+ #
29+ # constructor = org.jruby.rack.embed.Config.java_class.to_java.
30+ # getDeclaredConstructor([ org.jruby.rack.RackConfig.java_class ].to_java :'java.lang.Class')
31+ # constructor.setAccessible(true)
32+ # config = constructor.newInstance(foo_config) # org.jruby.rack.embed.Config.new(foo_config)
33+ #
34+ # begin
35+ # java.lang.System.set_property "foo", "BAR"
36+ # java.lang.System.set_property "bar", "FOO"
37+ #
38+ # config.getProperty('some').should be nil
39+ #
40+ # config.getProperty('foo').should == 'bar'
41+ # config.getProperty('bar').should == 'FOO'
42+ # ensure
43+ # java.lang.System.clear_property "foo"
44+ # java.lang.System.clear_property "bar"
45+ # end
46+ # end
47+
5048 context "initialized" do
51-
49+
5250 before ( :each ) do
5351 @config = org . jruby . rack . embed . Config . new
5452 @config . doInitialize JRuby . runtime
5553 end
56-
54+
5755 it "resolves properties from ENV" do
5856 begin
5957 ENV [ 'env_foo' ] = 'env_bar'
6058 ENV [ 'env_true' ] = 'true'
6159 ENV [ 'env_false' ] = 'false'
62-
60+
6361 @config . get_property ( 'env_foo' ) . should == 'env_bar'
6462 @config . get_property ( 'env_true' ) . should == 'true'
65-
63+
6664 @config . get_boolean_property ( 'env_true' ) . should == true
6765 @config . get_boolean_property ( 'env_false' ) . should == false
6866 ensure
@@ -76,38 +74,36 @@ def foo_config.getProperty(name, default = nil)
7674 begin
7775 ENV [ "jruby.rack.request.size.initial.bytes" ] = '1024'
7876 ENV [ "jruby.rack.request.size.maximum.bytes" ] = '4096'
79-
77+
8078 @config . getInitialMemoryBufferSize . should == 1024
8179 @config . getMaximumMemoryBufferSize . should == 4096
8280 ensure
8381 ENV . delete ( "jruby.rack.request.size.initial.bytes" )
8482 ENV . delete ( "jruby.rack.request.size.treshold.bytes" )
8583 end
8684 end
87-
85+
8886 it "sets compat version from runtime" do
89- if JRuby . runtime . is1_9
90- @config . compat_version . should == org . jruby . CompatVersion ::RUBY1_9
91- else
92- @config . compat_version . should == org . jruby . CompatVersion ::RUBY1_8
93- end
87+ require 'jruby'
88+ compat_version = JRuby . runtime . instance_config . compat_version
89+ expect ( @config . compat_version ) . to eql compat_version
9490 end
95-
91+
9692 it "sets out/err streams from runtime" do
9793 out = java . io . ByteArrayOutputStream . new
9894 err = java . io . ByteArrayOutputStream . new
9995 config = org . jruby . RubyInstanceConfig . new
10096 config . output = java . io . PrintStream . new ( out )
10197 config . error = java . io . PrintStream . new ( err )
10298 @config . doInitialize org . jruby . Ruby . newInstance ( config )
103-
99+
104100 @config . getOut . println "hello out!"
105101 @config . getErr . println "hello err!"
106-
102+
107103 out . toString . should == "hello out!\n "
108104 err . toString . should == "hello err!\n "
109105 end
110106
111107 end
112-
108+
113109end
0 commit comments