@@ -24,35 +24,35 @@ module JavaBuildpack::Container
2424
2525 it 'should detect with main class configuration' do
2626 detected = Main . new (
27- app_dir : 'spec/fixtures/container_none' ,
28- configuration : { 'java_main_class' => 'test-java-main-class' }
27+ app_dir : 'spec/fixtures/container_none' ,
28+ configuration : { 'java_main_class' => 'test-java-main-class' }
2929 ) . detect
3030
3131 expect ( detected ) . to be_true
3232 end
3333
3434 it 'should detect with main class manifest entry' do
3535 detected = Main . new (
36- app_dir : 'spec/fixtures/container_main' ,
37- configuration : { }
36+ app_dir : 'spec/fixtures/container_main' ,
37+ configuration : { }
3838 ) . detect
3939
4040 expect ( detected ) . to be_true
4141 end
4242
4343 it 'should not detect without main class manifest entry' do
4444 detected = Main . new (
45- app_dir : 'spec/fixtures/container_main_no_main_class' ,
46- configuration : { }
45+ app_dir : 'spec/fixtures/container_main_no_main_class' ,
46+ configuration : { }
4747 ) . detect
4848
4949 expect ( detected ) . to be_false
5050 end
5151
5252 it 'should not detect without manifest' do
5353 detected = Main . new (
54- app_dir : 'spec/fixtures/container_main_none' ,
55- configuration : { }
54+ app_dir : 'spec/fixtures/container_main_none' ,
55+ configuration : { }
5656 ) . detect
5757
5858 expect ( detected ) . to be_false
@@ -64,11 +64,11 @@ module JavaBuildpack::Container
6464 Dir . mkdir lib_directory
6565
6666 command = Main . new (
67- app_dir : root ,
68- java_home : 'test-java-home' ,
69- java_opts : %w( test-opt-2 test-opt-1 ) ,
70- lib_directory : lib_directory ,
71- configuration : { 'java_main_class' => 'test-java-main-class' }
67+ app_dir : root ,
68+ java_home : 'test-java-home' ,
69+ java_opts : %w( test-opt-2 test-opt-1 ) ,
70+ lib_directory : lib_directory ,
71+ configuration : { 'java_main_class' => 'test-java-main-class' }
7272 ) . release
7373
7474 expect ( command ) . to eq ( 'test-java-home/bin/java -cp . test-opt-1 test-opt-2 test-java-main-class' )
@@ -81,11 +81,11 @@ module JavaBuildpack::Container
8181 Dir . mkdir lib_directory
8282
8383 command = Main . new (
84- app_dir : 'spec/fixtures/container_main' ,
85- java_home : 'test-java-home' ,
86- java_opts : [ ] ,
87- lib_directory : lib_directory ,
88- configuration : { }
84+ app_dir : 'spec/fixtures/container_main' ,
85+ java_home : 'test-java-home' ,
86+ java_opts : [ ] ,
87+ lib_directory : lib_directory ,
88+ configuration : { }
8989 ) . release
9090
9191 expect ( command ) . to eq ( 'test-java-home/bin/java -cp .:alpha.jar:bravo.jar:charlie.jar test-main-class' )
@@ -98,14 +98,14 @@ module JavaBuildpack::Container
9898 Dir . mkdir lib_directory
9999
100100 command = Main . new (
101- app_dir : root ,
102- java_home : 'test-java-home' ,
103- java_opts : [ ] ,
104- lib_directory : lib_directory ,
105- configuration : {
106- 'java_main_class' => 'test-java-main-class' ,
107- 'arguments' => 'some arguments'
108- }
101+ app_dir : root ,
102+ java_home : 'test-java-home' ,
103+ java_opts : [ ] ,
104+ lib_directory : lib_directory ,
105+ configuration : {
106+ 'java_main_class' => 'test-java-main-class' ,
107+ 'arguments' => 'some arguments'
108+ }
109109 ) . release
110110
111111 expect ( command ) . to eq ( 'test-java-home/bin/java -cp . test-java-main-class some arguments' )
@@ -120,16 +120,78 @@ module JavaBuildpack::Container
120120 Dir [ 'spec/fixtures/additional_libs/*' ] . each { |file | system "cp #{ file } #{ lib_directory } " }
121121
122122 command = Main . new (
123- app_dir : root ,
123+ app_dir : root ,
124+ java_home : 'test-java-home' ,
125+ java_opts : [ ] ,
126+ lib_directory : lib_directory ,
127+ configuration : { 'java_main_class' => 'test-java-main-class' }
128+ ) . release
129+
130+ expect ( command ) . to eq ( 'test-java-home/bin/java -cp .:.lib/test-jar-1.jar:.lib/test-jar-2.jar test-java-main-class' )
131+ end
132+
133+ end
134+
135+ it 'should release Spring boot applications with a JarLauncher in the MANIFEST.MF by specifying a port' do
136+ command = Main . new (
137+ app_dir : 'spec/fixtures/container_main_spring_boot_jar_launcher' ,
124138 java_home : 'test-java-home' ,
125139 java_opts : [ ] ,
126- lib_directory : lib_directory ,
127- configuration : { 'java_main_class' => 'test-java-main-class' }
140+ configuration : { }
141+ ) . release
142+
143+ expect ( command ) . to eq ( 'test-java-home/bin/java -cp . org.springframework.boot.loader.JarLauncher --server.port=$PORT' )
144+ end
145+
146+ it 'should release Spring boot applications with a WarLauncher in the MANIFEST.MF by specifying a port' do
147+ command = Main . new (
148+ app_dir : 'spec/fixtures/container_main_spring_boot_war_launcher' ,
149+ java_home : 'test-java-home' ,
150+ java_opts : [ ] ,
151+ configuration : { }
152+ ) . release
153+
154+ expect ( command ) . to eq ( 'test-java-home/bin/java -cp . org.springframework.boot.loader.WarLauncher --server.port=$PORT' )
155+ end
156+
157+ it 'should release Spring boot applications with a JarLauncher in the configuration by specifying a port' do
158+ Dir . mktmpdir do |root |
159+ lib_directory = File . join ( root , '.lib' )
160+ Dir . mkdir lib_directory
161+
162+ command = Main . new (
163+ app_dir : root ,
164+ java_home : 'test-java-home' ,
165+ java_opts : [ ] ,
166+ lib_directory : lib_directory ,
167+ configuration : {
168+ 'java_main_class' => 'org.springframework.boot.loader.JarLauncher' ,
169+ 'arguments' => 'some arguments'
170+ }
128171 ) . release
129172
130- expect ( command ) . to eq ( 'test-java-home/bin/java -cp .:.lib/test-jar-1.jar:.lib/test-jar-2.jar test-java-main-class ' )
173+ expect ( command ) . to eq ( 'test-java-home/bin/java -cp . org.springframework.boot.loader.JarLauncher some arguments --server.port=$PORT ' )
131174 end
175+ end
132176
177+ it 'should release Spring boot applications with a WarLauncher in the configuration by specifying a port' do
178+ Dir . mktmpdir do |root |
179+ lib_directory = File . join ( root , '.lib' )
180+ Dir . mkdir lib_directory
181+
182+ command = Main . new (
183+ app_dir : root ,
184+ java_home : 'test-java-home' ,
185+ java_opts : [ ] ,
186+ lib_directory : lib_directory ,
187+ configuration : {
188+ 'java_main_class' => 'org.springframework.boot.loader.WarLauncher' ,
189+ 'arguments' => 'some arguments'
190+ }
191+ ) . release
192+
193+ expect ( command ) . to eq ( 'test-java-home/bin/java -cp . org.springframework.boot.loader.WarLauncher some arguments --server.port=$PORT' )
194+ end
133195 end
134196
135197 end
0 commit comments