Produced by Araxis Merge on 3/13/2019 2:49:38 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\AraxisMergeCompare\Pri_un\DSM\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_addDNSRecordTest.java | Tue Mar 12 22:01:54 2019 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\DSM-scrubbed\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_addDNSRecordTest.java | Wed Mar 13 02:10:20 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 10 | 736 |
| Changed | 9 | 18 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package or g.nhind.co nfig.rest. impl; | |
| 2 | ||
| 3 | import sta tic org.mo ckito.Matc hers.any; | |
| 4 | import sta tic org.mo ckito.Matc hers.eq; | |
| 5 | import sta tic org.mo ckito.Mock ito.doThro w; | |
| 6 | import sta tic org.mo ckito.Mock ito.mock; | |
| 7 | import sta tic org.mo ckito.Mock ito.when; | |
| 8 | ||
| 9 | import jav a.util.Arr ayList; | |
| 10 | import jav a.util.Arr ays; | |
| 11 | import jav a.util.Col lection; | |
| 12 | import jav a.util.Ite rator; | |
| 13 | ||
| 14 | import org .junit.Tes t; | |
| 15 | import org .nhind.con fig.client .ConfigSer viceRunner ; | |
| 16 | import org .nhind.con fig.rest.D NSService; | |
| 17 | import org .nhind.con fig.testba se.BaseTes tPlan; | |
| 18 | import org .nhind.con fig.testba se.TestUti ls; | |
| 19 | ||
| 20 | import org .nhindirec t.common.r est.except ions.Servi ceExceptio n; | |
| 21 | import org .nhindirec t.common.r est.except ions.Servi ceMethodEx ception; | |
| 22 | ||
| 23 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 24 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 25 | import org .nhindirec t.config.r esources.D NSResource ; | |
| 26 | ||
| 27 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 28 | import org .xbill.DNS .Type; | |
| 29 | ||
| 30 | public cla ss Default DNSService _addDNSRec ordTest | |
| 31 | { | |
| 32 | protected DNSDao dn sDao; | |
| 33 | ||
| 34 | stat ic DNSServ ice resour ce; | |
| 35 | ||
| 36 | abst ract class TestPlan extends Ba seTestPlan | |
| 37 | { | |
| 38 | protec ted Collec tion<DNSRe cord> reco rds; | |
| 39 | ||
| 40 | @Overr ide | |
| 41 | protec ted void s etupMocks( ) | |
| 42 | { | |
| 43 | try | |
| 44 | { | |
| 45 | dnsDao = ( DNSDao)Con figService Runner.get SpringAppl icationCon text().get Bean("DNSD aoImpl"); | |
| 46 | ||
| 47 | resource = (DNS Service)Ba seTestPlan .getServic e(ConfigSe rviceRunne r.getRestA PIBaseURL( ), DNS_SER VICE); | |
| 48 | ||
| 49 | } | |
| 50 | catch (T hrowable t ) | |
| 51 | { | |
| 52 | throw new RuntimeExc eption(t); | |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | @Overr ide | |
| 57 | protec ted void t earDownMoc ks() | |
| 58 | { | |
| 59 | ||
| 60 | } | |
| 61 | protec ted abstra ct Collect ion<DNSRec ord> getDN SRecordsTo Add(); | |
| 62 | ||
| 63 | @Overr ide | |
| 64 | protec ted void p erformInne r() throws Exception | |
| 65 | { | |
| 66 | ||
| 67 | final Co llection<D NSRecord> recordsToA dd = getDN SRecordsTo Add(); | |
| 68 | ||
| 69 | for (DNS Record add Record : r ecordsToAd d) | |
| 70 | { | |
| 71 | try | |
| 72 | { | |
| 73 | re source.add DNSRecord( addRecord) ; | |
| 74 | } | |
| 75 | catch (Ser viceExcept ion e) | |
| 76 | { | |
| 77 | th row e; | |
| 78 | } | |
| 79 | } | |
| 80 | ||
| 81 | doAssert ions(); | |
| 82 | } | |
| 83 | ||
| 84 | protec ted void d oAssertion s() throws Exception | |
| 85 | { | |
| 86 | ||
| 87 | } | |
| 88 | } | |
| 89 | ||
| 90 | @Tes t | |
| 91 | publ ic void te stAddRecor ds_assertR ecordsAdde d() throws Exception | |
| 92 | { | |
| 93 | new Te stPlan() | |
| 94 | { | |
| 95 | protecte d Collecti on<DNSReco rd> record s; | |
| 96 | ||
| 97 | @Overrid e | |
| 98 | protecte d Collecti on<DNSReco rd> getDNS RecordsToA dd() | |
| 99 | { | |
| 100 | try | |
| 101 | { | |
| 102 | re cords = ne w ArrayLis t<DNSRecor d>(); | |
| 103 | ||
| 104 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com", 36 00, " IP "); | |
| 105 | re cords.add( record); | |
| 106 | ||
| 107 | ||
| 108 | record = D NSUtils.cr eateARecor d("myserve r.com", 36 00, " IP "); | |
| 109 | re cords.add( record); | |
| 110 | ||
| 111 | record = D NSUtils.cr eateARecor d("myserve r2.com", 3 600, " IP "); | |
| 112 | re cords.add( record); | |
| 113 | ||
| 114 | re cord = DNS Utils.crea teX509CERT Record("gm 2552@secur ehealthema il.com", 3 600, TestU tils.loadC ert("gm255 2.der")); | |
| 115 | re cords.add( record); | |
| 116 | ||
| 117 | record = D NSUtils.cr eateMXReco rd("myserv er.com", " IP ", 3600, 2 ); | |
| 118 | re cords.add( record); | |
| 119 | ||
| 120 | re turn recor ds; | |
| 121 | } | |
| 122 | catch (Exc eption e) | |
| 123 | { | |
| 124 | th row new Ru ntimeExcep tion (e); | |
| 125 | } | |
| 126 | } | |
| 127 | ||
| 128 | ||
| 129 | @Overrid e | |
| 130 | protecte d void doA ssertions( ) throws E xception | |
| 131 | { | |
| 132 | Collection <org.nhind irect.conf ig.store.D NSRecord> retrievedR ecords = d nsDao.get( Type.ANY); | |
| 133 | ||
| 134 | assertNotN ull(retrie vedRecords ); | |
| 135 | assertEqua ls(this.re cords.size (), retrie vedRecords .size()); | |
| 136 | ||
| 137 | final Iter ator<DNSRe cord> adde dRecordsIt er = this. records.it erator(); | |
| 138 | ||
| 139 | for (org.n hindirect. config.sto re.DNSReco rd retriev edRecord : retrieved Records) | |
| 140 | { | |
| 141 | fi nal DNSRec ord addedR ecord = ad dedRecords Iter.next( ); | |
| 142 | ||
| 143 | as sertEquals (addedReco rd.getDcla ss(), retr ievedRecor d.getDclas s()); | |
| 144 | as sertEquals (addedReco rd.getType (), retrie vedRecord. getType()) ; | |
| 145 | as sertTrue(A rrays.equa ls(addedRe cord.getDa ta(), retr ievedRecor d.getData( ))); | |
| 146 | as sertEquals (addedReco rd.getTtl( ), retriev edRecord.g etTtl()); | |
| 147 | as sertEquals (addedReco rd.getName (), retrie vedRecord. getName()) ; | |
| 148 | } | |
| 149 | ||
| 150 | } | |
| 151 | }.perf orm(); | |
| 152 | } | |
| 153 | ||
| 154 | @Tes t | |
| 155 | publ ic void te stAddRecor ds_noDotte dSuffix_as sertRecord sAdded() t hrows Exce ption | |
| 156 | { | |
| 157 | new Te stPlan() | |
| 158 | { | |
| 159 | protecte d Collecti on<DNSReco rd> record s; | |
| 160 | ||
| 161 | @Overrid e | |
| 162 | protecte d Collecti on<DNSReco rd> getDNS RecordsToA dd() | |
| 163 | { | |
| 164 | try | |
| 165 | { | |
| 166 | re cords = ne w ArrayLis t<DNSRecor d>(); | |
| 167 | ||
| 168 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", 3 600, " IP "); | |
| 169 | re cord.setNa me("myserv er.com"); | |
| 170 | re cords.add( record); | |
| 171 | ||
| 172 | re turn recor ds; | |
| 173 | } | |
| 174 | catch (Exc eption e) | |
| 175 | { | |
| 176 | th row new Ru ntimeExcep tion (e); | |
| 177 | } | |
| 178 | } | |
| 179 | ||
| 180 | ||
| 181 | @Overrid e | |
| 182 | protecte d void doA ssertions( ) throws E xception | |
| 183 | { | |
| 184 | Collection <org.nhind irect.conf ig.store.D NSRecord> retrievedR ecords = d nsDao.get( Type.ANY); | |
| 185 | ||
| 186 | assertNotN ull(retrie vedRecords ); | |
| 187 | assertEqua ls(this.re cords.size (), retrie vedRecords .size()); | |
| 188 | ||
| 189 | final Iter ator<DNSRe cord> adde dRecordsIt er = this. records.it erator(); | |
| 190 | ||
| 191 | for (org.n hindirect. config.sto re.DNSReco rd retriev edRecord : retrieved Records) | |
| 192 | { | |
| 193 | fi nal DNSRec ord addedR ecord = ad dedRecords Iter.next( ); | |
| 194 | ||
| 195 | as sertEquals (addedReco rd.getDcla ss(), retr ievedRecor d.getDclas s()); | |
| 196 | as sertEquals (addedReco rd.getType (), retrie vedRecord. getType()) ; | |
| 197 | as sertTrue(A rrays.equa ls(addedRe cord.getDa ta(), retr ievedRecor d.getData( ))); | |
| 198 | as sertEquals (addedReco rd.getTtl( ), retriev edRecord.g etTtl()); | |
| 199 | as sertEquals ("myserver .com.", re trievedRec ord.getNam e()); | |
| 200 | } | |
| 201 | ||
| 202 | } | |
| 203 | }.perf orm(); | |
| 204 | } | |
| 205 | ||
| 206 | @Tes t | |
| 207 | publ ic void te stAddRecor ds_addDupl icate_asse rtConflict () throws Exception | |
| 208 | { | |
| 209 | new Te stPlan() | |
| 210 | { | |
| 211 | protecte d Collecti on<DNSReco rd> record s; | |
| 212 | ||
| 213 | @Overrid e | |
| 214 | protecte d Collecti on<DNSReco rd> getDNS RecordsToA dd() | |
| 215 | { | |
| 216 | try | |
| 217 | { | |
| 218 | re cords = ne w ArrayLis t<DNSRecor d>(); | |
| 219 | ||
| 220 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", 3 600, " IP "); | |
| 221 | re cords.add( record); | |
| 222 | ||
| 223 | record = D NSUtils.cr eateARecor d("myserve r.com.", 3 600, " IP "); | |
| 224 | re cords.add( record); | |
| 225 | ||
| 226 | re turn recor ds; | |
| 227 | } | |
| 228 | catch (Exc eption e) | |
| 229 | { | |
| 230 | th row new Ru ntimeExcep tion (e); | |
| 231 | } | |
| 232 | } | |
| 233 | ||
| 234 | ||
| 235 | @Overrid e | |
| 236 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 237 | { | |
| 238 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 239 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 240 | assertEqua ls(409, ex .getRespon seCode()); | |
| 241 | } | |
| 242 | }.perf orm(); | |
| 243 | } | |
| 244 | ||
| 245 | @Tes t | |
| 246 | publ ic void te stAddDNSRe cords_erro rInLookup_ assertServ iceError() throws Ex ception | |
| 247 | { | |
| 248 | new Te stPlan() | |
| 249 | { | |
| 250 | ||
| 251 | protecte d DNSResou rce dnsSer vice; | |
| 252 | ||
| 253 | @Overrid e | |
| 254 | protecte d void set upMocks() | |
| 255 | { | |
| 256 | try | |
| 257 | { | |
| 258 | su per.setupM ocks(); | |
| 259 | ||
| 260 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 261 | ||
| 262 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 263 | ||
| 264 | do Throw(new RuntimeExc eption()). when(mockD AO).get((S tring)any( ), eq(1)); | |
| 265 | ||
| 266 | dn sService.s etDNSDao(m ockDAO); | |
| 267 | } | |
| 268 | catch (Thr owable t) | |
| 269 | { | |
| 270 | th row new Ru ntimeExcep tion(t); | |
| 271 | } | |
| 272 | } | |
| 273 | ||
| 274 | @Overrid e | |
| 275 | protecte d void tea rDownMocks () | |
| 276 | { | |
| 277 | super.tear DownMocks( ); | |
| 278 | ||
| 279 | dnsService .setDNSDao (dnsDao); | |
| 280 | } | |
| 281 | ||
| 282 | @Overrid e | |
| 283 | protecte d Collecti on<DNSReco rd> getDNS RecordsToA dd() | |
| 284 | { | |
| 285 | try | |
| 286 | { | |
| 287 | Co llection<D NSRecord> records = new ArrayL ist<DNSRec ord>(); | |
| 288 | ||
| 289 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", 3 600, " IP "); | |
| 290 | re cords.add( record); | |
| 291 | ||
| 292 | re turn recor ds; | |
| 293 | } | |
| 294 | catch (Exc eption e) | |
| 295 | { | |
| 296 | th row new Ru ntimeExcep tion (e); | |
| 297 | } | |
| 298 | } | |
| 299 | ||
| 300 | @Overrid e | |
| 301 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 302 | { | |
| 303 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 304 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 305 | assertEqua ls(500, ex .getRespon seCode()); | |
| 306 | } | |
| 307 | }.perf orm(); | |
| 308 | } | |
| 309 | ||
| 310 | @Tes t | |
| 311 | publ ic void te stAddDNSRe cords_erro rInAdd_ass ertService Error() th rows Excep tion | |
| 312 | { | |
| 313 | new Te stPlan() | |
| 314 | { | |
| 315 | ||
| 316 | protecte d DNSResou rce dnsSer vice; | |
| 317 | ||
| 318 | @Suppres sWarnings( "unchecked ") | |
| 319 | @Overrid e | |
| 320 | protecte d void set upMocks() | |
| 321 | { | |
| 322 | try | |
| 323 | { | |
| 324 | su per.setupM ocks(); | |
| 325 | ||
| 326 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 327 | ||
| 328 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 329 | wh en(mockDAO .get((Stri ng)any(), eq(1))).th enReturn(n ew ArrayLi st<org.nhi ndirect.co nfig.store .DNSRecord >()); | |
| 330 | do Throw(new RuntimeExc eption()). when(mockD AO).add((C ollection< org.nhindi rect.confi g.store.DN SRecord>)a ny()); | |
| 331 | ||
| 332 | dn sService.s etDNSDao(m ockDAO); | |
| 333 | } | |
| 334 | catch (Thr owable t) | |
| 335 | { | |
| 336 | th row new Ru ntimeExcep tion(t); | |
| 337 | } | |
| 338 | } | |
| 339 | ||
| 340 | @Overrid e | |
| 341 | protecte d void tea rDownMocks () | |
| 342 | { | |
| 343 | super.tear DownMocks( ); | |
| 344 | ||
| 345 | dnsService .setDNSDao (dnsDao); | |
| 346 | } | |
| 347 | ||
| 348 | ||
| 349 | @Overrid e | |
| 350 | protecte d Collecti on<DNSReco rd> getDNS RecordsToA dd() | |
| 351 | { | |
| 352 | try | |
| 353 | { | |
| 354 | Co llection<D NSRecord> records = new ArrayL ist<DNSRec ord>(); | |
| 355 | ||
| 356 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", 3 600, " IP "); | |
| 357 | re cords.add( record); | |
| 358 | ||
| 359 | re turn recor ds; | |
| 360 | } | |
| 361 | catch (Exc eption e) | |
| 362 | { | |
| 363 | th row new Ru ntimeExcep tion (e); | |
| 364 | } | |
| 365 | } | |
| 366 | ||
| 367 | @Overrid e | |
| 368 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 369 | { | |
| 370 | assertTrue (exception instanceo f ServiceM ethodExcep tion); | |
| 371 | ServiceMet hodExcepti on ex = (S erviceMeth odExceptio n)exceptio n; | |
| 372 | assertEqua ls(500, ex .getRespon seCode()); | |
| 373 | } | |
| 374 | }.perf orm(); | |
| 375 | } | |
| 376 | ||
| 377 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.