|
18 | 18 | require 'component_helper' |
19 | 19 | require 'java_buildpack/framework/java_opts' |
20 | 20 |
|
21 | | -describe JavaBuildpack::Framework::JavaOpts do |
| 21 | +describe JavaBuildpack::Framework::JavaOpts, :focus do |
22 | 22 | include_context 'component_helper' |
23 | 23 |
|
24 | 24 | context do |
25 | | - let(:configuration) { super().merge('java_opts' => '-Xmx1024M') } |
| 25 | + let(:configuration) { { 'java_opts' => '-Xmx1024M' } } |
26 | 26 |
|
27 | 27 | it 'should detect with java.opts configuration' do |
28 | 28 | expect(component.detect).to eq('java-opts') |
29 | 29 | end |
30 | 30 | end |
31 | 31 |
|
| 32 | + context do |
| 33 | + let(:configuration) { { 'from_environment' => true } } |
| 34 | + let(:environment) { { 'JAVA_OPTS' => '-Dalpha=bravo' } } |
| 35 | + |
| 36 | + it 'should detect with ENV and with from_environment configuration' do |
| 37 | + expect(component.detect).to eq('java-opts') |
| 38 | + end |
| 39 | + end |
| 40 | + |
| 41 | + context do |
| 42 | + let(:environment) { { 'JAVA_OPTS' => '-Dalpha=bravo' } } |
| 43 | + |
| 44 | + it 'should not detect with ENV and without from_environment configuration' do |
| 45 | + expect(component.detect).to be_nil |
| 46 | + end |
| 47 | + end |
| 48 | + |
32 | 49 | it 'should not detect without java_opts configuration' do |
33 | 50 | expect(component.detect).to be_nil |
34 | 51 | end |
35 | 52 |
|
36 | 53 | context do |
37 | 54 | let(:configuration) do |
38 | | - super().merge('java_opts' => '-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y ' \ |
39 | | - "-XX:OnOutOfMemoryError='kill -9 %p'") |
| 55 | + { 'java_opts' => '-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y ' \ |
| 56 | + "-XX:OnOutOfMemoryError='kill -9 %p'" } |
40 | 57 | end |
41 | 58 |
|
42 | 59 | it 'should add split java_opts to context' do |
|
50 | 67 | end |
51 | 68 |
|
52 | 69 | context do |
53 | | - let(:configuration) { super().merge('java_opts' => '-Xms1024M') } |
| 70 | + let(:configuration) { { 'java_opts' => '-Xms1024M' } } |
54 | 71 |
|
55 | 72 | it 'should raise an error if a -Xms is configured' do |
56 | 73 | expect { component.compile }.to raise_error(/-Xms/) |
57 | 74 | end |
58 | 75 | end |
59 | 76 |
|
60 | 77 | context do |
61 | | - let(:configuration) { super().merge('java_opts' => '-Xmx1024M') } |
| 78 | + let(:configuration) { { 'java_opts' => '-Xmx1024M' } } |
62 | 79 |
|
63 | 80 | it 'should raise an error if a -Xmx is configured' do |
64 | 81 | expect { component.compile }.to raise_error(/-Xmx/) |
65 | 82 | end |
66 | 83 | end |
67 | 84 |
|
68 | 85 | context do |
69 | | - let(:configuration) { super().merge('java_opts' => '-XX:MaxMetaspaceSize=128M') } |
| 86 | + let(:configuration) { { 'java_opts' => '-XX:MaxMetaspaceSize=128M' } } |
70 | 87 |
|
71 | 88 | it 'should raise an error if a -XX:MaxMetaspaceSize is configured' do |
72 | 89 | expect { component.compile }.to raise_error(/-XX:MaxMetaspaceSize/) |
73 | 90 | end |
74 | 91 | end |
75 | 92 |
|
76 | 93 | context do |
77 | | - let(:configuration) { super().merge('java_opts' => '-XX:MetaspaceSize=128M') } |
| 94 | + let(:configuration) { { 'java_opts' => '-XX:MetaspaceSize=128M' } } |
78 | 95 |
|
79 | 96 | it 'should raise an error if a -XX:MetaspaceSize is configured' do |
80 | 97 | expect { component.compile }.to raise_error(/-XX:MetaspaceSize/) |
81 | 98 | end |
82 | 99 | end |
83 | 100 |
|
84 | 101 | context do |
85 | | - let(:configuration) { super().merge('java_opts' => '-XX:MaxPermSize=128M') } |
| 102 | + let(:configuration) { { 'java_opts' => '-XX:MaxPermSize=128M' } } |
86 | 103 |
|
87 | 104 | it 'should raise an error if a -XX:MaxPermSize is configured' do |
88 | 105 | expect { component.compile }.to raise_error(/-XX:MaxPermSize/) |
89 | 106 | end |
90 | 107 | end |
91 | 108 |
|
92 | 109 | context do |
93 | | - let(:configuration) { super().merge('java_opts' => '-XX:PermSize=128M') } |
| 110 | + let(:configuration) { { 'java_opts' => '-XX:PermSize=128M' } } |
94 | 111 |
|
95 | 112 | it 'should raise an error if a -XX:PermSize is configured' do |
96 | 113 | expect { component.compile }.to raise_error(/-XX:PermSize/) |
97 | 114 | end |
98 | 115 | end |
99 | 116 |
|
100 | 117 | context do |
101 | | - let(:configuration) { super().merge('java_opts' => '-Xss1M') } |
| 118 | + let(:configuration) { { 'java_opts' => '-Xss1M' } } |
102 | 119 |
|
103 | 120 | it 'should raise an error if a -Xss is configured' do |
104 | 121 | expect { component.compile }.to raise_error(/-Xss/) |
105 | 122 | end |
106 | 123 | end |
107 | 124 |
|
| 125 | + context do |
| 126 | + let(:configuration) { { 'from_environment' => true } } |
| 127 | + let(:environment) { { 'JAVA_OPTS' => '-Dalpha=bravo' } } |
| 128 | + |
| 129 | + it 'should include values specified in ENV[JAVA_OPTS]' do |
| 130 | + component.release |
| 131 | + expect(java_opts).to include('-Dalpha=bravo') |
| 132 | + end |
| 133 | + end |
| 134 | + |
| 135 | + context do |
| 136 | + let(:environment) { { 'JAVA_OPTS' => '-Dalpha=bravo' } } |
| 137 | + |
| 138 | + it 'should not include values specified in ENV[JAVA_OPTS] without from_environment' do |
| 139 | + component.release |
| 140 | + expect(java_opts).not_to include('-Dalpha=bravo') |
| 141 | + end |
| 142 | + end |
| 143 | + |
108 | 144 | end |
0 commit comments