forked from cloudfoundry/java-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtomcat_spec.rb
More file actions
102 lines (79 loc) · 3.73 KB
/
Copy pathtomcat_spec.rb
File metadata and controls
102 lines (79 loc) · 3.73 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
# Encoding: utf-8
# Cloud Foundry Java Buildpack
# Copyright 2013-2015 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 'component_helper'
require 'fileutils'
require 'java_buildpack/container/tomcat'
require 'java_buildpack/container/tomcat/tomcat_insight_support'
require 'java_buildpack/container/tomcat/tomcat_instance'
require 'java_buildpack/container/tomcat/tomcat_lifecycle_support'
require 'java_buildpack/container/tomcat/tomcat_logging_support'
require 'java_buildpack/container/tomcat/tomcat_access_logging_support'
require 'java_buildpack/container/tomcat/tomcat_redis_store'
describe JavaBuildpack::Container::Tomcat do
include_context 'component_helper'
let(:component) { StubTomcat.new context }
let(:configuration) do
{ 'tomcat' => tomcat_configuration,
'lifecycle_support' => lifecycle_support_configuration,
'logging_support' => logging_support_configuration,
'access_logging_support' => access_logging_support_configuration,
'redis_store' => redis_store_configuration }
end
let(:tomcat_configuration) { double('tomcat-configuration') }
let(:lifecycle_support_configuration) { double('lifecycle-support-configuration') }
let(:logging_support_configuration) { double('logging-support-configuration') }
let(:access_logging_support_configuration) { double('logging-support-configuration') }
let(:redis_store_configuration) { double('redis-store-configuration') }
it 'detects WEB-INF',
app_fixture: 'container_tomcat' do
expect(component.supports?).to be
end
it 'does not detect when WEB-INF is absent',
app_fixture: 'container_main' do
expect(component.supports?).not_to be
end
it 'does not detect when WEB-INF is present in a Java main application',
app_fixture: 'container_main_with_web_inf' do
expect(component.supports?).not_to be
end
it 'creates submodules' do
expect(JavaBuildpack::Container::TomcatInstance)
.to receive(:new).with(sub_configuration_context(tomcat_configuration))
expect(JavaBuildpack::Container::TomcatLifecycleSupport)
.to receive(:new).with(sub_configuration_context(lifecycle_support_configuration))
expect(JavaBuildpack::Container::TomcatLoggingSupport)
.to receive(:new).with(sub_configuration_context(logging_support_configuration))
expect(JavaBuildpack::Container::TomcatAccessLoggingSupport)
.to receive(:new).with(sub_configuration_context(access_logging_support_configuration))
expect(JavaBuildpack::Container::TomcatRedisStore)
.to receive(:new).with(sub_configuration_context(redis_store_configuration))
expect(JavaBuildpack::Container::TomcatInsightSupport).to receive(:new).with(context)
component.sub_components context
end
it 'returns command' do
expect(component.command).to eq("#{java_home.as_env_var} JAVA_OPTS=\"test-opt-2 test-opt-1 -Dhttp.port=$PORT\" " \
'$PWD/.java-buildpack/tomcat/bin/catalina.sh run')
end
end
class StubTomcat < JavaBuildpack::Container::Tomcat
public :command, :sub_components, :supports?
end
def sub_configuration_context(configuration)
c = context.clone
c[:configuration] = configuration
c
end