-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathjacoco_agent_spec.rb
More file actions
115 lines (94 loc) · 3.92 KB
/
jacoco_agent_spec.rb
File metadata and controls
115 lines (94 loc) · 3.92 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
112
113
114
115
# frozen_string_literal: true
# Cloud Foundry Java Buildpack
# Copyright 2013-2025 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 'java_buildpack/framework/jacoco_agent'
require 'java_buildpack/util/tokenized_version'
describe JavaBuildpack::Framework::JacocoAgent do
include_context 'with component help'
it 'does not detect without jacoco service' do
expect(component.detect).to be_nil
end
context do
before do
allow(services).to receive(:one_service?).with(/jacoco/, 'address').and_return(true)
end
let(:extended_credentials) do
{ 'address' => 'ext-address',
'output' => 'tcpserver',
'sessionid' => 'ext-session',
'excludes' => 'ex.*',
'includes' => 'in.*',
'port' => 7654,
'destfile' => 'custom.exec',
'append' => 'false',
'exclclassloader' => 'loader.*',
'inclbootstrapclasses' => 'true',
'inclnolocationclasses' => 'true',
'dumponexit' => 'false',
'classdumpdir' => 'dumpdir',
'jmx' => 'true' }
end
let(:extended_expected) do
[
'-javaagent:$PWD/.java-buildpack/jacoco_agent/jacocoagent.jar=address=ext-address',
'output=tcpserver',
'sessionid=ext-session',
'excludes=ex.*',
'includes=in.*',
'port=7654',
'destfile=custom.exec',
'append=false',
'exclclassloader=loader.*',
'inclbootstrapclasses=true',
'inclnolocationclasses=true',
'dumponexit=false',
'classdumpdir=dumpdir',
'jmx=true'
].join(',')
end
it 'detects with jacoco service' do
expect(component.detect).to eq("jacoco-agent=#{version}")
end
it 'downloads JaCoco agent JAR',
cache_fixture: 'stub-jacoco-agent.jar' do
component.compile
expect(sandbox + 'jacocoagent.jar').to exist
end
it 'updates JAVA_OPTS' do
allow(services).to receive(:find_service).and_return('credentials' => { 'address' => 'test-address' })
component.release
expect(java_opts).to include('-javaagent:$PWD/.java-buildpack/jacoco_agent/jacocoagent.jar=' \
'address=test-address,output=tcpclient,sessionid=$CF_INSTANCE_GUID')
end
it 'updates JAVA_OPTS with additional options' do
allow(services).to receive(:find_service).and_return('credentials' => { 'address' => 'test-address',
'output' => 'test-output',
'excludes' => 'test-excludes',
'includes' => 'test-includes',
'port' => 6300 })
component.release
expect(java_opts).to include('-javaagent:$PWD/.java-buildpack/jacoco_agent/jacocoagent.jar=' \
'address=test-address,output=test-output,sessionid=$CF_INSTANCE_GUID,' \
'excludes=test-excludes,includes=test-includes,port=6300')
end
it 'updates JAVA_OPTS with extended options' do
allow(services).to receive(:find_service).and_return('credentials' => extended_credentials)
component.release
expect(java_opts).to include(extended_expected)
end
end
end