99 java . lang . System . set_property "foo" , "bar"
1010 java . lang . System . set_property "truish" , "true"
1111 java . lang . System . set_property "falsish" , "false"
12-
12+
1313 subject . get_property ( 'foo' ) . should == 'bar'
1414 subject . get_property ( 'foo' , 'BAR' ) . should == 'bar'
15-
15+
1616 subject . get_boolean_property ( 'truish' ) . should == true
1717 subject . get_boolean_property ( 'falsish' , true ) . should == false
1818 ensure
2727 def foo_config . getProperty ( name , default = nil )
2828 name == 'foo' ? 'bar' : default
2929 end
30-
30+
3131 constructor = org . jruby . rack . embed . Config . java_class . to_java .
3232 getDeclaredConstructor ( [ org . jruby . rack . RackConfig . java_class ] . to_java :'java.lang.Class' )
3333 constructor . setAccessible ( true )
3434 config = constructor . newInstance ( foo_config ) # org.jruby.rack.embed.Config.new(foo_config)
35-
35+
3636 begin
3737 java . lang . System . set_property "foo" , "BAR"
3838 java . lang . System . set_property "bar" , "FOO"
39-
39+
4040 config . getProperty ( 'some' ) . should be nil
41-
41+
4242 config . getProperty ( 'foo' ) . should == 'bar'
4343 config . getProperty ( 'bar' ) . should == 'FOO'
4444 ensure
4545 java . lang . System . clear_property "foo"
4646 java . lang . System . clear_property "bar"
4747 end
4848 end
49-
49+
5050 context "initialized" do
51-
51+
5252 before ( :each ) do
5353 @config = org . jruby . rack . embed . Config . new
5454 @config . doInitialize JRuby . runtime
5555 end
56-
56+
5757 it "resolves properties from ENV" do
5858 begin
5959 ENV [ 'env_foo' ] = 'env_bar'
6060 ENV [ 'env_true' ] = 'true'
6161 ENV [ 'env_false' ] = 'false'
62-
62+
6363 @config . get_property ( 'env_foo' ) . should == 'env_bar'
6464 @config . get_property ( 'env_true' ) . should == 'true'
65-
65+
6666 @config . get_boolean_property ( 'env_true' ) . should == true
6767 @config . get_boolean_property ( 'env_false' ) . should == false
6868 ensure
@@ -76,38 +76,38 @@ def foo_config.getProperty(name, default = nil)
7676 begin
7777 ENV [ "jruby.rack.request.size.initial.bytes" ] = '1024'
7878 ENV [ "jruby.rack.request.size.maximum.bytes" ] = '4096'
79-
79+
8080 @config . getInitialMemoryBufferSize . should == 1024
8181 @config . getMaximumMemoryBufferSize . should == 4096
8282 ensure
8383 ENV . delete ( "jruby.rack.request.size.initial.bytes" )
8484 ENV . delete ( "jruby.rack.request.size.treshold.bytes" )
8585 end
8686 end
87-
87+
8888 it "sets compat version from runtime" do
8989 if JRuby . runtime . is1_9
9090 @config . compat_version . should == org . jruby . CompatVersion ::RUBY1_9
9191 else
9292 @config . compat_version . should == org . jruby . CompatVersion ::RUBY1_8
9393 end
94- end
95-
94+ end if JRUBY_VERSION . index ( '1.' ) == 0
95+
9696 it "sets out/err streams from runtime" do
9797 out = java . io . ByteArrayOutputStream . new
9898 err = java . io . ByteArrayOutputStream . new
9999 config = org . jruby . RubyInstanceConfig . new
100100 config . output = java . io . PrintStream . new ( out )
101101 config . error = java . io . PrintStream . new ( err )
102102 @config . doInitialize org . jruby . Ruby . newInstance ( config )
103-
103+
104104 @config . getOut . println "hello out!"
105105 @config . getErr . println "hello err!"
106-
106+
107107 out . toString . should == "hello out!\n "
108108 err . toString . should == "hello err!\n "
109109 end
110110
111111 end
112-
112+
113113end
0 commit comments