@@ -33,16 +33,19 @@ module JavaBuildpack::Jre
3333 end
3434
3535 it 'should detect with id of openjdk-<version>' do
36- JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
36+ Dir . mktmpdir do |root |
37+ JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
3738
38- detected = OpenJdk . new (
39- :app_dir => '' ,
40- :java_home => '' ,
41- :java_opts => [ ] ,
42- :configuration => { }
43- ) . detect
39+ detected = OpenJdk . new (
40+ :app_dir => '' ,
41+ :java_home => '' ,
42+ :java_opts => [ ] ,
43+ :configuration => { } ,
44+ :diagnostics => { :directory => root }
45+ ) . detect
4446
45- expect ( detected ) . to eq ( 'openjdk-1.7.0' )
47+ expect ( detected ) . to eq ( 'openjdk-1.7.0' )
48+ end
4649 end
4750
4851 it 'should extract Java from a GZipped TAR' do
@@ -52,10 +55,11 @@ module JavaBuildpack::Jre
5255 application_cache . stub ( :get ) . with ( 'test-uri' ) . and_yield ( File . open ( 'spec/fixtures/stub-java.tar.gz' ) )
5356
5457 OpenJdk . new (
55- :app_dir => root ,
56- :configuration => { } ,
57- :java_home => '' ,
58- :java_opts => [ ]
58+ :app_dir => root ,
59+ :configuration => { } ,
60+ :java_home => '' ,
61+ :java_opts => [ ] ,
62+ :diagnostics => { :directory => root }
5963 ) . compile
6064
6165 java = File . join ( root , '.java' , 'bin' , 'java' )
@@ -64,57 +68,69 @@ module JavaBuildpack::Jre
6468 end
6569
6670 it 'adds the JAVA_HOME to java_home' do
67- JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
68-
69- java_home = ''
70- OpenJdk . new (
71- :app_dir => '/application-directory' ,
72- :java_home => java_home ,
73- :java_opts => [ ] ,
74- :configuration => { }
75- )
71+ Dir . mktmpdir do |root |
72+ JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
7673
77- expect ( java_home ) . to eq ( '.java' )
74+ java_home = ''
75+ OpenJdk . new (
76+ :app_dir => '/application-directory' ,
77+ :java_home => java_home ,
78+ :java_opts => [ ] ,
79+ :configuration => { } ,
80+ :diagnostics => { :directory => root }
81+ )
82+
83+ expect ( java_home ) . to eq ( '.java' )
84+ end
7885 end
7986
8087 it 'should fail when ConfiguredItem.find_item fails' do
81- JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_raise ( 'test error' )
82- expect { OpenJdk . new (
83- :app_dir => '' ,
84- :java_home => '' ,
85- :java_opts => [ ] ,
86- :configuration => { }
87- ) . detect } . to raise_error ( /OpenJDK\ JRE\ error:\ test\ error/ )
88+ Dir . mktmpdir do |root |
89+ JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_raise ( 'test error' )
90+ expect { OpenJdk . new (
91+ :app_dir => '' ,
92+ :java_home => '' ,
93+ :java_opts => [ ] ,
94+ :configuration => { } ,
95+ :diagnostics => { :directory => root }
96+ ) . detect } . to raise_error ( /OpenJDK\ JRE\ error:\ test\ error/ )
97+ end
8898 end
8999
90100 it 'should add memory options to java_opts' do
91- JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
92- MemoryHeuristicsOpenJDKPre8 . stub ( :new ) . and_return ( memory_heuristic )
93-
94- java_opts = [ ]
95- OpenJdk . new (
96- :app_dir => '/application-directory' ,
97- :java_home => '' ,
98- :java_opts => java_opts ,
99- :configuration => { }
100- ) . release
101-
102- expect ( java_opts ) . to include ( 'opt-1' )
103- expect ( java_opts ) . to include ( 'opt-2' )
101+ Dir . mktmpdir do |root |
102+ JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
103+ MemoryHeuristicsOpenJDKPre8 . stub ( :new ) . and_return ( memory_heuristic )
104+
105+ java_opts = [ ]
106+ OpenJdk . new (
107+ :app_dir => '/application-directory' ,
108+ :java_home => '' ,
109+ :java_opts => java_opts ,
110+ :configuration => { } ,
111+ :diagnostics => { :directory => root }
112+ ) . release
113+
114+ expect ( java_opts ) . to include ( 'opt-1' )
115+ expect ( java_opts ) . to include ( 'opt-2' )
116+ end
104117 end
105118
106119 it 'adds OnOutOfMemoryError to java_opts' do
107- JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
108-
109- java_opts = [ ]
110- OpenJdk . new (
111- :app_dir => '' ,
112- :java_home => '' ,
113- :java_opts => java_opts ,
114- :configuration => { }
115- ) . release
120+ Dir . mktmpdir do |root |
121+ JavaBuildpack ::Repository ::ConfiguredItem . stub ( :find_item ) . and_return ( DETAILS_PRE_8 )
116122
117- expect ( java_opts . join ( ' ' ) ) . to match ( /-XX:OnOutOfMemoryError='kill -9 %p'/ )
123+ java_opts = [ ]
124+ OpenJdk . new (
125+ :app_dir => '' ,
126+ :java_home => '' ,
127+ :java_opts => java_opts ,
128+ :configuration => { } ,
129+ :diagnostics => { :directory => root }
130+ ) . release
131+
132+ expect ( java_opts . join ( ' ' ) ) . to match ( /-XX:OnOutOfMemoryError=#{ root } \/ killjava/ )
133+ end
118134 end
119135
120136 end
0 commit comments