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_getAll_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_getAll_Test.java | Tue May 22 20:59:39 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 468 |
| 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 org .apache.ax is.AxisFau lt; | |
| 10 | import org .apache.mi na.util.Av ailablePor tFinder; | |
| 11 | import org .nhind.con fig.Config urationSer viceProxy; | |
| 12 | import org .nhind.con fig.DnsRec ord; | |
| 13 | import org .nhindirec t.dns.Conf igServiceD NSStore; | |
| 14 | import org .nhindirec t.dns.DNSS erver; | |
| 15 | import org .nhindirec t.dns.DNSS erverSetti ngs; | |
| 16 | import org .nhindirec t.dns.util .BaseTestP lan; | |
| 17 | import org .nhindirec t.dns.util .ConfigSer viceRunner ; | |
| 18 | import org .xbill.DNS .ARecord; | |
| 19 | import org .xbill.DNS .DClass; | |
| 20 | import org .xbill.DNS .MXRecord; | |
| 21 | import org .xbill.DNS .Name; | |
| 22 | import org .xbill.DNS .Record; | |
| 23 | import org .xbill.DNS .SOARecord ; | |
| 24 | import org .xbill.DNS .Type; | |
| 25 | ||
| 26 | import jun it.framewo rk.TestCas e; | |
| 27 | ||
| 28 | public cla ss DNSReco rdCommands _getAll_Te st extends TestCase | |
| 29 | { | |
| 30 | ab stract cla ss TestPla n extends BaseTestPl an | |
| 31 | { | |
| 32 | pr otected Mo ckDNSRecor dPrinter r ecordPrint er; | |
| 33 | ||
| 34 | prot ected int port; | |
| 35 | prot ected DNSS erver serv er = null; | |
| 36 | prot ected Conf igurationS erviceProx y proxy; | |
| 37 | prot ected DNSR ecordComma nds record Commands; | |
| 38 | ||
| 39 | prot ected Reco rd toRecor d(DnsRecor d rec) thr ows Except ion | |
| 40 | { | |
| 41 | return Record.ne wRecord(Na me.fromStr ing(rec.ge tName()), rec.getTyp e(), rec.g etDclass() , rec.getT tl(), rec. getData()) ; | |
| 42 | } | |
| 43 | ||
| 44 | prot ected DnsR ecord from Record(Rec ord rec) t hrows Exce ption | |
| 45 | { | |
| 46 | DnsRec ord newRec = new Dns Record(); | |
| 47 | newRec .setData(r ec.rdataTo WireCanoni cal()); | |
| 48 | newRec .setDclass (rec.getDC lass()); | |
| 49 | newRec .setName(r ec.getName ().toStrin g()); | |
| 50 | newRec .setTtl(re c.getTTL() ); | |
| 51 | newRec .setType(r ec.getType ()); | |
| 52 | ||
| 53 | return newRec; | |
| 54 | } | |
| 55 | ||
| 56 | ||
| 57 | @Ove rride | |
| 58 | prot ected void setupMock s() throws Exception | |
| 59 | { | |
| 60 | if (!C onfigServi ceRunner.i sServiceRu nning()) | |
| 61 | ConfigSe rviceRunne r.startCon figService (); | |
| 62 | ||
| 63 | proxy = new Conf igurationS erviceProx y(ConfigSe rviceRunne r.getConfi gServiceUR L()); | |
| 64 | ||
| 65 | cleanR ecords(); | |
| 66 | ||
| 67 | port = Available PortFinder .getNextAv ailable(10 24); | |
| 68 | DNSSer verSetting s settings = new DNS ServerSett ings(); | |
| 69 | settin gs.setPort (port); | |
| 70 | ||
| 71 | server = new DNS Server(new ConfigSer viceDNSSto re(new URL (ConfigSer viceRunner .getConfig ServiceURL ())), sett ings); | |
| 72 | ||
| 73 | server .start(); | |
| 74 | ||
| 75 | record Printer = new MockDN SRecordPri nter(); | |
| 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 | record Commands.s etRecordPr inter(reco rdPrinter) ; | |
| 90 | ||
| 91 | List<R ecord> rec ordsToAdd = getRecor dsToAdd(); | |
| 92 | ||
| 93 | ||
| 94 | if (re cordsToAdd .size() > 0) | |
| 95 | { | |
| 96 | DnsRecor d[] addRec s = new Dn sRecord[re cordsToAdd .size()]; | |
| 97 | int cnt = 0; | |
| 98 | for (Rec ord record ToAdd : re cordsToAdd ) | |
| 99 | { | |
| 100 | addRecs[cn t++] = fro mRecord(re cordToAdd) ; | |
| 101 | } | |
| 102 | ||
| 103 | proxy.ad dDNS(addRe cs); | |
| 104 | } | |
| 105 | ||
| 106 | record Commands.g etAll(new String[] { }); | |
| 107 | ||
| 108 | List<R ecord> mat chedRecord s = new Ar rayList<Re cord>(); | |
| 109 | for (D nsRecord m atchedReco rd : recor dPrinter.p rintedReco rds) | |
| 110 | matchedR ecords.add (toRecord( matchedRec ord)); | |
| 111 | ||
| 112 | doAsse rtions(mat chedRecord s); | |
| 113 | } | |
| 114 | ||
| 115 | priv ate void c leanRecord s() throws Exception | |
| 116 | { | |
| 117 | DnsRec ord[] rec = proxy.ge tDNSByType (Type.ANY) ; | |
| 118 | ||
| 119 | if (re c != null && rec.len gth > 0) | |
| 120 | proxy.re moveDNS(re c); | |
| 121 | ||
| 122 | rec = proxy.getD NSByType(T ype.ANY); | |
| 123 | ||
| 124 | assert Null(rec); | |
| 125 | ||
| 126 | } | |
| 127 | ||
| 128 | prot ected abst ract List< Record> ge tRecordsTo Add() thro ws Excepti on; | |
| 129 | ||
| 130 | prot ected abst ract void doAssertio ns(List<Re cord> reco rdsMatched ) throws E xception; | |
| 131 | } | |
| 132 | ||
| 133 | ||
| 134 | pu blic void testGetRec ords_Asser tAllRecord Fetched() throws Exc eption | |
| 135 | { | |
| 136 | new TestPlan() | |
| 137 | { | |
| 138 | privat e List<Rec ord> recor dsToAdd; | |
| 139 | ||
| 140 | @Overr ide | |
| 141 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 142 | { | |
| 143 | recordsT oAdd = new ArrayList <Record>() ; | |
| 144 | ||
| 145 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.1 "))); | |
| 146 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample.doma in.com."), DClass.IN , 3600, In etAddress. getByName( "127.0.0.2 "))); | |
| 147 | ||
| 148 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample.dom ain.com.") , DClass.I N, 3600, | |
| 149 | 1, Name.from String("ma il1.exampl e.domain.c om."))); | |
| 150 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("e xample.dom ain.com.") , DClass.I N, 3600, | |
| 151 | 1, Name.from String("ma il2.exampl 2.domain.c om."))); | |
| 152 | ||
| 153 | 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. "), | |
| 154 | Na me.fromStr ing("gm255 2.example. domain.com ."), 1, 36 00, 60, 60 , 3600)); | |
| 155 | ||
| 156 | ||
| 157 | recordsT oAdd.add(n ew ARecord (Name.from String("do main.com." ), DClass. IN, 3600, InetAddres s.getByNam e("127.0.0 .5"))); | |
| 158 | ||
| 159 | recordsT oAdd.add(n ew MXRecor d(Name.fro mString("d omain.com. "), DClass .IN, 3600, | |
| 160 | 1, Name.from String("ma il1.domain .com."))); | |
| 161 | ||
| 162 | recordsT oAdd.add(n ew SOAReco rd(Name.fr omString(" domain.com ."), DClas s.IN, 3600 , Name.fro mString("n s1.domain. com."), | |
| 163 | Na me.fromStr ing("gm255 2.domain.c om."), 1, 3600, 60, 60, 3600)) ; | |
| 164 | ||
| 165 | recordsT oAdd.add(n ew ARecord (Name.from String("ex ample2.dom ain.com.") , DClass.I N, 3600, I netAddress .getByName ("127.0.0. 5"))); | |
| 166 | ||
| 167 | return r ecordsToAd d; | |
| 168 | } | |
| 169 | ||
| 170 | @Overr ide | |
| 171 | protec ted void d oAssertion s(List<Rec ord> recor dsMatched) throws Ex ception | |
| 172 | { | |
| 173 | assertNo tNull(reco rdsMatched ); | |
| 174 | assertEq uals(9, re cordsMatch ed.size()) ; | |
| 175 | ||
| 176 | for (Rec ord record : records ToAdd) | |
| 177 | { | |
| 178 | int index = recordsT oAdd.index Of(record) ; | |
| 179 | assertTrue (index > - 1); | |
| 180 | Record che ckRecord = recordsTo Add.get(in dex); | |
| 181 | assertEqua ls(record, checkReco rd); | |
| 182 | } | |
| 183 | } | |
| 184 | }.pe rform(); | |
| 185 | } | |
| 186 | ||
| 187 | pu blic void testGetRec ords_empty Store_Asse rtNoRecord sFetched() throws Ex ception | |
| 188 | { | |
| 189 | new TestPlan() | |
| 190 | { | |
| 191 | ||
| 192 | @Overr ide | |
| 193 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 194 | { | |
| 195 | ||
| 196 | return C ollections .emptyList (); | |
| 197 | } | |
| 198 | ||
| 199 | ||
| 200 | @Overr ide | |
| 201 | protec ted void d oAssertion s(List<Rec ord> recor dsMatched) throws Ex ception | |
| 202 | { | |
| 203 | assertNo tNull(reco rdsMatched ); | |
| 204 | assertEq uals(0, re cordsMatch ed.size()) ; | |
| 205 | } | |
| 206 | }.pe rform(); | |
| 207 | } | |
| 208 | ||
| 209 | pu blic void testFailur eToFetchRe cords_inva lidProxy_A ssertExcep tion() thr ows Except ion | |
| 210 | { | |
| 211 | new TestPlan() | |
| 212 | { | |
| 213 | ||
| 214 | @Overr ide | |
| 215 | protec ted List<R ecord> get RecordsToA dd() throw s Exceptio n | |
| 216 | { | |
| 217 | this.recor dCommands. setConfigu rationProx y(new Conf igurationS erviceProx y("http:// localhost: PORT /bogusendp oint")); | |
| 218 | return C ollections .emptyList (); | |
| 219 | } | |
| 220 | ||
| 221 | @Overr ide | |
| 222 | protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on | |
| 223 | { | |
| 224 | assertNo tNull(exce ption); | |
| 225 | assertTr ue(excepti on instanc eof Runtim eException ); | |
| 226 | assertTr ue(excepti on.getCaus e() instan ceof AxisF ault); | |
| 227 | } | |
| 228 | ||
| 229 | @Overr ide | |
| 230 | protec ted void d oAssertion s(List<Rec ord> recor dsMatched) throws Ex ception | |
| 231 | { | |
| 232 | } | |
| 233 | }.pe rform(); | |
| 234 | } | |
| 235 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.