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_ensureARecords_Test.java | Tue May 22 13:40:36 2018 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\dns\src\test\java\org\nhindirect\dns\tools | DNSRecordCommands_ensureARecords_Test.java | Tue May 22 20:59:38 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 596 |
| 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.Col lections; | |
| 7 | import jav a.util.Lis t; | |
| 8 | ||
| 9 | import jun it.framewo rk.TestCas e; | |
| 10 | ||
| 11 | import org .apache.ax is.AxisFau lt; | |
| 12 | import org .apache.mi na.util.Av ailablePor tFinder; | |
| 13 | import org .nhind.con fig.Config urationSer viceProxy; | |
| 14 | import org .nhind.con fig.DnsRec ord; | |
| 15 | import org .nhindirec t.dns.Conf igServiceD NSStore; | |
| 16 | import org .nhindirec t.dns.DNSS erver; | |
| 17 | import org .nhindirec t.dns.DNSS erverSetti ngs; | |
| 18 | import org .nhindirec t.dns.util .BaseTestP lan; | |
| 19 | import org .nhindirec t.dns.util .ConfigSer viceRunner ; | |
| 20 | import org .xbill.DNS .ARecord; | |
| 21 | import org .xbill.DNS .DClass; | |
| 22 | import org .xbill.DNS .Name; | |
| 23 | import org .xbill.DNS .Record; | |
| 24 | import org .xbill.DNS .Type; | |
| 25 | ||
| 26 | public cla ss DNSReco rdCommands _ensureARe cords_Test extends T estCase | |
| 27 | { | |
| 28 | ab stract cla ss TestPla n extends BaseTestPl an | |
| 29 | { | |
| 30 | prot ected int port; | |
| 31 | prot ected DNSS erver serv er = null; | |
| 32 | prot ected Conf igurationS erviceProx y proxy; | |
| 33 | prot ected DNSR ecordComma nds record Commands; | |
| 34 | ||
| 35 | prot ected Reco rd toRecor d(DnsRecor d rec) thr ows Except ion | |
| 36 | { | |
| 37 | return Record.ne wRecord(Na me.fromStr ing(rec.ge tName()), rec.getTyp e(), rec.g etDclass() , rec.getT tl(), rec. getData()) ; | |
| 38 | } | |
| 39 | ||
| 40 | prot ected List <Record> g etARecords InStore() throws Exc eption | |
| 41 | { | |
| 42 | DnsRec ord[] reco rds = prox y.getDNSBy Type(Type. A); | |
| 43 | ||
| 44 | List<R ecord> ret Val; | |
| 45 | ||
| 46 | if (re cords == n ull || rec ords.lengt h == 0) | |
| 47 | retVal = Collectio ns.emptyLi st(); | |
| 48 | else | |
| 49 | { | |
| 50 | retVal = new Array List<Recor d>(); | |
| 51 | for (Dns Record rec ord : reco rds) | |
| 52 | retVal.add (toRecord( record)); | |
| 53 | } | |
| 54 | ||
| 55 | return retVal; | |
| 56 | } | |
| 57 | ||
| 58 | @Ove rride | |
| 59 | prot ected void setupMock s() throws Exception | |
| 60 | { | |
| 61 | if (!C onfigServi ceRunner.i sServiceRu nning()) | |
| 62 | ConfigSe rviceRunne r.startCon figService (); | |
| 63 | ||
| 64 | proxy = new Conf igurationS erviceProx y(ConfigSe rviceRunne r.getConfi gServiceUR L()); | |
| 65 | ||
| 66 | cleanR ecords(); | |
| 67 | ||
| 68 | port = Available PortFinder .getNextAv ailable(10 24); | |
| 69 | DNSSer verSetting s settings = new DNS ServerSett ings(); | |
| 70 | settin gs.setPort (port); | |
| 71 | ||
| 72 | server = new DNS Server(new ConfigSer viceDNSSto re(new URL (ConfigSer viceRunner .getConfig ServiceURL ())), sett ings); | |
| 73 | ||
| 74 | server .start(); | |
| 75 | ||
| 76 | } | |
| 77 | ||
| 78 | @Ove rride | |
| 79 | prot ected void tearDownM ocks() thr ows Except ion | |
| 80 | { | |
| 81 | if (se rver != nu ll) | |
| 82 | server.s top(); | |
| 83 | } | |
| 84 | ||
| 85 | @Ove rride | |
| 86 | prot ected void performIn ner() thro ws Excepti on | |
| 87 | { | |
| 88 | record Commands = new DNSRe cordComman ds(proxy); | |
| 89 | ||
| 90 | List<R ecord> rec ordsToAdd = getRecor dsToAdd(); | |
| 91 | ||
| 92 | ||
| 93 | for (R ecord reco rdToAdd : recordsToA dd) | |
| 94 | { | |
| 95 | ARecord rec = (ARe cord)recor dToAdd; | |
| 96 | String[] command = {rec.getN ame().toSt ring(), re c.getAddre ss().getHo stAddress( ), Long.to String(rec .getTTL()) }; | |
| 97 | recordCo mmands.ens ureANAME(c ommand); | |
| 98 | } | |
| 99 | ||
| 100 | ||
| 101 | doAsse rtions(get ARecordsIn Store()); | |
| 102 | } | |
| 103 | ||
| 104 | priv ate void c leanRecord s() throws Exception | |
| 105 | { | |
| 106 | DnsRec ord[] rec = proxy.ge tDNSByType (Type.ANY) ; | |
| 107 | ||
| 108 | if (re c != null && rec.len gth > 0) | |
| 109 | proxy.re moveDNS(re c); | |
| 110 | ||
| 111 | rec = proxy.getD NSByType(T ype.ANY); | |
| 112 | ||
| 113 | assert Null(rec); | |
| 114 | ||
| 115 | } | |
| 116 | ||
| 117 | ||
| 118 | prot ected abst ract List< Record> ge tRecordsTo Add() thro ws Excepti on; | |
| 119 | ||
| 120 | prot ected abst ract void doAssertio ns(List<Re cord> reco rds) throw s Exceptio n; | |
| 121 | } | |
| 122 | ||
| 123 | pu blic void testEnsure AName_Asse rtRecordAd ded() thro ws Excepti on | |
| 124 | { | |
| 125 | new TestPlan() | |
| 126 | { | |
| 127 | @Overr ide | |
| 128 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 129 | { | |
| 130 | List<Rec ord> addRe cords = ne w ArrayLis t<Record>( ); | |
| 131 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.1") )); | |
| 132 | ||
| 133 | return a ddRecords; | |
| 134 | } | |
| 135 | ||
| 136 | @Overr ide | |
| 137 | protec ted void d oAssertion s(List<Rec ord> recor ds) throws Exception | |
| 138 | { | |
| 139 | assertNo tNull(reco rds); | |
| 140 | assertEq uals(1, re cords.size ()); | |
| 141 | ||
| 142 | Record r ec = recor ds.iterato r().next() ; | |
| 143 | assertEq uals("exam ple.domain .com.", re c.getName( ).toString ()); | |
| 144 | assertEq uals(3600, rec.getTT L()); | |
| 145 | assertEq uals(Type. A, rec.get Type()); | |
| 146 | assertEq uals(DClas s.IN, rec. getDClass( )); | |
| 147 | ||
| 148 | ARecord aRec = (AR ecord)rec; | |
| 149 | assertEq uals(aRec. getAddress ().getHost Address(), "127.0.0. 1"); | |
| 150 | ||
| 151 | } | |
| 152 | ||
| 153 | }.pe rform(); | |
| 154 | } | |
| 155 | ||
| 156 | pu blic void testEnsure AName_Asse rtOneEntry () throws Exception | |
| 157 | { | |
| 158 | new TestPlan() | |
| 159 | { | |
| 160 | @Overr ide | |
| 161 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 162 | { | |
| 163 | List<Rec ord> addRe cords = ne w ArrayLis t<Record>( ); | |
| 164 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.1") )); | |
| 165 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.1") )); | |
| 166 | ||
| 167 | return a ddRecords; | |
| 168 | } | |
| 169 | ||
| 170 | @Overr ide | |
| 171 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 172 | { | |
| 173 | ||
| 174 | } | |
| 175 | ||
| 176 | @Overr ide | |
| 177 | protec ted void d oAssertion s(List<Rec ord> recor ds) throws Exception | |
| 178 | { | |
| 179 | // make sure the f irst comma nd worked | |
| 180 | ||
| 181 | assertNo tNull(reco rds); | |
| 182 | assertEq uals(1, re cords.size ()); | |
| 183 | ||
| 184 | Record r ec = recor ds.iterato r().next() ; | |
| 185 | assertEq uals("exam ple.domain .com.", re c.getName( ).toString ()); | |
| 186 | assertEq uals(3600, rec.getTT L()); | |
| 187 | assertEq uals(Type. A, rec.get Type()); | |
| 188 | assertEq uals(DClas s.IN, rec. getDClass( )); | |
| 189 | ||
| 190 | ARecord aRec = (AR ecord)rec; | |
| 191 | assertEq uals(aRec. getAddress ().getHost Address(), "127.0.0. 1"); | |
| 192 | } | |
| 193 | ||
| 194 | }.pe rform(); | |
| 195 | } | |
| 196 | ||
| 197 | pu blic void testEnsure MultipleRe cords_Asse rtRecordsA dded() thr ows Except ion | |
| 198 | { | |
| 199 | new TestPlan() | |
| 200 | { | |
| 201 | privat e List<Rec ord> addRe cords; | |
| 202 | ||
| 203 | @Overr ide | |
| 204 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 205 | { | |
| 206 | addRecor ds = new A rrayList<R ecord>(); | |
| 207 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple1.domai n.com."), DClass.IN, 3600, Ine tAddress.g etByName(" 127.0.0.1" ))); | |
| 208 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple2.domai n.com."), DClass.IN, 3600, Ine tAddress.g etByName(" 127.0.0.2" ))); | |
| 209 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple3.domai n.com."), DClass.IN, 3600, Ine tAddress.g etByName(" 127.0.0.3" ))); | |
| 210 | ||
| 211 | return a ddRecords; | |
| 212 | } | |
| 213 | ||
| 214 | ||
| 215 | @Overr ide | |
| 216 | protec ted void d oAssertion s(List<Rec ord> recor ds) throws Exception | |
| 217 | { | |
| 218 | assertNo tNull(reco rds); | |
| 219 | assertEq uals(3, re cords.size ()); | |
| 220 | ||
| 221 | for (Rec ord record : addReco rds) | |
| 222 | { | |
| 223 | int index = records. indexOf(re cord); | |
| 224 | assertTrue (index > - 1); | |
| 225 | Record che ckRecord = records.g et(index); | |
| 226 | assertEqua ls(record, checkReco rd); | |
| 227 | } | |
| 228 | } | |
| 229 | ||
| 230 | }.pe rform(); | |
| 231 | } | |
| 232 | ||
| 233 | pu blic void testEnsure MultipleRe cords_Same NameDiffIP _AssertRec ordsAdded( ) throws E xception | |
| 234 | { | |
| 235 | new TestPlan() | |
| 236 | { | |
| 237 | privat e List<Rec ord> addRe cords; | |
| 238 | ||
| 239 | @Overr ide | |
| 240 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 241 | { | |
| 242 | addRecor ds = new A rrayList<R ecord>(); | |
| 243 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.1") )); | |
| 244 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.2") )); | |
| 245 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.3") )); | |
| 246 | ||
| 247 | return a ddRecords; | |
| 248 | } | |
| 249 | ||
| 250 | ||
| 251 | @Overr ide | |
| 252 | protec ted void d oAssertion s(List<Rec ord> recor ds) throws Exception | |
| 253 | { | |
| 254 | assertNo tNull(reco rds); | |
| 255 | assertEq uals(3, re cords.size ()); | |
| 256 | ||
| 257 | for (Rec ord record : addReco rds) | |
| 258 | { | |
| 259 | int index = records. indexOf(re cord); | |
| 260 | assertTrue (index > - 1); | |
| 261 | Record che ckRecord = records.g et(index); | |
| 262 | assertEqua ls(record, checkReco rd); | |
| 263 | } | |
| 264 | } | |
| 265 | ||
| 266 | }.pe rform(); | |
| 267 | } | |
| 268 | ||
| 269 | pu blic void testFailTo Ensure_inv alidProxy_ AssertExce ption() th rows Excep tion | |
| 270 | { | |
| 271 | new TestPlan() | |
| 272 | { | |
| 273 | privat e List<Rec ord> addRe cords; | |
| 274 | ||
| 275 | @Overr ide | |
| 276 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 277 | { | |
| 278 | addRecor ds = new A rrayList<R ecord>(); | |
| 279 | addRecor ds.add(new ARecord(N ame.fromSt ring("exam ple.domain .com."), D Class.IN, 3600, Inet Address.ge tByName("1 27.0.0.1") )); | |
| 280 | ||
| 281 | this.recor dCommands. setConfigu rationProx y(new Conf igurationS erviceProx y("http:// localhost: PORT /bogusendp oint")); | |
| 282 | return a ddRecords; | |
| 283 | } | |
| 284 | ||
| 285 | @Overr ide | |
| 286 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 287 | { | |
| 288 | assertNo tNull(exce ption); | |
| 289 | assertTr ue(excepti on instanc eof Runtim eException ); | |
| 290 | assertTr ue(excepti on.getCaus e() instan ceof AxisF ault); | |
| 291 | } | |
| 292 | ||
| 293 | @Overr ide | |
| 294 | protec ted void d oAssertion s(List<Rec ord> recor dsMatched) throws Ex ception | |
| 295 | { | |
| 296 | } | |
| 297 | }.pe rform(); | |
| 298 | } | |
| 299 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.