Produced by Araxis Merge on 3/13/2019 2:49:39 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\dsm-config\dsm-config-service-jar\src\test\java\org\nhindirect\config\resources | DNSRecource_getDNSRecordsTest.java | Tue Mar 12 21:58:50 2019 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\DSM-scrubbed\Direct Implementation\java\dsm-config\dsm-config-service-jar\src\test\java\org\nhindirect\config\resources | DNSRecource_getDNSRecordsTest.java | Wed Mar 13 02:22:48 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 942 |
| Changed | 4 | 8 |
| 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.nhindire ct.config. resources; | |
| 2 | ||
| 3 | import sta tic org.mo ckito.Matc hers.any; | |
| 4 | import sta tic org.mo ckito.Mock ito.doThro w; | |
| 5 | import sta tic org.mo ckito.Mock ito.mock; | |
| 6 | ||
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Arr ays; | |
| 9 | import jav a.util.Col lection; | |
| 10 | import jav a.util.Ite rator; | |
| 11 | ||
| 12 | import jav ax.ws.rs.c ore.MediaT ype; | |
| 13 | ||
| 14 | import org .junit.Tes t; | |
| 15 | import org .nhindirec t.config.B aseTestPla n; | |
| 16 | import org .nhindirec t.config.C onfigServi ceRunner; | |
| 17 | import org .nhindirec t.config.T estUtils; | |
| 18 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 19 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 20 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 21 | import org .xbill.DNS .Type; | |
| 22 | ||
| 23 | import com .sun.jerse y.api.clie nt.Generic Type; | |
| 24 | import com .sun.jerse y.api.clie nt.Uniform InterfaceE xception; | |
| 25 | import com .sun.jerse y.api.clie nt.WebReso urce; | |
| 26 | ||
| 27 | public cla ss DNSReco urce_getDN SRecordsTe st | |
| 28 | { | |
| 29 | protected DNSDao dn sDao; | |
| 30 | ||
| 31 | static We bResource resource; | |
| 32 | ||
| 33 | abst ract class TestPlan extends Ba seTestPlan | |
| 34 | { | |
| 35 | protec ted Collec tion<DNSRe cord> reco rds; | |
| 36 | ||
| 37 | @Overr ide | |
| 38 | protec ted void s etupMocks( ) | |
| 39 | { | |
| 40 | try | |
| 41 | { | |
| 42 | dnsDao = ( DNSDao)Con figService Runner.get SpringAppl icationCon text().get Bean("dnsD ao"); | |
| 43 | ||
| 44 | resource = getR esource(Co nfigServic eRunner.ge tConfigSer viceURL()) ; | |
| 45 | } | |
| 46 | catch (T hrowable t ) | |
| 47 | { | |
| 48 | throw new RuntimeExc eption(t); | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| 52 | @Overr ide | |
| 53 | protec ted void t earDownMoc ks() | |
| 54 | { | |
| 55 | ||
| 56 | } | |
| 57 | ||
| 58 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 59 | { | |
| 60 | try | |
| 61 | { | |
| 62 | records = new ArrayL ist<DNSRec ord>(); | |
| 63 | ||
| 64 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com", 36 00, " IP "); | |
| 65 | records.ad d(record); | |
| 66 | ||
| 67 | ||
| 68 | record = D NSUtils.cr eateARecor d("myserve r.com", 36 00, " IP "); | |
| 69 | records.ad d(record); | |
| 70 | ||
| 71 | record = D NSUtils.cr eateARecor d("myserve r2.com", 3 600, " IP "); | |
| 72 | records.ad d(record); | |
| 73 | ||
| 74 | record = D NSUtils.cr eateX509CE RTRecord(" gm2552@sec urehealthe mail.com", 3600, Tes tUtils.loa dCert("gm2 552.der")) ; | |
| 75 | records.ad d(record); | |
| 76 | ||
| 77 | record = D NSUtils.cr eateMXReco rd("myserv er.com", " IP ", 3600, 2 ); | |
| 78 | records.ad d(record); | |
| 79 | ||
| 80 | return rec ords; | |
| 81 | } | |
| 82 | catch (E xception e ) | |
| 83 | { | |
| 84 | throw new RuntimeExc eption (e) ; | |
| 85 | } | |
| 86 | } | |
| 87 | ||
| 88 | protec ted abstra ct String getTypeToR etrieve(); | |
| 89 | ||
| 90 | protec ted abstra ct String getNameToR etrieve(); | |
| 91 | ||
| 92 | @Overr ide | |
| 93 | protec ted void p erformInne r() throws Exception | |
| 94 | { | |
| 95 | ||
| 96 | final Co llection<D NSRecord> recsToAdd = getDNSRe cordsToAdd (); | |
| 97 | ||
| 98 | if (recs ToAdd != n ull) | |
| 99 | { | |
| 100 | for (DNSRe cord addRe c : recsTo Add) | |
| 101 | { | |
| 102 | tr y | |
| 103 | { | |
| 104 | reso urce.path( "/api/dns" ).entity(a ddRec, Med iaType.APP LICATION_J SON).put(a ddRec); | |
| 105 | } | |
| 106 | ca tch (Unifo rmInterfac eException e) | |
| 107 | { | |
| 108 | thro w e; | |
| 109 | } | |
| 110 | } | |
| 111 | } | |
| 112 | ||
| 113 | try | |
| 114 | { | |
| 115 | WebResourc e getResou rce = reso urce.path( "/api/dns" ); | |
| 116 | ||
| 117 | if (getTyp eToRetriev e() != nul l) | |
| 118 | ge tResource = getResou rce.queryP aram("type ", getType ToRetrieve ()); | |
| 119 | ||
| 120 | if (getNam eToRetriev e() != nul l) | |
| 121 | ge tResource = getResou rce.queryP aram("name ", getName ToRetrieve ()); | |
| 122 | ||
| 123 | final Gene ricType<Ar rayList<DN SRecord>> genType = new Generi cType<Arra yList<DNSR ecord>>(){ }; | |
| 124 | final Coll ection<DNS Record> re cords = ge tResource. get(genTyp e); | |
| 125 | ||
| 126 | doAssertio ns(records ); | |
| 127 | } | |
| 128 | catch (U niformInte rfaceExcep tion e) | |
| 129 | { | |
| 130 | if (e.getR esponse(). getStatus( ) == 204) | |
| 131 | do Assertions (new Array List<DNSRe cord>()); | |
| 132 | else | |
| 133 | th row e; | |
| 134 | } | |
| 135 | ||
| 136 | } | |
| 137 | ||
| 138 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 139 | { | |
| 140 | ||
| 141 | } | |
| 142 | } | |
| 143 | ||
| 144 | @Tes t | |
| 145 | publ ic void te stGetDNSRe cords_byTy peOnly_ass ertRecords Retrieved( ) throws E xception | |
| 146 | { | |
| 147 | new Te stPlan() | |
| 148 | { | |
| 149 | ||
| 150 | @Overrid e | |
| 151 | protecte d String g etTypeToRe trieve() | |
| 152 | { | |
| 153 | return Int eger.toStr ing(Type.A ); | |
| 154 | } | |
| 155 | ||
| 156 | @Overrid e | |
| 157 | protecte d String g etNameToRe trieve() | |
| 158 | { | |
| 159 | return ""; | |
| 160 | } | |
| 161 | ||
| 162 | @Overrid e | |
| 163 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 164 | { | |
| 165 | assertNotN ull(record s); | |
| 166 | assertEqua ls(3, reco rds.size() ); | |
| 167 | ||
| 168 | final Iter ator<DNSRe cord> adde dRecordsIt er = this. records.it erator(); | |
| 169 | ||
| 170 | for (DNSRe cord retri evedRecord : records ) | |
| 171 | { | |
| 172 | fi nal DNSRec ord addedR ecord = ad dedRecords Iter.next( ); | |
| 173 | ||
| 174 | as sertEquals (addedReco rd.getDcla ss(), retr ievedRecor d.getDclas s()); | |
| 175 | as sertEquals (Type.A, r etrievedRe cord.getTy pe()); | |
| 176 | as sertTrue(A rrays.equa ls(addedRe cord.getDa ta(), retr ievedRecor d.getData( ))); | |
| 177 | as sertEquals (addedReco rd.getTtl( ), retriev edRecord.g etTtl()); | |
| 178 | as sertEquals (addedReco rd.getName (), retrie vedRecord. getName()) ; | |
| 179 | } | |
| 180 | ||
| 181 | } | |
| 182 | }.perf orm(); | |
| 183 | } | |
| 184 | ||
| 185 | @Tes t | |
| 186 | publ ic void te stGetDNSRe cords_byNa meOnly_ass ertRecords Retrieved( ) throws E xception | |
| 187 | { | |
| 188 | new Te stPlan() | |
| 189 | { | |
| 190 | ||
| 191 | @Overrid e | |
| 192 | protecte d String g etTypeToRe trieve() | |
| 193 | { | |
| 194 | return nul l; | |
| 195 | } | |
| 196 | ||
| 197 | @Overrid e | |
| 198 | protecte d String g etNameToRe trieve() | |
| 199 | { | |
| 200 | return "my Server.com "; | |
| 201 | } | |
| 202 | ||
| 203 | @Overrid e | |
| 204 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 205 | { | |
| 206 | assertNotN ull(record s); | |
| 207 | assertEqua ls(3, reco rds.size() ); | |
| 208 | ||
| 209 | for (DNSRe cord retri evedRecord : records ) | |
| 210 | { | |
| 211 | as sertTrue(r etrievedRe cord.getNa me().equal sIgnoreCas e("myServe r.com.")); | |
| 212 | } | |
| 213 | ||
| 214 | } | |
| 215 | }.perf orm(); | |
| 216 | } | |
| 217 | ||
| 218 | @Tes t | |
| 219 | publ ic void te stGetDNSRe cords_byNa meOnly_dot tedSuffix_ assertReco rdsRetriev ed() throw s Exceptio n | |
| 220 | { | |
| 221 | new Te stPlan() | |
| 222 | { | |
| 223 | ||
| 224 | @Overrid e | |
| 225 | protecte d String g etTypeToRe trieve() | |
| 226 | { | |
| 227 | return nul l; | |
| 228 | } | |
| 229 | ||
| 230 | @Overrid e | |
| 231 | protecte d String g etNameToRe trieve() | |
| 232 | { | |
| 233 | return "my Server.com ."; | |
| 234 | } | |
| 235 | ||
| 236 | @Overrid e | |
| 237 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 238 | { | |
| 239 | assertNotN ull(record s); | |
| 240 | assertEqua ls(3, reco rds.size() ); | |
| 241 | ||
| 242 | for (DNSRe cord retri evedRecord : records ) | |
| 243 | { | |
| 244 | as sertTrue(r etrievedRe cord.getNa me().equal sIgnoreCas e("myServe r.com.")); | |
| 245 | } | |
| 246 | ||
| 247 | } | |
| 248 | }.perf orm(); | |
| 249 | } | |
| 250 | ||
| 251 | @Tes t | |
| 252 | publ ic void te stGetDNSRe cords_byNa meAndType_ assertReco rdsRetriev ed() throw s Exceptio n | |
| 253 | { | |
| 254 | new Te stPlan() | |
| 255 | { | |
| 256 | ||
| 257 | @Overrid e | |
| 258 | protecte d String g etTypeToRe trieve() | |
| 259 | { | |
| 260 | return Int eger.toStr ing(Type.A ); | |
| 261 | } | |
| 262 | ||
| 263 | @Overrid e | |
| 264 | protecte d String g etNameToRe trieve() | |
| 265 | { | |
| 266 | return "my Server.com "; | |
| 267 | } | |
| 268 | ||
| 269 | @Overrid e | |
| 270 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 271 | { | |
| 272 | assertNotN ull(record s); | |
| 273 | assertEqua ls(2, reco rds.size() ); | |
| 274 | ||
| 275 | for (DNSRe cord retri evedRecord : records ) | |
| 276 | { | |
| 277 | as sertEquals (Type.A, r etrievedRe cord.getTy pe()); | |
| 278 | as sertTrue(r etrievedRe cord.getNa me().equal sIgnoreCas e("myServe r.com.")); | |
| 279 | } | |
| 280 | ||
| 281 | } | |
| 282 | }.perf orm(); | |
| 283 | } | |
| 284 | ||
| 285 | @Tes t | |
| 286 | publ ic void te stGetDNSRe cords_byNa meAndType_ dottedSuff ix_assertR ecordsRetr ieved() th rows Excep tion | |
| 287 | { | |
| 288 | new Te stPlan() | |
| 289 | { | |
| 290 | ||
| 291 | @Overrid e | |
| 292 | protecte d String g etTypeToRe trieve() | |
| 293 | { | |
| 294 | return Int eger.toStr ing(Type.A ); | |
| 295 | } | |
| 296 | ||
| 297 | @Overrid e | |
| 298 | protecte d String g etNameToRe trieve() | |
| 299 | { | |
| 300 | return "my Server.com ."; | |
| 301 | } | |
| 302 | ||
| 303 | @Overrid e | |
| 304 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 305 | { | |
| 306 | assertNotN ull(record s); | |
| 307 | assertEqua ls(2, reco rds.size() ); | |
| 308 | ||
| 309 | for (DNSRe cord retri evedRecord : records ) | |
| 310 | { | |
| 311 | as sertEquals (Type.A, r etrievedRe cord.getTy pe()); | |
| 312 | as sertTrue(r etrievedRe cord.getNa me().equal sIgnoreCas e("myServe r.com.")); | |
| 313 | } | |
| 314 | ||
| 315 | } | |
| 316 | }.perf orm(); | |
| 317 | } | |
| 318 | ||
| 319 | @Tes t | |
| 320 | publ ic void te stGetDNSRe cords_getA llWithAnyT ype_assert RecordsRet rieved() t hrows Exce ption | |
| 321 | { | |
| 322 | new Te stPlan() | |
| 323 | { | |
| 324 | ||
| 325 | @Overrid e | |
| 326 | protecte d String g etTypeToRe trieve() | |
| 327 | { | |
| 328 | return Int eger.toStr ing(Type.A NY); | |
| 329 | } | |
| 330 | ||
| 331 | @Overrid e | |
| 332 | protecte d String g etNameToRe trieve() | |
| 333 | { | |
| 334 | return ""; | |
| 335 | } | |
| 336 | ||
| 337 | @Overrid e | |
| 338 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 339 | { | |
| 340 | assertNotN ull(record s); | |
| 341 | assertEqua ls(this.re cords.size (), record s.size()); | |
| 342 | ||
| 343 | final Iter ator<DNSRe cord> adde dRecordsIt er = this. records.it erator(); | |
| 344 | ||
| 345 | for (DNSRe cord retri evedRecord : records ) | |
| 346 | { | |
| 347 | fi nal DNSRec ord addedR ecord = ad dedRecords Iter.next( ); | |
| 348 | ||
| 349 | as sertEquals (addedReco rd.getDcla ss(), retr ievedRecor d.getDclas s()); | |
| 350 | as sertEquals (addedReco rd.getType (), retrie vedRecord. getType()) ; | |
| 351 | as sertTrue(A rrays.equa ls(addedRe cord.getDa ta(), retr ievedRecor d.getData( ))); | |
| 352 | as sertEquals (addedReco rd.getTtl( ), retriev edRecord.g etTtl()); | |
| 353 | as sertEquals (addedReco rd.getName (), retrie vedRecord. getName()) ; | |
| 354 | } | |
| 355 | ||
| 356 | } | |
| 357 | }.perf orm(); | |
| 358 | } | |
| 359 | ||
| 360 | @Tes t | |
| 361 | publ ic void te stGetDNSRe cords_type NotInStore _assertNoR ecordsRetr ieved() th rows Excep tion | |
| 362 | { | |
| 363 | new Te stPlan() | |
| 364 | { | |
| 365 | ||
| 366 | @Overrid e | |
| 367 | protecte d String g etTypeToRe trieve() | |
| 368 | { | |
| 369 | return Int eger.toStr ing(Type.A 6); | |
| 370 | } | |
| 371 | ||
| 372 | @Overrid e | |
| 373 | protecte d String g etNameToRe trieve() | |
| 374 | { | |
| 375 | return ""; | |
| 376 | } | |
| 377 | ||
| 378 | @Overrid e | |
| 379 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 380 | { | |
| 381 | assertNotN ull(record s); | |
| 382 | assertTrue (records.i sEmpty()); | |
| 383 | ||
| 384 | } | |
| 385 | }.perf orm(); | |
| 386 | } | |
| 387 | ||
| 388 | @Tes t | |
| 389 | publ ic void te stGetDNSRe cords_noTy peOrName_a ssertBadRe quest() th rows Excep tion | |
| 390 | { | |
| 391 | new Te stPlan() | |
| 392 | { | |
| 393 | ||
| 394 | @Overrid e | |
| 395 | protecte d String g etTypeToRe trieve() | |
| 396 | { | |
| 397 | return "-1 "; | |
| 398 | } | |
| 399 | ||
| 400 | @Overrid e | |
| 401 | protecte d String g etNameToRe trieve() | |
| 402 | { | |
| 403 | return ""; | |
| 404 | } | |
| 405 | ||
| 406 | @Overrid e | |
| 407 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 408 | { | |
| 409 | assertTrue (exception instanceo f UniformI nterfaceEx ception); | |
| 410 | UniformInt erfaceExce ption ex = (UniformI nterfaceEx ception)ex ception; | |
| 411 | assertEqua ls(400, ex .getRespon se().getSt atus()); | |
| 412 | } | |
| 413 | }.perf orm(); | |
| 414 | } | |
| 415 | ||
| 416 | @Tes t | |
| 417 | publ ic void te stGetDNSRe cords_erro rInLookup_ assertServ iceError() throws Ex ception | |
| 418 | { | |
| 419 | new Te stPlan() | |
| 420 | { | |
| 421 | ||
| 422 | protecte d DNSResou rce dnsSer vice; | |
| 423 | ||
| 424 | @Overrid e | |
| 425 | protecte d void set upMocks() | |
| 426 | { | |
| 427 | try | |
| 428 | { | |
| 429 | su per.setupM ocks(); | |
| 430 | ||
| 431 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 432 | ||
| 433 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 434 | do Throw(new RuntimeExc eption()). when(mockD AO).get((S tring)any( )); | |
| 435 | ||
| 436 | dn sService.s etDNSDao(m ockDAO); | |
| 437 | } | |
| 438 | catch (Thr owable t) | |
| 439 | { | |
| 440 | th row new Ru ntimeExcep tion(t); | |
| 441 | } | |
| 442 | } | |
| 443 | ||
| 444 | @Overrid e | |
| 445 | protecte d void tea rDownMocks () | |
| 446 | { | |
| 447 | super.tear DownMocks( ); | |
| 448 | ||
| 449 | dnsService .setDNSDao (dnsDao); | |
| 450 | } | |
| 451 | ||
| 452 | ||
| 453 | @Overrid e | |
| 454 | protecte d String g etTypeToRe trieve() | |
| 455 | { | |
| 456 | return "-1 "; | |
| 457 | } | |
| 458 | ||
| 459 | @Overrid e | |
| 460 | protecte d String g etNameToRe trieve() | |
| 461 | { | |
| 462 | return "my server.com "; | |
| 463 | } | |
| 464 | ||
| 465 | @Overrid e | |
| 466 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 467 | { | |
| 468 | assertTrue (exception instanceo f UniformI nterfaceEx ception); | |
| 469 | UniformInt erfaceExce ption ex = (UniformI nterfaceEx ception)ex ception; | |
| 470 | assertEqua ls(500, ex .getRespon se().getSt atus()); | |
| 471 | } | |
| 472 | }.perf orm(); | |
| 473 | } | |
| 474 | ||
| 475 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.