Produced by Araxis Merge on 5/25/2018 9:21:42 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\dns\src\test\java\org\nhindirect\dns\tools | DNSRecordCommands_removeRecords_Test.java | Tue May 22 13:40:38 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\dns\src\test\java\org\nhindirect\dns\tools | DNSRecordCommands_removeRecords_Test.java | Tue May 22 20:59:43 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 734 |
| Changed | 1 | 2 |
| 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.dns.too ls; | |
| 2 | ||
| 3 | import jav a.net.Inet Address; | |
| 4 | import jav a.net.URL; | |
| 5 | import jav a.util.Arr ayList; | |
| 6 | import jav a.util.Arr ays; | |
| 7 | import jav a.util.Col lections; | |
| 8 | import jav a.util.Lis t; | |
| 9 | ||
| 10 | import jun it.framewo rk.TestCas e; | |
| 11 | ||
| 12 | import org .apache.ax is.AxisFau lt; | |
| 13 | import org .apache.mi na.util.Av ailablePor tFinder; | |
| 14 | import org .nhind.con fig.Config urationSer viceProxy; | |
| 15 | import org .nhind.con fig.DnsRec ord; | |
| 16 | import org .nhindirec t.dns.Conf igServiceD NSStore; | |
| 17 | import org .nhindirec t.dns.DNSS erver; | |
| 18 | import org .nhindirec t.dns.DNSS erverSetti ngs; | |
| 19 | import org .nhindirec t.dns.util .BaseTestP lan; | |
| 20 | import org .nhindirec t.dns.util .ConfigSer viceRunner ; | |
| 21 | import org .xbill.DNS .ARecord; | |
| 22 | import org .xbill.DNS .DClass; | |
| 23 | import org .xbill.DNS .MXRecord; | |
| 24 | import org .xbill.DNS .Name; | |
| 25 | import org .xbill.DNS .Record; | |
| 26 | import org .xbill.DNS .SOARecord ; | |
| 27 | import org .xbill.DNS .Type; | |
| 28 | ||
| 29 | public cla ss DNSReco rdCommands _removeRec ords_Test extends Te stCase | |
| 30 | { | |
| 31 | ab stract cla ss TestPla n extends BaseTestPl an | |
| 32 | { | |
| 33 | prot ected int port; | |
| 34 | prot ected DNSS erver serv er = null; | |
| 35 | prot ected Conf igurationS erviceProx y proxy; | |
| 36 | prot ected DNSR ecordComma nds record Commands; | |
| 37 | ||
| 38 | prot ected Reco rd toRecor d(DnsRecor d rec) thr ows Except ion | |
| 39 | { | |
| 40 | return Record.ne wRecord(Na me.fromStr ing(rec.ge tName()), rec.getTyp e(), rec.g etDclass() , rec.getT tl(), rec. getData()) ; | |
| 41 | } | |
| 42 | ||
| 43 | prot ected DnsR ecord from Record(Rec ord rec) t hrows Exce ption | |
| 44 | { | |
| 45 | DnsRec ord newRec = new Dns Record(); | |
| 46 | newRec .setData(r ec.rdataTo WireCanoni cal()); | |
| 47 | newRec .setDclass (rec.getDC lass()); | |
| 48 | newRec .setName(r ec.getName ().toStrin g()); | |
| 49 | newRec .setTtl(re c.getTTL() ); | |
| 50 | newRec .setType(r ec.getType ()); | |
| 51 | ||
| 52 | return newRec; | |
| 53 | } | |
| 54 | ||
| 55 | ||
| 56 | prot ected List <Record> g etRecordsI nStore(int type) thr ows Except ion | |
| 57 | { | |
| 58 | DnsRec ord[] reco rds = prox y.getDNSBy Type(type) ; | |
| 59 | ||
| 60 | List<R ecord> ret Val; | |
| 61 | ||
| 62 | if (re cords == n ull || rec ords.lengt h == 0) | |
| 63 | retVal = Collectio ns.emptyLi st(); | |
| 64 | else | |
| 65 | { | |
| 66 | retVal = new Array List<Recor d>(); | |
| 67 | for (Dns Record rec ord : reco rds) | |
| 68 | retVal.add (toRecord( record)); | |
| 69 | } | |
| 70 | ||
| 71 | return retVal; | |
| 72 | } | |
| 73 | ||
| 74 | @Ove rride | |
| 75 | prot ected void setupMock s() throws Exception | |
| 76 | { | |
| 77 | if (!C onfigServi ceRunner.i sServiceRu nning()) | |
| 78 | ConfigSe rviceRunne r.startCon figService (); | |
| 79 | ||
| 80 | proxy = new Conf igurationS erviceProx y(ConfigSe rviceRunne r.getConfi gServiceUR L()); | |
| 81 | ||
| 82 | cleanR ecords(); | |
| 83 | ||
| 84 | port = Available PortFinder .getNextAv ailable(10 24); | |
| 85 | DNSSer verSetting s settings = new DNS ServerSett ings(); | |
| 86 | settin gs.setPort (port); | |
| 87 | ||
| 88 | server = new DNS Server(new ConfigSer viceDNSSto re(new URL (ConfigSer viceRunner .getConfig ServiceURL ())), sett ings); | |
| 89 | ||
| 90 | server .start(); | |
| 91 | ||
| 92 | } | |
| 93 | ||
| 94 | @Ove rride | |
| 95 | prot ected void tearDownM ocks() thr ows Except ion | |
| 96 | { | |
| 97 | if (se rver != nu ll) | |
| 98 | server.s top(); | |
| 99 | } | |
| 100 | ||
| 101 | @Ove rride | |
| 102 | prot ected void performIn ner() thro ws Excepti on | |
| 103 | { | |
| 104 | record Commands = new DNSRe cordComman ds(proxy); | |
| 105 | ||
| 106 | List<R ecord> rec ordsToAdd = getRecor dsToAdd(); | |
| 107 | ||
| 108 | ||
| 109 | DnsRec ord[] addR ecs = new DnsRecord[ recordsToA dd.size()] ; | |
| 110 | int cn t = 0; | |
| 111 | for (R ecord reco rdToAdd : recordsToA dd) | |
| 112 | { | |
| 113 | addRecs[ cnt++] = f romRecord( recordToAd d); | |
| 114 | } | |
| 115 | ||
| 116 | proxy. addDNS(add Recs); | |
| 117 | ||
| 118 | addRec s = proxy. getDNSByTy pe(Type.AN Y); | |
| 119 | ||
| 120 | ||
| 121 | List<D nsRecord> recordsToR emove = ge tRecordsTo Remove(Arr ays.asList (addRecs)) ; | |
| 122 | for (D nsRecord r ecordToRem ove : reco rdsToRemov e) | |
| 123 | { | |
| 124 | switch ( recordToRe move.getTy pe()) | |
| 125 | { | |
| 126 | case Type. A: | |
| 127 | re cordComman ds.removeA NAME(new S tring[] {L ong.toStri ng(recordT oRemove.ge tId())}); | |
| 128 | br eak; | |
| 129 | case Type. MX: | |
| 130 | re cordComman ds.removeM X(new Stri ng[] {Long .toString( recordToRe move.getId ())}); | |
| 131 | br eak; | |
| 132 | case Type. SOA: | |
| 133 | re cordComman ds.removeS OA(new Str ing[] {Lon g.toString (recordToR emove.getI d())}); | |
| 134 | br eak; | |
| 135 | ||
| 136 | } | |
| 137 | ||
| 138 | } | |
| 139 | ||
| 140 | doAsse rtions(get RecordsInS tore(Type. ANY)); | |
| 141 | } | |
| 142 | ||
| 143 | priv ate void c leanRecord s() throws Exception | |
| 144 | { | |
| 145 | DnsRec ord[] rec = proxy.ge tDNSByType (Type.ANY) ; | |
| 146 | ||
| 147 | if (re c != null && rec.len gth > 0) | |
| 148 | proxy.re moveDNS(re c); | |
| 149 | ||
| 150 | rec = proxy.getD NSByType(T ype.ANY); | |
| 151 | ||
| 152 | assert Null(rec); | |
| 153 | ||
| 154 | } | |
| 155 | ||
| 156 | ||
| 157 | prot ected abst ract List< Record> ge tRecordsTo Add() thro ws Excepti on; | |
| 158 | ||
| 159 | prot ected abst ract List< DnsRecord> getRecord sToRemove( List<DnsRe cord> adde dRecords) throws Exc eption; | |
| 160 | ||
| 161 | prot ected abst ract void doAssertio ns(List<Re cord> rema iningRecor ds) throws Exception ; | |
| 162 | } | |
| 163 | ||
| 164 | pu blic void testRemove AllRecords _AssertRec ordRemove( ) throws E xception | |
| 165 | { | |
| 166 | new TestPlan() | |
| 167 | { | |
| 168 | privat e List<Rec ord> recor dsToAdd; | |
| 169 | ||
| 170 | @Overr ide | |
| 171 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 172 | { | |
| 173 | recordsT oAdd = new ArrayList <Record>() ; | |
| 174 | ||
| 175 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.1 "))); | |
| 176 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample.dom ain.com.") , DClass.I N, 3600, | |
| 177 | 1, Name.from String("ma il1.exampl e.domain.c om."))); | |
| 178 | recordsT oAdd.add(n ew SOAReco rd(Name.fr omString(" example.do main.com." ), DClass. IN, 3600, Name.fromS tring("ns1 .example.d omain.com. "), | |
| 179 | Na me.fromStr ing("gm255 2.example. domain.com ."), 1, 36 00, 60, 60 , 3600)); | |
| 180 | ||
| 181 | return r ecordsToAd d; | |
| 182 | } | |
| 183 | ||
| 184 | @Overr ide | |
| 185 | protec ted List<D nsRecord> getRecords ToRemove(L ist<DnsRec ord> added Records) t hrows Exce ption | |
| 186 | { | |
| 187 | return a ddedRecord s; | |
| 188 | } | |
| 189 | ||
| 190 | @Overr ide | |
| 191 | protec ted void d oAssertion s(List<Rec ord> remai ningRecord s) throws Exception | |
| 192 | { | |
| 193 | assertNo tNull(rema iningRecor ds); | |
| 194 | assertEq uals(0, re mainingRec ords.size( )); | |
| 195 | } | |
| 196 | ||
| 197 | }.pe rform(); | |
| 198 | } | |
| 199 | ||
| 200 | ||
| 201 | pu blic void testRemove OnlyARecor ds_AssertO nlyARecord Removed() throws Exc eption | |
| 202 | { | |
| 203 | new TestPlan() | |
| 204 | { | |
| 205 | privat e List<Rec ord> recor dsToAdd; | |
| 206 | privat e List<Rec ord> expec tedRemaini ngRecords; | |
| 207 | ||
| 208 | ||
| 209 | @Overr ide | |
| 210 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 211 | { | |
| 212 | recordsT oAdd = new ArrayList <Record>() ; | |
| 213 | ||
| 214 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.1 "))); | |
| 215 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.2 "))); | |
| 216 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample.dom ain.com.") , DClass.I N, 3600, | |
| 217 | 1, Name.from String("ma il1.exampl e.domain.c om."))); | |
| 218 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample2.do main.com." ), DClass. IN, 3600, | |
| 219 | 1, Name.from String("ma il2.exampl 2.domain.c om."))); | |
| 220 | ||
| 221 | recordsT oAdd.add(n ew SOAReco rd(Name.fr omString(" example.do main.com." ), DClass. IN, 3600, Name.fromS tring("ns1 .example.d omain.com. "), | |
| 222 | Na me.fromStr ing("gm255 2.example. domain.com ."), 1, 36 00, 60, 60 , 3600)); | |
| 223 | ||
| 224 | return r ecordsToAd d; | |
| 225 | } | |
| 226 | ||
| 227 | @Overr ide | |
| 228 | protec ted List<D nsRecord> getRecords ToRemove(L ist<DnsRec ord> added Records) t hrows Exce ption | |
| 229 | { | |
| 230 | List<Dns Record> re tVal = new ArrayList <DnsRecord >(); | |
| 231 | expected RemainingR ecords = n ew ArrayLi st<Record> (); | |
| 232 | ||
| 233 | for (Dns Record add edRecord : addedReco rds) | |
| 234 | { | |
| 235 | if (addedR ecord.getT ype() == T ype.A) | |
| 236 | re tVal.add(a ddedRecord ); | |
| 237 | else | |
| 238 | ex pectedRema iningRecor ds.add(toR ecord(adde dRecord)); | |
| 239 | } | |
| 240 | ||
| 241 | return r etVal; | |
| 242 | } | |
| 243 | ||
| 244 | @Overr ide | |
| 245 | protec ted void d oAssertion s(List<Rec ord> remai ningRecord s) throws Exception | |
| 246 | { | |
| 247 | assertNo tNull(rema iningRecor ds); | |
| 248 | assertEq uals(3, re mainingRec ords.size( )); | |
| 249 | ||
| 250 | for (Rec ord expect edRemainin g : expect edRemainin gRecords) | |
| 251 | { | |
| 252 | int index = remainin gRecords.i ndexOf(exp ectedRemai ning); | |
| 253 | assertTrue (index >= 0); | |
| 254 | ||
| 255 | Record che ckRecord = remaining Records.ge t(index); | |
| 256 | assertTrue (checkReco rd.getType () != Type .A); | |
| 257 | assertEqua ls(checkRe cord, expe ctedRemain ing); | |
| 258 | } | |
| 259 | } | |
| 260 | ||
| 261 | }.pe rform(); | |
| 262 | } | |
| 263 | ||
| 264 | pu blic void testRemove AllExceptA Records_As sertAllExc eptARecord Removed() throws Exc eption | |
| 265 | { | |
| 266 | new TestPlan() | |
| 267 | { | |
| 268 | privat e List<Rec ord> recor dsToAdd; | |
| 269 | privat e List<Rec ord> expec tedRemaini ngRecords; | |
| 270 | ||
| 271 | ||
| 272 | @Overr ide | |
| 273 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 274 | { | |
| 275 | recordsT oAdd = new ArrayList <Record>() ; | |
| 276 | ||
| 277 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.1 "))); | |
| 278 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.2 "))); | |
| 279 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample.dom ain.com.") , DClass.I N, 3600, | |
| 280 | 1, Name.from String("ma il1.exampl e.domain.c om."))); | |
| 281 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample2.do main.com." ), DClass. IN, 3600, | |
| 282 | 1, Name.from String("ma il2.exampl 2.domain.c om."))); | |
| 283 | ||
| 284 | recordsT oAdd.add(n ew SOAReco rd(Name.fr omString(" example.do main.com." ), DClass. IN, 3600, Name.fromS tring("ns1 .example.d omain.com. "), | |
| 285 | Na me.fromStr ing("gm255 2.example. domain.com ."), 1, 36 00, 60, 60 , 3600)); | |
| 286 | ||
| 287 | return r ecordsToAd d; | |
| 288 | } | |
| 289 | ||
| 290 | @Overr ide | |
| 291 | protec ted List<D nsRecord> getRecords ToRemove(L ist<DnsRec ord> added Records) t hrows Exce ption | |
| 292 | { | |
| 293 | List<Dns Record> re tVal = new ArrayList <DnsRecord >(); | |
| 294 | expected RemainingR ecords = n ew ArrayLi st<Record> (); | |
| 295 | ||
| 296 | for (Dns Record add edRecord : addedReco rds) | |
| 297 | { | |
| 298 | if (addedR ecord.getT ype() != T ype.A) | |
| 299 | re tVal.add(a ddedRecord ); | |
| 300 | else | |
| 301 | ex pectedRema iningRecor ds.add(toR ecord(adde dRecord)); | |
| 302 | } | |
| 303 | ||
| 304 | return r etVal; | |
| 305 | } | |
| 306 | ||
| 307 | @Overr ide | |
| 308 | protec ted void d oAssertion s(List<Rec ord> remai ningRecord s) throws Exception | |
| 309 | { | |
| 310 | assertNo tNull(rema iningRecor ds); | |
| 311 | assertEq uals(2, re mainingRec ords.size( )); | |
| 312 | ||
| 313 | for (Rec ord expect edRemainin g : expect edRemainin gRecords) | |
| 314 | { | |
| 315 | int index = remainin gRecords.i ndexOf(exp ectedRemai ning); | |
| 316 | assertTrue (index >= 0); | |
| 317 | ||
| 318 | Record che ckRecord = remaining Records.ge t(index); | |
| 319 | assertTrue (checkReco rd.getType () == Type .A); | |
| 320 | assertEqua ls(checkRe cord, expe ctedRemain ing); | |
| 321 | } | |
| 322 | } | |
| 323 | ||
| 324 | }.pe rform(); | |
| 325 | } | |
| 326 | ||
| 327 | pu blic void testFailur eToRemove_ invalidPro xy_AssertE xception() throws Ex ception | |
| 328 | { | |
| 329 | new TestPlan() | |
| 330 | { | |
| 331 | privat e List<Rec ord> recor dsToAdd; | |
| 332 | ||
| 333 | @Overr ide | |
| 334 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 335 | { | |
| 336 | recordsT oAdd = new ArrayList <Record>() ; | |
| 337 | ||
| 338 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.1 "))); | |
| 339 | ||
| 340 | return r ecordsToAd d; | |
| 341 | } | |
| 342 | ||
| 343 | @Overr ide | |
| 344 | protec ted List<D nsRecord> getRecords ToRemove(L ist<DnsRec ord> added Records) t hrows Exce ption | |
| 345 | { | |
| 346 | this.recor dCommands. setConfigu rationProx y(new Conf igurationS erviceProx y("http:// localhost: PORT /bogusendp oint")); | |
| 347 | return a ddedRecord s; | |
| 348 | } | |
| 349 | ||
| 350 | @Overr ide | |
| 351 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 352 | { | |
| 353 | assertNo tNull(exce ption); | |
| 354 | assertTr ue(excepti on instanc eof Runtim eException ); | |
| 355 | assertTr ue(excepti on.getCaus e() instan ceof AxisF ault); | |
| 356 | ||
| 357 | ||
| 358 | } | |
| 359 | ||
| 360 | @Overr ide | |
| 361 | protec ted void d oAssertion s(List<Rec ord> remai ningRecord s) throws Exception | |
| 362 | { | |
| 363 | ||
| 364 | } | |
| 365 | ||
| 366 | }.pe rform(); | |
| 367 | } | |
| 368 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.