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-jar\src\test\java\org\nhindirect\config\resources | DNSResource_addDNSRecordTest.java | Tue May 22 13:45:48 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-service-jar\src\test\java\org\nhindirect\config\resources | DNSResource_addDNSRecordTest.java | Wed May 23 16:39:28 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 11 | 724 |
| Changed | 10 | 20 |
| 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.Matc hers.eq; | |
| 5 | import sta tic org.mo ckito.Mock ito.when; | |
| 6 | import sta tic org.mo ckito.Mock ito.doThro w; | |
| 7 | import sta tic org.mo ckito.Mock ito.mock; | |
| 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 | import jav ax.ws.rs.c ore.MediaT ype; | |
| 14 | ||
| 15 | import org .junit.Tes t; | |
| 16 | import org .nhindirec t.config.B aseTestPla n; | |
| 17 | import org .nhindirec t.config.C onfigServi ceRunner; | |
| 18 | import org .nhindirec t.config.T estUtils; | |
| 19 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 20 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 21 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 22 | import org .xbill.DNS .Type; | |
| 23 | ||
| 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 DNSReso urce_addDN SRecordTes t | |
| 28 | { | |
| 29 | protec ted DNSDao dnsDao; | |
| 30 | ||
| 31 | st atic WebRe source res ource; | |
| 32 | ||
| 33 | ab stract cla ss TestPla n extends BaseTestPl an | |
| 34 | { | |
| 35 | @Ove rride | |
| 36 | prot ected void setupMock s() | |
| 37 | { | |
| 38 | try | |
| 39 | { | |
| 40 | dnsDao = (DNSDao)C onfigServi ceRunner.g etSpringAp plicationC ontext().g etBean("dn sDao"); | |
| 41 | ||
| 42 | resource = ge tResource( ConfigServ iceRunner. getConfigS erviceURL( )); | |
| 43 | } | |
| 44 | catch (Throwable t) | |
| 45 | { | |
| 46 | throw ne w RuntimeE xception(t ); | |
| 47 | } | |
| 48 | } | |
| 49 | ||
| 50 | @Ove rride | |
| 51 | prot ected void tearDownM ocks() | |
| 52 | { | |
| 53 | ||
| 54 | } | |
| 55 | ||
| 56 | prot ected abst ract Colle ction<DNSR ecord> get DNSRecords ToAdd(); | |
| 57 | ||
| 58 | @Ove rride | |
| 59 | prot ected void performIn ner() thro ws Excepti on | |
| 60 | { | |
| 61 | ||
| 62 | final Collection <DNSRecord > recordsT oAdd = get DNSRecords ToAdd(); | |
| 63 | ||
| 64 | for (D NSRecord a ddRecord : recordsTo Add) | |
| 65 | { | |
| 66 | try | |
| 67 | { | |
| 68 | resource.p ath("/api/ dns").enti ty(addReco rd, MediaT ype.APPLIC ATION_JSON ).put(addR ecord); | |
| 69 | } | |
| 70 | catch (U niformInte rfaceExcep tion e) | |
| 71 | { | |
| 72 | throw e; | |
| 73 | } | |
| 74 | } | |
| 75 | ||
| 76 | doAsse rtions(); | |
| 77 | } | |
| 78 | ||
| 79 | prot ected void doAsserti ons() thro ws Excepti on | |
| 80 | { | |
| 81 | ||
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | @T est | |
| 86 | pu blic void testAddRec ords_asser tRecordsAd ded() thro ws Excepti on | |
| 87 | { | |
| 88 | new TestPlan() | |
| 89 | { | |
| 90 | protec ted Collec tion<DNSRe cord> reco rds; | |
| 91 | ||
| 92 | @Overr ide | |
| 93 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 94 | { | |
| 95 | try | |
| 96 | { | |
| 97 | records = new ArrayL ist<DNSRec ord>(); | |
| 98 | ||
| 99 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com", PORT , " IP "); | |
| 100 | records.ad d(record); | |
| 101 | ||
| 102 | ||
| 103 | record = D NSUtils.cr eateARecor d("myserve r.com", PORT , " IP "); | |
| 104 | records.ad d(record); | |
| 105 | ||
| 106 | record = D NSUtils.cr eateARecor d("myserve r2.com", PORT , " IP "); | |
| 107 | records.ad d(record); | |
| 108 | ||
| 109 | record = D NSUtils.cr eateX509CE RTRecord(" gm2552@sec urehealthe mail.com", PORT , TestUtil s.loadCert ("gm2552.d er")); | |
| 110 | records.ad d(record); | |
| 111 | ||
| 112 | record = D NSUtils.cr eateMXReco rd("myserv er.com", " IP ", PORT , 2); | |
| 113 | records.ad d(record); | |
| 114 | ||
| 115 | return rec ords; | |
| 116 | } | |
| 117 | catch (E xception e ) | |
| 118 | { | |
| 119 | throw new RuntimeExc eption (e) ; | |
| 120 | } | |
| 121 | } | |
| 122 | ||
| 123 | ||
| 124 | @Overr ide | |
| 125 | protec ted void d oAssertion s() throws Exception | |
| 126 | { | |
| 127 | Collecti on<org.nhi ndirect.co nfig.store .DNSRecord > retrieve dRecords = dnsDao.ge t(Type.ANY ); | |
| 128 | ||
| 129 | assertNo tNull(retr ievedRecor ds); | |
| 130 | assertEq uals(this. records.si ze(), retr ievedRecor ds.size()) ; | |
| 131 | ||
| 132 | final It erator<DNS Record> ad dedRecords Iter = thi s.records. iterator() ; | |
| 133 | ||
| 134 | for (org .nhindirec t.config.s tore.DNSRe cord retri evedRecord : retriev edRecords) | |
| 135 | { | |
| 136 | final DNSR ecord adde dRecord = addedRecor dsIter.nex t(); | |
| 137 | ||
| 138 | assertEqua ls(addedRe cord.getDc lass(), re trievedRec ord.getDcl ass()); | |
| 139 | assertEqua ls(addedRe cord.getTy pe(), retr ievedRecor d.getType( )); | |
| 140 | assertTrue (Arrays.eq uals(added Record.get Data(), re trievedRec ord.getDat a())); | |
| 141 | assertEqua ls(addedRe cord.getTt l(), retri evedRecord .getTtl()) ; | |
| 142 | assertEqua ls(addedRe cord.getNa me(), retr ievedRecor d.getName( )); | |
| 143 | } | |
| 144 | ||
| 145 | } | |
| 146 | }.pe rform(); | |
| 147 | } | |
| 148 | ||
| 149 | @T est | |
| 150 | pu blic void testAddRec ords_noDot tedSuffix_ assertReco rdsAdded() throws Ex ception | |
| 151 | { | |
| 152 | new TestPlan() | |
| 153 | { | |
| 154 | protec ted Collec tion<DNSRe cord> reco rds; | |
| 155 | ||
| 156 | @Overr ide | |
| 157 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 158 | { | |
| 159 | try | |
| 160 | { | |
| 161 | records = new ArrayL ist<DNSRec ord>(); | |
| 162 | ||
| 163 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", PORT , " IP "); | |
| 164 | record.set Name("myse rver.com") ; | |
| 165 | records.ad d(record); | |
| 166 | ||
| 167 | return rec ords; | |
| 168 | } | |
| 169 | catch (E xception e ) | |
| 170 | { | |
| 171 | throw new RuntimeExc eption (e) ; | |
| 172 | } | |
| 173 | } | |
| 174 | ||
| 175 | ||
| 176 | @Overr ide | |
| 177 | protec ted void d oAssertion s() throws Exception | |
| 178 | { | |
| 179 | Collecti on<org.nhi ndirect.co nfig.store .DNSRecord > retrieve dRecords = dnsDao.ge t(Type.ANY ); | |
| 180 | ||
| 181 | assertNo tNull(retr ievedRecor ds); | |
| 182 | assertEq uals(this. records.si ze(), retr ievedRecor ds.size()) ; | |
| 183 | ||
| 184 | final It erator<DNS Record> ad dedRecords Iter = thi s.records. iterator() ; | |
| 185 | ||
| 186 | for (org .nhindirec t.config.s tore.DNSRe cord retri evedRecord : retriev edRecords) | |
| 187 | { | |
| 188 | final DNSR ecord adde dRecord = addedRecor dsIter.nex t(); | |
| 189 | ||
| 190 | assertEqua ls(addedRe cord.getDc lass(), re trievedRec ord.getDcl ass()); | |
| 191 | assertEqua ls(addedRe cord.getTy pe(), retr ievedRecor d.getType( )); | |
| 192 | assertTrue (Arrays.eq uals(added Record.get Data(), re trievedRec ord.getDat a())); | |
| 193 | assertEqua ls(addedRe cord.getTt l(), retri evedRecord .getTtl()) ; | |
| 194 | assertEqua ls("myserv er.com.", retrievedR ecord.getN ame()); | |
| 195 | } | |
| 196 | ||
| 197 | } | |
| 198 | }.pe rform(); | |
| 199 | } | |
| 200 | ||
| 201 | @T est | |
| 202 | pu blic void testAddRec ords_addDu plicate_as sertConfli ct() throw s Exceptio n | |
| 203 | { | |
| 204 | new TestPlan() | |
| 205 | { | |
| 206 | protec ted Collec tion<DNSRe cord> reco rds; | |
| 207 | ||
| 208 | @Overr ide | |
| 209 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 210 | { | |
| 211 | try | |
| 212 | { | |
| 213 | records = new ArrayL ist<DNSRec ord>(); | |
| 214 | ||
| 215 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", PORT , " IP "); | |
| 216 | records.ad d(record); | |
| 217 | ||
| 218 | record = D NSUtils.cr eateARecor d("myserve r.com.", PORT , " IP "); | |
| 219 | records.ad d(record); | |
| 220 | ||
| 221 | return rec ords; | |
| 222 | } | |
| 223 | catch (E xception e ) | |
| 224 | { | |
| 225 | throw new RuntimeExc eption (e) ; | |
| 226 | } | |
| 227 | } | |
| 228 | ||
| 229 | ||
| 230 | @Overr ide | |
| 231 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 232 | { | |
| 233 | assertTr ue(excepti on instanc eof Unifor mInterface Exception) ; | |
| 234 | UniformI nterfaceEx ception ex = (Unifor mInterface Exception) exception; | |
| 235 | assertEq uals(409, ex.getResp onse().get Status()); | |
| 236 | } | |
| 237 | }.pe rform(); | |
| 238 | } | |
| 239 | ||
| 240 | @T est | |
| 241 | pu blic void testAddDNS Records_er rorInLooku p_assertSe rviceError () throws Exception | |
| 242 | { | |
| 243 | new TestPlan() | |
| 244 | { | |
| 245 | ||
| 246 | protec ted DNSRes ource dnsS ervice; | |
| 247 | ||
| 248 | @Overr ide | |
| 249 | protec ted void s etupMocks( ) | |
| 250 | { | |
| 251 | try | |
| 252 | { | |
| 253 | super.setu pMocks(); | |
| 254 | ||
| 255 | dnsService = (DNSRes ource)Conf igServiceR unner.getS pringAppli cationCont ext().getB ean("DNSRe source"); | |
| 256 | ||
| 257 | DNSDao moc kDAO = moc k(DNSDao.c lass); | |
| 258 | ||
| 259 | doThrow(ne w RuntimeE xception() ).when(moc kDAO).get( (String)an y(), eq(1) ); | |
| 260 | ||
| 261 | dnsService .setDNSDao (mockDAO); | |
| 262 | } | |
| 263 | catch (T hrowable t ) | |
| 264 | { | |
| 265 | throw new RuntimeExc eption(t); | |
| 266 | } | |
| 267 | } | |
| 268 | ||
| 269 | @Overr ide | |
| 270 | protec ted void t earDownMoc ks() | |
| 271 | { | |
| 272 | super.te arDownMock s(); | |
| 273 | ||
| 274 | dnsServi ce.setDNSD ao(dnsDao) ; | |
| 275 | } | |
| 276 | ||
| 277 | @Overr ide | |
| 278 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 279 | { | |
| 280 | try | |
| 281 | { | |
| 282 | Collection <DNSRecord > records = new Arra yList<DNSR ecord>(); | |
| 283 | ||
| 284 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", PORT , " IP "); | |
| 285 | records.ad d(record); | |
| 286 | ||
| 287 | return rec ords; | |
| 288 | } | |
| 289 | catch (E xception e ) | |
| 290 | { | |
| 291 | throw new RuntimeExc eption (e) ; | |
| 292 | } | |
| 293 | } | |
| 294 | ||
| 295 | @Overr ide | |
| 296 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 297 | { | |
| 298 | assertTr ue(excepti on instanc eof Unifor mInterface Exception) ; | |
| 299 | UniformI nterfaceEx ception ex = (Unifor mInterface Exception) exception; | |
| 300 | assertEq uals(500, ex.getResp onse().get Status()); | |
| 301 | } | |
| 302 | }.pe rform(); | |
| 303 | } | |
| 304 | ||
| 305 | @T est | |
| 306 | pu blic void testAddDNS Records_er rorInAdd_a ssertServi ceError() throws Exc eption | |
| 307 | { | |
| 308 | new TestPlan() | |
| 309 | { | |
| 310 | ||
| 311 | protec ted DNSRes ource dnsS ervice; | |
| 312 | ||
| 313 | @Suppr essWarning s("uncheck ed") | |
| 314 | @Overr ide | |
| 315 | protec ted void s etupMocks( ) | |
| 316 | { | |
| 317 | try | |
| 318 | { | |
| 319 | super.setu pMocks(); | |
| 320 | ||
| 321 | dnsService = (DNSRes ource)Conf igServiceR unner.getS pringAppli cationCont ext().getB ean("DNSRe source"); | |
| 322 | ||
| 323 | DNSDao moc kDAO = moc k(DNSDao.c lass); | |
| 324 | when(mockD AO.get((St ring)any() , eq(1))). thenReturn (new Array List<org.n hindirect. config.sto re.DNSReco rd>()); | |
| 325 | doThrow(ne w RuntimeE xception() ).when(moc kDAO).add( (Collectio n<org.nhin direct.con fig.store. DNSRecord> )any()); | |
| 326 | ||
| 327 | dnsService .setDNSDao (mockDAO); | |
| 328 | } | |
| 329 | catch (T hrowable t ) | |
| 330 | { | |
| 331 | throw new RuntimeExc eption(t); | |
| 332 | } | |
| 333 | } | |
| 334 | ||
| 335 | @Overr ide | |
| 336 | protec ted void t earDownMoc ks() | |
| 337 | { | |
| 338 | super.te arDownMock s(); | |
| 339 | ||
| 340 | dnsServi ce.setDNSD ao(dnsDao) ; | |
| 341 | } | |
| 342 | ||
| 343 | ||
| 344 | @Overr ide | |
| 345 | protec ted Collec tion<DNSRe cord> getD NSRecordsT oAdd() | |
| 346 | { | |
| 347 | try | |
| 348 | { | |
| 349 | Collection <DNSRecord > records = new Arra yList<DNSR ecord>(); | |
| 350 | ||
| 351 | DNSRecord record = D NSUtils.cr eateARecor d("myserve r.com.", PORT , " IP "); | |
| 352 | records.ad d(record); | |
| 353 | ||
| 354 | return rec ords; | |
| 355 | } | |
| 356 | catch (E xception e ) | |
| 357 | { | |
| 358 | throw new RuntimeExc eption (e) ; | |
| 359 | } | |
| 360 | } | |
| 361 | ||
| 362 | @Overr ide | |
| 363 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 364 | { | |
| 365 | assertTr ue(excepti on instanc eof Unifor mInterface Exception) ; | |
| 366 | UniformI nterfaceEx ception ex = (Unifor mInterface Exception) exception; | |
| 367 | assertEq uals(500, ex.getResp onse().get Status()); | |
| 368 | } | |
| 369 | }.pe rform(); | |
| 370 | } | |
| 371 | ||
| 372 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.