|
| 1 | +# Encoding: utf-8 |
| 2 | +# Cloud Foundry Java Buildpack |
| 3 | +# Copyright 2013-2015 the original author or authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +require 'spec_helper' |
| 18 | +require 'component_helper' |
| 19 | +require 'java_buildpack/framework/debug' |
| 20 | + |
| 21 | +describe JavaBuildpack::Framework::Debug do |
| 22 | + include_context 'component_helper' |
| 23 | + |
| 24 | + it 'does not detect if not enabled' do |
| 25 | + expect(component.detect).to be_nil |
| 26 | + end |
| 27 | + |
| 28 | + context do |
| 29 | + let(:configuration) { { 'enabled' => true } } |
| 30 | + |
| 31 | + it 'detects when enabled' do |
| 32 | + expect(component.detect).to eq('debug') |
| 33 | + end |
| 34 | + |
| 35 | + it 'uses 8000 as the default port' do |
| 36 | + component.release |
| 37 | + expect(java_opts).to include('-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n') |
| 38 | + end |
| 39 | + |
| 40 | + it 'does not suspend by default' do |
| 41 | + component.release |
| 42 | + expect(java_opts).to include('-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n') |
| 43 | + end |
| 44 | + end |
| 45 | + |
| 46 | + context do |
| 47 | + let(:configuration) { { 'enabled' => true, 'port' => 8001 } } |
| 48 | + |
| 49 | + it 'uses configured port' do |
| 50 | + component.release |
| 51 | + expect(java_opts).to include('-agentlib:jdwp=transport=dt_socket,server=y,address=8001,suspend=n') |
| 52 | + end |
| 53 | + end |
| 54 | + |
| 55 | + context do |
| 56 | + let(:configuration) { { 'enabled' => true, 'suspend' => true } } |
| 57 | + |
| 58 | + it 'uses configured suspend' do |
| 59 | + component.release |
| 60 | + expect(java_opts).to include('-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y') |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | +end |
0 commit comments