@@ -224,7 +224,7 @@ def testDeleteModelAppDeployments(self):
224
224
yaml_exists = os .path .exists (yaml_result )
225
225
226
226
self .assertEqual (yaml_exists , True )
227
- self .assertEqual (len (stdout_result ), 1 )
227
+ self .assertEqual (len (stdout_result ), 0 )
228
228
229
229
self .assertEqual (model_dictionary .has_key ('appDeployments' ), True )
230
230
self .assertEqual (model_dictionary ['appDeployments' ].has_key ('Library' ), True )
@@ -244,6 +244,187 @@ def testDeleteModelAppDeployments(self):
244
244
245
245
self .assertEqual (return_code , 0 )
246
246
247
+ def testCompareModelFull2 (self ):
248
+ _method_name = 'testCompareModelFull2'
249
+ # This test for
250
+ # 1. Changing weblogic password
251
+ # 2. Changing RCU password
252
+ # 3. Deleting an application
253
+
254
+ _variables_file = self ._resources_dir + '/compare_model_model1.10.properties'
255
+ _new_model_file = self ._resources_dir + '/compare_model_model7.yaml'
256
+ _old_model_file = self ._resources_dir + '/compare_model_model6.yaml'
257
+ _temp_dir = os .path .join (tempfile .gettempdir (), _method_name )
258
+
259
+ if os .path .exists (_temp_dir ):
260
+ shutil .rmtree (_temp_dir )
261
+
262
+ os .mkdir (_temp_dir )
263
+
264
+ mw_home = os .environ ['MW_HOME' ]
265
+ args_map = {
266
+ '-oracle_home' : mw_home ,
267
+ '-variable_file' : _variables_file ,
268
+ '-output_dir' : _temp_dir ,
269
+ '-domain_type' : 'WLS' ,
270
+ '-trailing_arguments' : [ _new_model_file , _old_model_file ]
271
+ }
272
+
273
+ try :
274
+ model_context = ModelContext ('CompareModelTestCase' , args_map )
275
+ obj = ModelFileDiffer (_new_model_file , _old_model_file , model_context , _temp_dir )
276
+ return_code = obj .compare ()
277
+ self .assertEqual (return_code , 0 )
278
+
279
+ yaml_result = _temp_dir + os .sep + 'diffed_model.yaml'
280
+ json_result = _temp_dir + os .sep + 'diffed_model.json'
281
+ stdout_result = obj .get_compare_msgs ()
282
+ model_dictionary = FileToPython (yaml_result ).parse ()
283
+ yaml_exists = os .path .exists (yaml_result )
284
+ json_exists = os .path .exists (json_result )
285
+
286
+ self .assertEqual (yaml_exists , True )
287
+ self .assertEqual (json_exists , True )
288
+ self .assertEqual (len (stdout_result ), 0 )
289
+
290
+ self .assertEqual (model_dictionary .has_key ('domainInfo' ), True )
291
+ self .assertEqual (model_dictionary ['domainInfo' ].has_key ('AdminPassword' ), True )
292
+ self .assertEqual (model_dictionary ['domainInfo' ]['AdminPassword' ], 'welcome2' )
293
+ self .assertEqual (model_dictionary ['domainInfo' ].has_key ('AdminUser' ), False )
294
+ self .assertEqual (model_dictionary ['domainInfo' ].has_key ('RCUDbInfo' ), True )
295
+ self .assertEqual (model_dictionary ['domainInfo' ]['RCUDbInfo' ].has_key ('rcu_admin_password' ), True )
296
+ self .assertEqual (len (model_dictionary ['domainInfo' ]['RCUDbInfo' ]), 1 )
297
+ self .assertEqual (len (model_dictionary ['domainInfo' ]), 2 )
298
+ self .assertEqual (model_dictionary .has_key ('appDeployments' ), True )
299
+ self .assertEqual (model_dictionary ['appDeployments' ].has_key ('Application' ), True )
300
+ self .assertEqual (model_dictionary ['appDeployments' ]['Application' ].has_key ('!yourear' ), True )
301
+ self .assertEqual (len (model_dictionary ['appDeployments' ]['Application' ]), 1 )
302
+
303
+
304
+ except (CompareException , PyWLSTException ), te :
305
+ return_code = 2
306
+ self ._logger .severe ('WLSDPLY-05709' ,
307
+ te .getLocalizedMessage (), error = te ,
308
+ class_name = self ._program_name , method_name = _method_name )
309
+
310
+ if os .path .exists (_temp_dir ):
311
+ shutil .rmtree (_temp_dir )
312
+
313
+ self .assertEqual (return_code , 0 )
314
+
315
+ def _testCompareModelFull3 (self ):
316
+ _method_name = 'testCompareModelFull3'
317
+ # This test for
318
+ # 1. Changing MailSessionProperty
319
+ # 2. Changing ODL HandlerDefaults
320
+ # 3. Changing ODL Handler property
321
+ # 4. Changing ODL Logger attributes
322
+
323
+ _variables_file = self ._resources_dir + '/compare_model_model1.10.properties'
324
+ _new_model_file = self ._resources_dir + '/compare_model_model7.yaml'
325
+ _old_model_file = self ._resources_dir + '/compare_model_model6.yaml'
326
+ _temp_dir = os .path .join (tempfile .gettempdir (), _method_name )
327
+
328
+ if os .path .exists (_temp_dir ):
329
+ shutil .rmtree (_temp_dir )
330
+
331
+ os .mkdir (_temp_dir )
332
+
333
+ mw_home = os .environ ['MW_HOME' ]
334
+ args_map = {
335
+ '-oracle_home' : mw_home ,
336
+ '-variable_file' : _variables_file ,
337
+ '-output_dir' : _temp_dir ,
338
+ '-domain_type' : 'WLS' ,
339
+ '-trailing_arguments' : [ _new_model_file , _old_model_file ]
340
+ }
341
+
342
+ try :
343
+ model_context = ModelContext ('CompareModelTestCase' , args_map )
344
+ obj = ModelFileDiffer (_new_model_file , _old_model_file , model_context , _temp_dir )
345
+ return_code = obj .compare ()
346
+ self .assertEqual (return_code , 0 )
347
+
348
+ yaml_result = _temp_dir + os .sep + 'diffed_model.yaml'
349
+ json_result = _temp_dir + os .sep + 'diffed_model.json'
350
+ stdout_result = obj .get_compare_msgs ()
351
+ model_dictionary = FileToPython (yaml_result ).parse ()
352
+ yaml_exists = os .path .exists (yaml_result )
353
+ json_exists = os .path .exists (json_result )
354
+
355
+ self .assertEqual (yaml_exists , True )
356
+ self .assertEqual (json_exists , True )
357
+ self .assertEqual (len (stdout_result ), 0 )
358
+
359
+ self .assertEqual (model_dictionary .has_key ('resources' ), True )
360
+ self .assertEqual (model_dictionary ['resources' ].has_key ('MailSession' ), True )
361
+ self .assertEqual (model_dictionary ['resources' ]['MailSession' ].has_key ('MyMailSession' ), True )
362
+ self .assertEqual (model_dictionary ['resources' ]['MailSession' ]['MyMailSession' ].has_key ('mail.imap.port' ),
363
+ True )
364
+ self .assertEqual (model_dictionary ['resources' ]['MailSession' ]['MyMailSession' ]['mail.imap.port' ], 993 )
365
+ self .assertEqual (len (model_dictionary ['resources' ]['MailSession' ]['MyMailSession' ]['mail.imap.port' ]), 1 )
366
+
367
+ self .assertEqual (model_dictionary ['resources' ].has_key ('ODLConfiguration' ), True )
368
+ self .assertEqual (model_dictionary ['resources' ]['ODLConfiguration' ].has_key ('config' ), True )
369
+ self .assertEqual (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ].has_key ('HandlerDefaults' ),
370
+ True )
371
+ self .assertEqual (
372
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['HandlerDefaults' ].has_key ('maxFileSize' ),
373
+ True )
374
+ self .assertEqual (
375
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['HandlerDefaults' ]['maxFileSize' ],
376
+ 14857620 )
377
+
378
+ self .assertEqual (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ].has_key ('Handler' ),
379
+ True )
380
+ self .assertEqual (
381
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Handler' ].has_key ('odl-handler' ),
382
+ True )
383
+ self .assertEqual (
384
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Handler' ]['odl-handler' ]
385
+ .has_key ('Properties' ), True )
386
+ self .assertEqual (
387
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Handler' ]['odl-handler' ]['Properties' ]
388
+ .has_key ('maxFileSize' ), True )
389
+ self .assertEqual (
390
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Handler' ]['odl-handler' ]
391
+ ['Properties' ]['maxFileSize' ], 14857620 )
392
+
393
+
394
+ self .assertEqual (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ].has_key ('Logger' ),
395
+ True )
396
+ self .assertEqual (
397
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Logger' ]
398
+ .has_key ('oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager' ),
399
+ True )
400
+ self .assertEqual (
401
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Logger' ]
402
+ ['oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager' ]
403
+ .has_key ('Level' ), True )
404
+ self .assertEqual (
405
+ model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Logger' ]
406
+ ['oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager' ]['Level' ],
407
+ 'TRACE:16' )
408
+ self .assertEqual (
409
+ len (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]), 3 )
410
+
411
+ self .assertEqual (
412
+ len (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['Logger' ]), 1 )
413
+
414
+ self .assertEqual (
415
+ len (model_dictionary ['resources' ]['ODLConfiguration' ]['config' ]['HandlerDefaults' ]), 1 )
416
+
417
+ except (CompareException , PyWLSTException ), te :
418
+ return_code = 2
419
+ self ._logger .severe ('WLSDPLY-05709' ,
420
+ te .getLocalizedMessage (), error = te ,
421
+ class_name = self ._program_name , method_name = _method_name )
422
+
423
+ if os .path .exists (_temp_dir ):
424
+ shutil .rmtree (_temp_dir )
425
+
426
+ self .assertEqual (return_code , 0 )
427
+
247
428
248
429
if __name__ == '__main__' :
249
430
unittest .main ()
0 commit comments