|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DNSTask | Line # 20 | 69 | 0% | 13 | 52 | 32.5% |
0.32467532
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (21) | |||
| Result | |||
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testUnregisterService
javax.jmdns.test.JmDNSTest.testUnregisterService
|
1 PASS | |
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
|
1 PASS | |
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
|
1 PASS | |
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testListMyService
javax.jmdns.test.JmDNSTest.testListMyService
|
1 PASS | |
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
|
1 PASS | |
|
0.32467532
|
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.TextUpdateTest.testSubtype
javax.jmdns.test.TextUpdateTest.testSubtype
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testRegisterServiceTwice
javax.jmdns.test.JmDNSTest.testRegisterServiceTwice
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testRegisterService
javax.jmdns.test.JmDNSTest.testRegisterService
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testQueryMyService
javax.jmdns.test.JmDNSTest.testQueryMyService
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testListenForMyService
javax.jmdns.test.JmDNSTest.testListenForMyService
|
1 PASS | |
|
0.25974026
|
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
|
1 PASS | |
|
0.24675325
|
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
|
1 PASS | |
|
0.064935066
|
javax.jmdns.test.JmDNSTest.testCreate
javax.jmdns.test.JmDNSTest.testCreate
|
1 PASS | |
|
0.064935066
|
javax.jmdns.test.JmDNSTest.testCreateINet
javax.jmdns.test.JmDNSTest.testCreateINet
|
1 PASS | |
| 1 | // Licensed under Apache License version 2.0 | |
| 2 | package javax.jmdns.impl.tasks; | |
| 3 | ||
| 4 | import java.io.IOException; | |
| 5 | import java.util.Timer; | |
| 6 | import java.util.TimerTask; | |
| 7 | ||
| 8 | import javax.jmdns.impl.DNSIncoming; | |
| 9 | import javax.jmdns.impl.DNSOutgoing; | |
| 10 | import javax.jmdns.impl.DNSQuestion; | |
| 11 | import javax.jmdns.impl.DNSRecord; | |
| 12 | import javax.jmdns.impl.JmDNSImpl; | |
| 13 | import javax.jmdns.impl.constants.DNSConstants; | |
| 14 | ||
| 15 | /** | |
| 16 | * This is the root class for all task scheduled by the timer in JmDNS. | |
| 17 | * | |
| 18 | * @author Pierre Frisch | |
| 19 | */ | |
| 20 | public abstract class DNSTask extends TimerTask { | |
| 21 | ||
| 22 | /** | |
| 23 | * | |
| 24 | */ | |
| 25 | private final JmDNSImpl _jmDNSImpl; | |
| 26 | ||
| 27 | /** | |
| 28 | * @param jmDNSImpl | |
| 29 | */ | |
| 30 | 603 |
protected DNSTask(JmDNSImpl jmDNSImpl) { |
| 31 | 589 | super(); |
| 32 | 599 | this._jmDNSImpl = jmDNSImpl; |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Return the DNS associated with this task. | |
| 37 | * | |
| 38 | * @return associated DNS | |
| 39 | */ | |
| 40 | 7996 |
public JmDNSImpl getDns() { |
| 41 | 7998 | return _jmDNSImpl; |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * Start this task. | |
| 46 | * | |
| 47 | * @param timer | |
| 48 | * task timer. | |
| 49 | */ | |
| 50 | public abstract void start(Timer timer); | |
| 51 | ||
| 52 | /** | |
| 53 | * Return this task name. | |
| 54 | * | |
| 55 | * @return task name | |
| 56 | */ | |
| 57 | public abstract String getName(); | |
| 58 | ||
| 59 | /* | |
| 60 | * (non-Javadoc) | |
| 61 | * @see java.lang.Object#toString() | |
| 62 | */ | |
| 63 | 0 |
@Override |
| 64 | public String toString() { | |
| 65 | 0 | return this.getName(); |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Add a question to the message. | |
| 70 | * | |
| 71 | * @param out | |
| 72 | * outgoing message | |
| 73 | * @param rec | |
| 74 | * DNS question | |
| 75 | * @return outgoing message for the next question | |
| 76 | * @exception IOException | |
| 77 | */ | |
| 78 | 141 |
public DNSOutgoing addQuestion(DNSOutgoing out, DNSQuestion rec) throws IOException { |
| 79 | 141 | DNSOutgoing newOut = out; |
| 80 | 141 | try { |
| 81 | 141 | newOut.addQuestion(rec); |
| 82 | } catch (final IOException e) { | |
| 83 | 0 | int flags = newOut.getFlags(); |
| 84 | 0 | boolean multicast = newOut.isMulticast(); |
| 85 | 0 | int maxUDPPayload = newOut.getMaxUDPPayload(); |
| 86 | 0 | int id = newOut.getId(); |
| 87 | ||
| 88 | 0 | newOut.setFlags(flags | DNSConstants.FLAGS_TC); |
| 89 | 0 | newOut.setId(id); |
| 90 | 0 | this._jmDNSImpl.send(newOut); |
| 91 | ||
| 92 | 0 | newOut = new DNSOutgoing(flags, multicast, maxUDPPayload); |
| 93 | 0 | newOut.addQuestion(rec); |
| 94 | } | |
| 95 | 141 | return newOut; |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * Add an answer if it is not suppressed. | |
| 100 | * | |
| 101 | * @param out | |
| 102 | * outgoing message | |
| 103 | * @param in | |
| 104 | * incoming request | |
| 105 | * @param rec | |
| 106 | * DNS record answer | |
| 107 | * @return outgoing message for the next answer | |
| 108 | * @exception IOException | |
| 109 | */ | |
| 110 | 506 |
public DNSOutgoing addAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException { |
| 111 | 506 | DNSOutgoing newOut = out; |
| 112 | 505 | try { |
| 113 | 505 | newOut.addAnswer(in, rec); |
| 114 | } catch (final IOException e) { | |
| 115 | 0 | int flags = newOut.getFlags(); |
| 116 | 0 | boolean multicast = newOut.isMulticast(); |
| 117 | 0 | int maxUDPPayload = newOut.getMaxUDPPayload(); |
| 118 | 0 | int id = newOut.getId(); |
| 119 | ||
| 120 | 0 | newOut.setFlags(flags | DNSConstants.FLAGS_TC); |
| 121 | 0 | newOut.setId(id); |
| 122 | 0 | this._jmDNSImpl.send(newOut); |
| 123 | ||
| 124 | 0 | newOut = new DNSOutgoing(flags, multicast, maxUDPPayload); |
| 125 | 0 | newOut.addAnswer(in, rec); |
| 126 | } | |
| 127 | 505 | return newOut; |
| 128 | } | |
| 129 | ||
| 130 | /** | |
| 131 | * Add an answer to the message. | |
| 132 | * | |
| 133 | * @param out | |
| 134 | * outgoing message | |
| 135 | * @param rec | |
| 136 | * DNS record answer | |
| 137 | * @param now | |
| 138 | * @return outgoing message for the next answer | |
| 139 | * @exception IOException | |
| 140 | */ | |
| 141 | 18 |
public DNSOutgoing addAnswer(DNSOutgoing out, DNSRecord rec, long now) throws IOException { |
| 142 | 18 | DNSOutgoing newOut = out; |
| 143 | 18 | try { |
| 144 | 18 | newOut.addAnswer(rec, now); |
| 145 | } catch (final IOException e) { | |
| 146 | 0 | int flags = newOut.getFlags(); |
| 147 | 0 | boolean multicast = newOut.isMulticast(); |
| 148 | 0 | int maxUDPPayload = newOut.getMaxUDPPayload(); |
| 149 | 0 | int id = newOut.getId(); |
| 150 | ||
| 151 | 0 | newOut.setFlags(flags | DNSConstants.FLAGS_TC); |
| 152 | 0 | newOut.setId(id); |
| 153 | 0 | this._jmDNSImpl.send(newOut); |
| 154 | ||
| 155 | 0 | newOut = new DNSOutgoing(flags, multicast, maxUDPPayload); |
| 156 | 0 | newOut.addAnswer(rec, now); |
| 157 | } | |
| 158 | 18 | return newOut; |
| 159 | } | |
| 160 | ||
| 161 | /** | |
| 162 | * Add an authoritative answer to the message. | |
| 163 | * | |
| 164 | * @param out | |
| 165 | * outgoing message | |
| 166 | * @param rec | |
| 167 | * DNS record answer | |
| 168 | * @return outgoing message for the next answer | |
| 169 | * @exception IOException | |
| 170 | */ | |
| 171 | 141 |
public DNSOutgoing addAuthoritativeAnswer(DNSOutgoing out, DNSRecord rec) throws IOException { |
| 172 | 141 | DNSOutgoing newOut = out; |
| 173 | 141 | try { |
| 174 | 141 | newOut.addAuthorativeAnswer(rec); |
| 175 | } catch (final IOException e) { | |
| 176 | 0 | int flags = newOut.getFlags(); |
| 177 | 0 | boolean multicast = newOut.isMulticast(); |
| 178 | 0 | int maxUDPPayload = newOut.getMaxUDPPayload(); |
| 179 | 0 | int id = newOut.getId(); |
| 180 | ||
| 181 | 0 | newOut.setFlags(flags | DNSConstants.FLAGS_TC); |
| 182 | 0 | newOut.setId(id); |
| 183 | 0 | this._jmDNSImpl.send(newOut); |
| 184 | ||
| 185 | 0 | newOut = new DNSOutgoing(flags, multicast, maxUDPPayload); |
| 186 | 0 | newOut.addAuthorativeAnswer(rec); |
| 187 | } | |
| 188 | 141 | return newOut; |
| 189 | } | |
| 190 | ||
| 191 | /** | |
| 192 | * Add an additional answer to the record. Omit if there is no room. | |
| 193 | * | |
| 194 | * @param out | |
| 195 | * outgoing message | |
| 196 | * @param in | |
| 197 | * incoming request | |
| 198 | * @param rec | |
| 199 | * DNS record answer | |
| 200 | * @return outgoing message for the next answer | |
| 201 | * @exception IOException | |
| 202 | */ | |
| 203 | 0 |
public DNSOutgoing addAdditionalAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException { |
| 204 | 0 | DNSOutgoing newOut = out; |
| 205 | 0 | try { |
| 206 | 0 | newOut.addAdditionalAnswer(in, rec); |
| 207 | } catch (final IOException e) { | |
| 208 | 0 | int flags = newOut.getFlags(); |
| 209 | 0 | boolean multicast = newOut.isMulticast(); |
| 210 | 0 | int maxUDPPayload = newOut.getMaxUDPPayload(); |
| 211 | 0 | int id = newOut.getId(); |
| 212 | ||
| 213 | 0 | newOut.setFlags(flags | DNSConstants.FLAGS_TC); |
| 214 | 0 | newOut.setId(id); |
| 215 | 0 | this._jmDNSImpl.send(newOut); |
| 216 | ||
| 217 | 0 | newOut = new DNSOutgoing(flags, multicast, maxUDPPayload); |
| 218 | 0 | newOut.addAdditionalAnswer(in, rec); |
| 219 | } | |
| 220 | 0 | return newOut; |
| 221 | } | |
| 222 | ||
| 223 | } | |
|
||||||||||||