forked from cloudfoundry/java-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_spec.rb
More file actions
111 lines (82 loc) · 3.39 KB
/
base_spec.rb
File metadata and controls
111 lines (82 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# frozen_string_literal: true
# Cloud Foundry Java Buildpack
# Copyright 2013-2018 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'spec_helper'
require 'droplet_helper'
require 'fileutils'
require 'java_buildpack/util/play/base'
describe JavaBuildpack::Util::Play::Base do
include_context 'with droplet help'
let(:play) { described_class.new(droplet) }
it 'does not support with no start script' do
allow(play).to receive(:start_script).and_return nil
expect(play.supports?).not_to be
end
it 'does not support with a non-existent start script' do
allow(play).to receive(:start_script).and_return(droplet.root + 'bin/start')
expect(play.supports?).not_to be
end
it 'does not support with no play JAR' do
allow(play).to receive(:start_script).and_return(droplet.root + 'bin/start')
allow(play).to receive(:lib_dir).and_return(droplet.root + 'lib')
FileUtils.mkdir_p app_dir + 'bin'
FileUtils.touch app_dir + 'bin/start'
expect(play.supports?).not_to be
end
it 'raises error if augment_classpath method is unimplemented' do
expect { play.send(:augment_classpath) }.to raise_error "Method 'augment_classpath' must be defined"
end
it 'raises error if java_opts method is unimplemented' do
expect { play.send(:java_opts) }.to raise_error "Method 'java_opts' must be defined"
end
it 'raises error if lib_dir method is unimplemented' do
expect { play.send(:lib_dir) }.to raise_error "Method 'lib_dir' must be defined"
end
it 'raises error if start_script method is unimplemented' do
expect { play.send(:start_script) }.to raise_error "Method 'start_script' must be defined"
end
context nil, app_fixture: 'container_play_2.2_staged' do
let(:lib_dir) { droplet.root + 'lib' }
let(:play_jar) { lib_dir + 'com.typesafe.play.play_2.10-2.2.0.jar' }
let(:start_script) { app_dir + 'bin/play-application' }
before do
allow(play).to receive(:augment_classpath)
allow(play).to receive(:lib_dir).and_return(lib_dir)
allow(play).to receive(:start_script).and_return(start_script)
end
it 'supports application' do
expect(play.supports?).to be
end
it 'returns a version' do
expect(play.version).to eq('2.2.0')
end
it 'sets the start script to be executable' do
expect(start_script).not_to be_executable
play.compile
expect(start_script).to be_executable
end
it 'determines whether or not certain JARs are present in the lib directory' do
expect(play.jar?(/so.*st.jar/)).to be
expect(play.jar?(/some.test.jar/)).to be
expect(play.jar?(/nosuch.jar/)).not_to be
end
it 'replaces the bootstrap class' do
play.compile
content = start_script.read
expect(content).not_to match(/play.core.server.NettyServer/)
expect(content).to match(/org.cloudfoundry.reconfiguration.play.Bootstrap/)
end
end
end