MatrixBerryCore
ConfRepoMgrAdaptiveVersionedTC.m
Go to the documentation of this file.
1 classdef ConfRepoMgrAdaptiveVersionedTC < mxberry.conf.test.AConfRepoMgrVersionedTC
2  properties (Access=protected)
3  tcm
4  end
5  methods (Access=private)
6  function self=initData(self)
7  import mxberry.conf.test.*;
8  self.cm=self.factory.getInstance();
9  self.cm.removeAll();
10  clearStorageContent(self.cm);
11  %
12  self.tcm=self.cm.getTemplateRepo();
13  self.tcm.removeAll();
14  clearStorageContent(self.tcm);
15  %
16  self.cm=self.factory.getInstance();
17  self.tcm=self.cm.getTemplateRepo();
18  %
19  SConfA=struct('confName','testConfA','alpha',0,'beta',0);
20  SConfB=struct('confName','testConfB','alpha',11,'beta',11);
21  %
22  self.tcm.putConf('testConfA',SConfA,0);
23  self.tcm.putConf('testConfB',SConfB,0);
24  function clearStorageContent(cm)
25  import mxberry.core.throwerror;
26  storageRoot=cm.getStorageLocationRoot();
27  if mxberry.io.isdir(storageRoot)
28  [indOk,msgStr]=mxberry.io.rmdir(...
29  cm.getStorageLocationRoot(),'s');
30  if indOk~=1
31  throwerror('wrongStatus',...
32  'deletion of directory %s has failed :%s',...
33  storageRoot,msgStr);
34  end
35  mxberry.io.mkdir(storageRoot);
36  end
37  end
38  end
39  end
40  methods
41  function self = ConfRepoMgrAdaptiveVersionedTC(varargin)
42  self = self@mxberry.conf.test.AConfRepoMgrVersionedTC(varargin{:});
43  end
44  end
45  properties (MethodSetupParameter)
46  factoryParam=struct('adaptivever',...
47  mxberry.conf.test.ConfRepoManagerFactory('adaptivever'));
48  end
49  methods (TestMethodSetup)
50  function self = setUp(self,factoryParam)
51  self.factory=factoryParam;
52  self=self.initData();
53  end
54  end
55  methods (Test)
56  function self=test_updateAll(self)
57  self.cm.updateAll();
58  self.aux_checkUpdateAll(self.cm);
59  self.aux_checkUpdateAll(self.tcm);
60  %
61  end
62  function testUpdateAllBranches(self)
63  curBranchKey=self.cm.getStorageBranchKey();
64  isOk=isequal({curBranchKey},self.cm.getBranchKeyList());
65  self.verifyTrue(isOk);
66  otherBranchKey=[curBranchKey,'_2'];
67  templateBranchKey=self.cm.getTemplateBranchKey();
68  storageRootDir=self.cm.getStorageLocationRoot();
69  [isSuccess,msgStr]=copyfile([storageRootDir,filesep,...
70  templateBranchKey],...
71  [storageRootDir,filesep,otherBranchKey]);
72  [isSuccess,msgStr]=copyfile([storageRootDir,filesep,...
73  templateBranchKey],...
74  [storageRootDir,filesep,curBranchKey]);
75  %
76  check({curBranchKey,otherBranchKey});
77  check({curBranchKey,otherBranchKey},false);
78  %
79  check({templateBranchKey,curBranchKey,otherBranchKey},true);
80  %
81  branchKeyList={templateBranchKey,curBranchKey,otherBranchKey};
82  nBranches=numel(branchKeyList);
83  %
84  self.cm.updateAll();
85  checkMaster([true,true,false]);
86  self.cm.updateAll(true);
87  checkMaster([true,true,true]);
88  %
89  function checkMaster(isOkExpVec)
90  for iBranch=1:nBranches
91  curBranchKey=branchKeyList{iBranch};
92  cm=self.factory.getInstance('currentBranchKey',...
93  curBranchKey);
94  self.aux_checkUpdateAll(cm,isOkExpVec(iBranch));
95  %
96  end
97  end
98  %
99  function check(branchList,varargin)
100  self.verifyEqual(isSuccess,true,msgStr);
101  isOk=isequal(sort(branchList),...
102  sort(self.cm.getBranchKeyList(varargin{:})));
103  self.verifyTrue(isOk);
104  end
105  end
106  function self=test_update(self)
107  self.cm.deployConfTemplate('testConfA');
108  self.cm.updateConfTemplate('testConfA');
109  [SConf,confVersion,metaData]=self.tcm.getConf('testConfB');
110  self.cm.putConf('testConfB',SConf,confVersion,metaData);
111  %
112  self.aux_checkUpdate(self.cm);
113  self.aux_checkUpdate(self.tcm);
114  end
115  end
116 end
function filesep()
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function mkdir(in dirName)
MKDIR creates a directory recursively.
function rmdir(in dirName, in sFlag)
RMDIR removes a directory (optionally recursively)
function isdir(in dirName, in isJavaBased)
ISDIR returns true if a specified name corresponds to an existing directory.
function copyfile(in srcName, in dstName)
COPYFILE is a simplified version of the built-in function that supports long file paths on Windows (>...