Produced by Araxis Merge on 5/25/2018 9:21:41 AM 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\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_getDNSRecordTest.java | Tue May 22 13:50:22 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl | DefaultDNSService_getDNSRecordTest.java | Wed May 23 16:21:44 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 6 | 930 |
| Changed | 5 | 10 |
| 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.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 org .junit.Tes t; | |
| 13 | import org .nhind.con fig.client .ConfigSer viceRunner ; | |
| 14 | import org .nhind.con fig.rest.D NSService; | |
| 15 | import org .nhind.con fig.testba se.BaseTes tPlan; | |
| 16 | import org .nhind.con fig.testba se.TestUti ls; | |
| 17 | ||
| 18 | import org .nhindirec t.common.r est.except ions.Servi ceExceptio n; | |
| 19 | import org .nhindirec t.common.r est.except ions.Servi ceMethodEx ception; | |
| 20 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 21 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 22 | import org .nhindirec t.config.r esources.D NSResource ; | |
| 23 | ||
| 24 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 25 | import org .xbill.DNS .Type; | |
| 26 | ||
| 27 | public cla ss Default DNSService _getDNSRec ordTest | |
| 28 | { | |
| 29 | protec ted DNSDao dnsDao; | |
| 30 | ||
| 31 | st atic DNSSe rvice reso urce; | |
| 32 | ||
| 33 | ab stract cla ss TestPla n extends BaseTestPl an | |
| 34 | { | |
| 35 | prot ected Coll ection<DNS Record> re cords; | |
| 36 | ||
| 37 | @Ove rride | |
| 38 | prot ected void setupMock s() | |
| 39 | { | |
| 40 | try | |
| 41 | { | |
| 42 | dnsDao = (DNSDao)C onfigServi ceRunner.g etSpringAp plicationC ontext().g etBean("DN SDaoImpl") ; | |
| 43 | ||
| 44 | resource = (D NSService) BaseTestPl an.getServ ice(Config ServiceRun ner.getRes tAPIBaseUR L(), DNS_S ERVICE); | |
| 45 | ||
| 46 | } | |
| 47 | catch (Throwable t) | |
| 48 | { | |
| 49 | throw ne w RuntimeE xception(t ); | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 53 | @Ove rride | |
| 54 | prot ected void tearDownM ocks() | |
| 55 | { | |
| 56 | ||
| 57 | } | |
| 58 | ||
| 59 | prot ected Coll ection<DNS Record> ge tDNSRecord sToAdd() | |
| 60 | { | |
| 61 | try | |
| 62 | { | |
| 63 | records = new Arra yList<DNSR ecord>(); | |
| 64 | ||
| 65 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com", PORT , " IP "); | |
| 66 | records. add(record ); | |
| 67 | ||
| 68 | ||
| 69 | record = D NSUtils.cr eateARecor d("myserve r.com", PORT , " IP "); | |
| 70 | records. add(record ); | |
| 71 | ||
| 72 | record = D NSUtils.cr eateARecor d("myserve r2.com", PORT , " IP "); | |
| 73 | records. add(record ); | |
| 74 | ||
| 75 | record = D NSUtils.cr eateX509CE RTRecord(" gm2552@sec urehealthe mail.com", PORT , TestUtil s.loadCert ("gm2552.d er")); | |
| 76 | records. add(record ); | |
| 77 | ||
| 78 | record = D NSUtils.cr eateMXReco rd("myserv er.com", " IP ", PORT , 2); | |
| 79 | records. add(record ); | |
| 80 | ||
| 81 | return r ecords; | |
| 82 | } | |
| 83 | catch (Exception e) | |
| 84 | { | |
| 85 | throw ne w RuntimeE xception ( e); | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | prot ected abst ract Strin g getTypeT oRetrieve( ); | |
| 90 | ||
| 91 | prot ected abst ract Strin g getNameT oRetrieve( ); | |
| 92 | ||
| 93 | @Ove rride | |
| 94 | prot ected void performIn ner() thro ws Excepti on | |
| 95 | { | |
| 96 | ||
| 97 | final Collection <DNSRecord > recsToAd d = getDNS RecordsToA dd(); | |
| 98 | ||
| 99 | if (re csToAdd != null) | |
| 100 | { | |
| 101 | for (DNS Record add Rec : recs ToAdd) | |
| 102 | { | |
| 103 | try | |
| 104 | { | |
| 105 | re source.add DNSRecord( addRec); | |
| 106 | } | |
| 107 | catch (Ser viceExcept ion e) | |
| 108 | { | |
| 109 | th row e; | |
| 110 | } | |
| 111 | } | |
| 112 | } | |
| 113 | ||
| 114 | try | |
| 115 | { | |
| 116 | final in t type = g etTypeToRe trieve() = = null ? - 1 : Integ er.parseIn t(getTypeT oRetrieve( )); | |
| 117 | final St ring name = getNameT oRetrieve( ) == null ? "" : get NameToRetr ieve(); | |
| 118 | ||
| 119 | final Co llection<D NSRecord> records = resource.g etDNSRecor d(type, na me); | |
| 120 | ||
| 121 | doAssert ions(recor ds); | |
| 122 | } | |
| 123 | catch (ServiceMe thodExcept ion e) | |
| 124 | { | |
| 125 | if (e.ge tResponseC ode() == 2 04) | |
| 126 | doAssertio ns(new Arr ayList<DNS Record>()) ; | |
| 127 | else | |
| 128 | throw e; | |
| 129 | } | |
| 130 | ||
| 131 | } | |
| 132 | ||
| 133 | prot ected void doAsserti ons(Collec tion<DNSRe cord> reco rds) throw s Exceptio n | |
| 134 | { | |
| 135 | ||
| 136 | } | |
| 137 | } | |
| 138 | ||
| 139 | @T est | |
| 140 | pu blic void testGetDNS Records_by TypeOnly_a ssertRecor dsRetrieve d() throws Exception | |
| 141 | { | |
| 142 | new TestPlan() | |
| 143 | { | |
| 144 | ||
| 145 | @Overr ide | |
| 146 | protec ted String getTypeTo Retrieve() | |
| 147 | { | |
| 148 | return I nteger.toS tring(Type .A); | |
| 149 | } | |
| 150 | ||
| 151 | @Overr ide | |
| 152 | protec ted String getNameTo Retrieve() | |
| 153 | { | |
| 154 | return " "; | |
| 155 | } | |
| 156 | ||
| 157 | @Overr ide | |
| 158 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 159 | { | |
| 160 | assertNo tNull(reco rds); | |
| 161 | assertEq uals(3, re cords.size ()); | |
| 162 | ||
| 163 | final It erator<DNS Record> ad dedRecords Iter = thi s.records. iterator() ; | |
| 164 | ||
| 165 | for (DNS Record ret rievedReco rd : recor ds) | |
| 166 | { | |
| 167 | final DNSR ecord adde dRecord = addedRecor dsIter.nex t(); | |
| 168 | ||
| 169 | assertEqua ls(addedRe cord.getDc lass(), re trievedRec ord.getDcl ass()); | |
| 170 | assertEqua ls(Type.A, retrieved Record.get Type()); | |
| 171 | assertTrue (Arrays.eq uals(added Record.get Data(), re trievedRec ord.getDat a())); | |
| 172 | assertEqua ls(addedRe cord.getTt l(), retri evedRecord .getTtl()) ; | |
| 173 | assertEqua ls(addedRe cord.getNa me(), retr ievedRecor d.getName( )); | |
| 174 | } | |
| 175 | ||
| 176 | } | |
| 177 | }.pe rform(); | |
| 178 | } | |
| 179 | ||
| 180 | @T est | |
| 181 | pu blic void testGetDNS Records_by NameOnly_a ssertRecor dsRetrieve d() throws Exception | |
| 182 | { | |
| 183 | new TestPlan() | |
| 184 | { | |
| 185 | ||
| 186 | @Overr ide | |
| 187 | protec ted String getTypeTo Retrieve() | |
| 188 | { | |
| 189 | return n ull; | |
| 190 | } | |
| 191 | ||
| 192 | @Overr ide | |
| 193 | protec ted String getNameTo Retrieve() | |
| 194 | { | |
| 195 | return " myServer.c om"; | |
| 196 | } | |
| 197 | ||
| 198 | @Overr ide | |
| 199 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 200 | { | |
| 201 | assertNo tNull(reco rds); | |
| 202 | assertEq uals(3, re cords.size ()); | |
| 203 | ||
| 204 | for (DNS Record ret rievedReco rd : recor ds) | |
| 205 | { | |
| 206 | assertTrue (retrieved Record.get Name().equ alsIgnoreC ase("mySer ver.com.") ); | |
| 207 | } | |
| 208 | ||
| 209 | } | |
| 210 | }.pe rform(); | |
| 211 | } | |
| 212 | ||
| 213 | @T est | |
| 214 | pu blic void testGetDNS Records_by NameOnly_d ottedSuffi x_assertRe cordsRetri eved() thr ows Except ion | |
| 215 | { | |
| 216 | new TestPlan() | |
| 217 | { | |
| 218 | ||
| 219 | @Overr ide | |
| 220 | protec ted String getTypeTo Retrieve() | |
| 221 | { | |
| 222 | return n ull; | |
| 223 | } | |
| 224 | ||
| 225 | @Overr ide | |
| 226 | protec ted String getNameTo Retrieve() | |
| 227 | { | |
| 228 | return " myServer.c om."; | |
| 229 | } | |
| 230 | ||
| 231 | @Overr ide | |
| 232 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 233 | { | |
| 234 | assertNo tNull(reco rds); | |
| 235 | assertEq uals(3, re cords.size ()); | |
| 236 | ||
| 237 | for (DNS Record ret rievedReco rd : recor ds) | |
| 238 | { | |
| 239 | assertTrue (retrieved Record.get Name().equ alsIgnoreC ase("mySer ver.com.") ); | |
| 240 | } | |
| 241 | ||
| 242 | } | |
| 243 | }.pe rform(); | |
| 244 | } | |
| 245 | ||
| 246 | @T est | |
| 247 | pu blic void testGetDNS Records_by NameAndTyp e_assertRe cordsRetri eved() thr ows Except ion | |
| 248 | { | |
| 249 | new TestPlan() | |
| 250 | { | |
| 251 | ||
| 252 | @Overr ide | |
| 253 | protec ted String getTypeTo Retrieve() | |
| 254 | { | |
| 255 | return I nteger.toS tring(Type .A); | |
| 256 | } | |
| 257 | ||
| 258 | @Overr ide | |
| 259 | protec ted String getNameTo Retrieve() | |
| 260 | { | |
| 261 | return " myServer.c om"; | |
| 262 | } | |
| 263 | ||
| 264 | @Overr ide | |
| 265 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 266 | { | |
| 267 | assertNo tNull(reco rds); | |
| 268 | assertEq uals(2, re cords.size ()); | |
| 269 | ||
| 270 | for (DNS Record ret rievedReco rd : recor ds) | |
| 271 | { | |
| 272 | assertEqua ls(Type.A, retrieved Record.get Type()); | |
| 273 | assertTrue (retrieved Record.get Name().equ alsIgnoreC ase("mySer ver.com.") ); | |
| 274 | } | |
| 275 | ||
| 276 | } | |
| 277 | }.pe rform(); | |
| 278 | } | |
| 279 | ||
| 280 | @T est | |
| 281 | pu blic void testGetDNS Records_by NameAndTyp e_dottedSu ffix_asser tRecordsRe trieved() throws Exc eption | |
| 282 | { | |
| 283 | new TestPlan() | |
| 284 | { | |
| 285 | ||
| 286 | @Overr ide | |
| 287 | protec ted String getTypeTo Retrieve() | |
| 288 | { | |
| 289 | return I nteger.toS tring(Type .A); | |
| 290 | } | |
| 291 | ||
| 292 | @Overr ide | |
| 293 | protec ted String getNameTo Retrieve() | |
| 294 | { | |
| 295 | return " myServer.c om."; | |
| 296 | } | |
| 297 | ||
| 298 | @Overr ide | |
| 299 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 300 | { | |
| 301 | assertNo tNull(reco rds); | |
| 302 | assertEq uals(2, re cords.size ()); | |
| 303 | ||
| 304 | for (DNS Record ret rievedReco rd : recor ds) | |
| 305 | { | |
| 306 | assertEqua ls(Type.A, retrieved Record.get Type()); | |
| 307 | assertTrue (retrieved Record.get Name().equ alsIgnoreC ase("mySer ver.com.") ); | |
| 308 | } | |
| 309 | ||
| 310 | } | |
| 311 | }.pe rform(); | |
| 312 | } | |
| 313 | ||
| 314 | @T est | |
| 315 | pu blic void testGetDNS Records_ge tAllWithAn yType_asse rtRecordsR etrieved() throws Ex ception | |
| 316 | { | |
| 317 | new TestPlan() | |
| 318 | { | |
| 319 | ||
| 320 | @Overr ide | |
| 321 | protec ted String getTypeTo Retrieve() | |
| 322 | { | |
| 323 | return I nteger.toS tring(Type .ANY); | |
| 324 | } | |
| 325 | ||
| 326 | @Overr ide | |
| 327 | protec ted String getNameTo Retrieve() | |
| 328 | { | |
| 329 | return " "; | |
| 330 | } | |
| 331 | ||
| 332 | @Overr ide | |
| 333 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 334 | { | |
| 335 | assertNo tNull(reco rds); | |
| 336 | assertEq uals(this. records.si ze(), reco rds.size() ); | |
| 337 | ||
| 338 | final It erator<DNS Record> ad dedRecords Iter = thi s.records. iterator() ; | |
| 339 | ||
| 340 | for (DNS Record ret rievedReco rd : recor ds) | |
| 341 | { | |
| 342 | final DNSR ecord adde dRecord = addedRecor dsIter.nex t(); | |
| 343 | ||
| 344 | assertEqua ls(addedRe cord.getDc lass(), re trievedRec ord.getDcl ass()); | |
| 345 | assertEqua ls(addedRe cord.getTy pe(), retr ievedRecor d.getType( )); | |
| 346 | assertTrue (Arrays.eq uals(added Record.get Data(), re trievedRec ord.getDat a())); | |
| 347 | assertEqua ls(addedRe cord.getTt l(), retri evedRecord .getTtl()) ; | |
| 348 | assertEqua ls(addedRe cord.getNa me(), retr ievedRecor d.getName( )); | |
| 349 | } | |
| 350 | ||
| 351 | } | |
| 352 | }.pe rform(); | |
| 353 | } | |
| 354 | ||
| 355 | @T est | |
| 356 | pu blic void testGetDNS Records_ty peNotInSto re_assertN oRecordsRe trieved() throws Exc eption | |
| 357 | { | |
| 358 | new TestPlan() | |
| 359 | { | |
| 360 | ||
| 361 | @Overr ide | |
| 362 | protec ted String getTypeTo Retrieve() | |
| 363 | { | |
| 364 | return I nteger.toS tring(Type .A6); | |
| 365 | } | |
| 366 | ||
| 367 | @Overr ide | |
| 368 | protec ted String getNameTo Retrieve() | |
| 369 | { | |
| 370 | return " "; | |
| 371 | } | |
| 372 | ||
| 373 | @Overr ide | |
| 374 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 375 | { | |
| 376 | assertNo tNull(reco rds); | |
| 377 | assertTr ue(records .isEmpty() ); | |
| 378 | ||
| 379 | } | |
| 380 | }.pe rform(); | |
| 381 | } | |
| 382 | ||
| 383 | @T est | |
| 384 | pu blic void testGetDNS Records_no TypeOrName _assertBad Request() throws Exc eption | |
| 385 | { | |
| 386 | new TestPlan() | |
| 387 | { | |
| 388 | ||
| 389 | @Overr ide | |
| 390 | protec ted String getTypeTo Retrieve() | |
| 391 | { | |
| 392 | return " -1"; | |
| 393 | } | |
| 394 | ||
| 395 | @Overr ide | |
| 396 | protec ted String getNameTo Retrieve() | |
| 397 | { | |
| 398 | return " "; | |
| 399 | } | |
| 400 | ||
| 401 | @Overr ide | |
| 402 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 403 | { | |
| 404 | assertTr ue(excepti on instanc eof Servic eMethodExc eption); | |
| 405 | ServiceM ethodExcep tion ex = (ServiceMe thodExcept ion)except ion; | |
| 406 | assertEq uals(400, ex.getResp onseCode() ); | |
| 407 | } | |
| 408 | }.pe rform(); | |
| 409 | } | |
| 410 | ||
| 411 | @T est | |
| 412 | pu blic void testGetDNS Records_er rorInLooku p_assertSe rviceError () throws Exception | |
| 413 | { | |
| 414 | new TestPlan() | |
| 415 | { | |
| 416 | ||
| 417 | protec ted DNSRes ource dnsS ervice; | |
| 418 | ||
| 419 | @Overr ide | |
| 420 | protec ted void s etupMocks( ) | |
| 421 | { | |
| 422 | try | |
| 423 | { | |
| 424 | super.setu pMocks(); | |
| 425 | ||
| 426 | dnsService = (DNSRes ource)Conf igServiceR unner.getS pringAppli cationCont ext().getB ean("DNSRe source"); | |
| 427 | ||
| 428 | DNSDao moc kDAO = moc k(DNSDao.c lass); | |
| 429 | doThrow(ne w RuntimeE xception() ).when(moc kDAO).get( (String)an y()); | |
| 430 | ||
| 431 | dnsService .setDNSDao (mockDAO); | |
| 432 | } | |
| 433 | catch (T hrowable t ) | |
| 434 | { | |
| 435 | throw new RuntimeExc eption(t); | |
| 436 | } | |
| 437 | } | |
| 438 | ||
| 439 | @Overr ide | |
| 440 | protec ted void t earDownMoc ks() | |
| 441 | { | |
| 442 | super.te arDownMock s(); | |
| 443 | ||
| 444 | dnsServi ce.setDNSD ao(dnsDao) ; | |
| 445 | } | |
| 446 | ||
| 447 | ||
| 448 | @Overr ide | |
| 449 | protec ted String getTypeTo Retrieve() | |
| 450 | { | |
| 451 | return " -1"; | |
| 452 | } | |
| 453 | ||
| 454 | @Overr ide | |
| 455 | protec ted String getNameTo Retrieve() | |
| 456 | { | |
| 457 | return " myserver.c om"; | |
| 458 | } | |
| 459 | ||
| 460 | @Overr ide | |
| 461 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 462 | { | |
| 463 | assertTr ue(excepti on instanc eof Servic eMethodExc eption); | |
| 464 | ServiceM ethodExcep tion ex = (ServiceMe thodExcept ion)except ion; | |
| 465 | assertEq uals(500, ex.getResp onseCode() ); | |
| 466 | } | |
| 467 | }.pe rform(); | |
| 468 | } | |
| 469 | ||
| 470 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.