2
2
Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3
3
The Universal Permissive License (UPL), Version 1.0
4
4
"""
5
- import os
6
5
import unittest
7
6
8
7
import wlsdeploy .util .variables as variables
@@ -156,10 +155,10 @@ def testWithSegmentInList(self):
156
155
variable_injector .REGEXP ] = [list_entry ]
157
156
actual = self ._helper .inject_variables (replacement_dict )
158
157
self ._compare_to_expected_dictionary (expected , actual )
159
- list = self ._model ['resources' ]['WLDFSystemResource' ]['MyWldfModule' ]['WLDFResource' ]['Harvester' ][
158
+ wldf_list = self ._model ['resources' ]['WLDFSystemResource' ]['MyWldfModule' ]['WLDFResource' ]['Harvester' ][
160
159
'HarvestedType' ]['weblogic.management.runtime.ServerRuntimeMBean' ]['HarvestedAttribute' ]
161
160
found = False
162
- for entry in list :
161
+ for entry in wldf_list :
163
162
if entry == '@@PROP:WLDFSystemResource.MyWldfModule.WLDFResource.Harvester.HarvestedType.' \
164
163
'weblogic.management.runtime.ServerRuntimeMBean.HarvestedAttribute@@' :
165
164
found = True
@@ -179,11 +178,10 @@ def testWithSegmentInStringInList(self):
179
178
variable_injector .REGEXP ] = [list_entry ]
180
179
actual = self ._helper .inject_variables (replacement_dict )
181
180
self ._compare_to_expected_dictionary (expected , actual )
182
- list = \
183
- self ._model ['resources' ]['WLDFSystemResource' ]['MyWldfModule' ]['WLDFResource' ]['Harvester' ]['HarvestedType' ][
184
- 'weblogic.management.runtime.ServerRuntimeMBean' ]['HarvestedInstance' ]
181
+ wldf_list = self ._model ['resources' ]['WLDFSystemResource' ]['MyWldfModule' ]['WLDFResource' ]['Harvester' ][
182
+ 'HarvestedType' ]['weblogic.management.runtime.ServerRuntimeMBean' ]['HarvestedInstance' ]
185
183
found = False
186
- for entry in list :
184
+ for entry in wldf_list :
187
185
if entry == 'com.bea:Name=@@PROP:WLDFSystemResource.MyWldfModule.WLDFResource.Harvester.HarvestedType.' \
188
186
'weblogic.management.runtime.ServerRuntimeMBean.HarvestedInstance--ManagedServer@@' \
189
187
',Type=ServerRuntime' :
@@ -246,7 +244,6 @@ def testWithVariableHelperKeywords(self):
246
244
self .assertEqual (self ._variable_file , variable_file_name )
247
245
self .assertEqual (True , inserted )
248
246
actual = variables .load_variables (self ._variable_file )
249
- print actual
250
247
self ._compare_to_expected_dictionary (expected , actual )
251
248
252
249
def testForceAttribute (self ):
@@ -260,6 +257,15 @@ def testForceAttribute(self):
260
257
actual = self ._helper .inject_variables (replacement_dict )
261
258
self ._compare_to_expected_dictionary (expected , actual )
262
259
260
+ def testForceAttributeWithTwoDefaults (self ):
261
+ expected = dict ()
262
+ expected ['JMSSystemResource.MyJmsModule.JmsResource.Template.JmsTemplate.MaximumMessageSize' ] = '0'
263
+ replacement_dict = dict ()
264
+ replacement_dict ['JMSSystemResource.JmsResource.Template.MaximumMessageSize' ] = dict ()
265
+ replacement_dict ['JMSSystemResource.JmsResource.Template.MaximumMessageSize' ][variable_injector .FORCE ] = True
266
+ actual = self ._helper .inject_variables (replacement_dict )
267
+ self ._compare_to_expected_dictionary (expected , actual )
268
+
263
269
def testReplaceVariableValueAttribute (self ):
264
270
expected = dict ()
265
271
expected [
@@ -272,6 +278,7 @@ def testReplaceVariableValueAttribute(self):
272
278
'JNDIProperty[java.naming.security.principal].Value' ][
273
279
variable_injector .VARIABLE_VALUE ] = 'k8s'
274
280
actual = self ._helper .inject_variables (replacement_dict )
281
+ print actual
275
282
self ._compare_to_expected_dictionary (expected , actual )
276
283
277
284
def testReplaceVariableValueSegmentInString (self ):
@@ -283,8 +290,8 @@ def testReplaceVariableValueSegmentInString(self):
283
290
list_entry = dict ()
284
291
list_entry [variable_injector .REGEXP_PATTERN ] = '(?<=HOST=)[\w.-]+(?=\))'
285
292
list_entry [variable_injector .REGEXP_SUFFIX ] = 'Host'
286
- replacement_dict ['JDBCSystemResource[Database2].JdbcResource.JDBCDriverParams.URL' ][variable_injector . REGEXP ] = [
287
- list_entry ]
293
+ replacement_dict ['JDBCSystemResource[Database2].JdbcResource.JDBCDriverParams.URL' ][
294
+ variable_injector . REGEXP ] = [ list_entry ]
288
295
replacement_dict ['JDBCSystemResource[Database2].JdbcResource.JDBCDriverParams.URL' ][
289
296
variable_injector .VARIABLE_VALUE ] = 'den00chv'
290
297
actual = self ._helper .inject_variables (replacement_dict )
0 commit comments