|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Canceler | Line # 22 | 23 | 0% | 14 | 10 | 74.4% |
0.74358976
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(21) | |||
Result | |||
0.74358976
|
javax.jmdns.test.JmDNSTest.testUnregisterService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.TextUpdateTest.testSubtype
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testRegisterServiceTwice
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testRegisterService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListMyService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testQueryMyService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListenForMyService
![]() |
1 PASS | |
0.74358976
|
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
![]() |
1 PASS | |
0.33333334
|
javax.jmdns.test.JmDNSTest.testCreate
![]() |
1 PASS | |
0.33333334
|
javax.jmdns.test.JmDNSTest.testCreateINet
![]() |
1 PASS | |
1 | // Copyright 2003-2005 Arthur van Hoff, Rick Blair | |
2 | // Licensed under Apache License version 2.0 | |
3 | // Original license LGPL | |
4 | ||
5 | package javax.jmdns.impl.tasks.state; | |
6 | ||
7 | import java.io.IOException; | |
8 | import java.util.Timer; | |
9 | import java.util.logging.Logger; | |
10 | ||
11 | import javax.jmdns.impl.DNSOutgoing; | |
12 | import javax.jmdns.impl.DNSRecord; | |
13 | import javax.jmdns.impl.JmDNSImpl; | |
14 | import javax.jmdns.impl.ServiceInfoImpl; | |
15 | import javax.jmdns.impl.constants.DNSConstants; | |
16 | import javax.jmdns.impl.constants.DNSRecordClass; | |
17 | import javax.jmdns.impl.constants.DNSState; | |
18 | ||
19 | /** | |
20 | * The Canceler sends two announces with TTL=0 for the specified services. | |
21 | */ | |
22 | public class Canceler extends DNSStateTask { | |
23 | static Logger logger = Logger.getLogger(Canceler.class.getName()); | |
24 | ||
25 | 33 |
![]() |
26 | 33 | super(jmDNSImpl, 0); |
27 | ||
28 | 33 | this.setTaskState(DNSState.CANCELING_1); |
29 | 33 | this.associate(DNSState.CANCELING_1); |
30 | } | |
31 | ||
32 | /* | |
33 | * (non-Javadoc) | |
34 | * @see javax.jmdns.impl.tasks.DNSTask#getName() | |
35 | */ | |
36 | 120 |
![]() |
37 | public String getName() { | |
38 | 120 | return "Canceler(" + (this.getDns() != null ? this.getDns().getName() : "") + ")"; |
39 | } | |
40 | ||
41 | /* | |
42 | * (non-Javadoc) | |
43 | * @see java.lang.Object#toString() | |
44 | */ | |
45 | 0 |
![]() |
46 | public String toString() { | |
47 | 0 | return super.toString() + " state: " + this.getTaskState(); |
48 | } | |
49 | ||
50 | /* | |
51 | * (non-Javadoc) | |
52 | * @see javax.jmdns.impl.tasks.DNSTask#start(java.util.Timer) | |
53 | */ | |
54 | 33 |
![]() |
55 | public void start(Timer timer) { | |
56 | 33 | timer.schedule(this, 0, DNSConstants.ANNOUNCE_WAIT_INTERVAL); |
57 | } | |
58 | ||
59 | /* | |
60 | * (non-Javadoc) | |
61 | * @see java.util.TimerTask#cancel() | |
62 | */ | |
63 | 33 |
![]() |
64 | public boolean cancel() { | |
65 | 33 | this.removeAssociation(); |
66 | ||
67 | 33 | return super.cancel(); |
68 | } | |
69 | ||
70 | /* | |
71 | * (non-Javadoc) | |
72 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#getTaskDescription() | |
73 | */ | |
74 | 120 |
![]() |
75 | public String getTaskDescription() { | |
76 | 120 | return "canceling"; |
77 | } | |
78 | ||
79 | /* | |
80 | * (non-Javadoc) | |
81 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#checkRunCondition() | |
82 | */ | |
83 | 73 |
![]() |
84 | protected boolean checkRunCondition() { | |
85 | 73 | return true; |
86 | } | |
87 | ||
88 | /* | |
89 | * (non-Javadoc) | |
90 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#createOugoing() | |
91 | */ | |
92 | 73 |
![]() |
93 | protected DNSOutgoing createOugoing() { | |
94 | 73 | return new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA); |
95 | } | |
96 | ||
97 | /* | |
98 | * (non-Javadoc) | |
99 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#buildOutgoingForDNS(javax.jmdns.impl.DNSOutgoing) | |
100 | */ | |
101 | 0 |
![]() |
102 | protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException { | |
103 | 0 | DNSOutgoing newOut = out; |
104 | 0 | for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.UNIQUE, this.getTTL())) { |
105 | 0 | newOut = this.addAnswer(newOut, null, answer); |
106 | } | |
107 | 0 | return newOut; |
108 | } | |
109 | ||
110 | /* | |
111 | * (non-Javadoc) | |
112 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#buildOutgoingForInfo(javax.jmdns.impl.ServiceInfoImpl, javax.jmdns.impl.DNSOutgoing) | |
113 | */ | |
114 | 60 |
![]() |
115 | protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException { | |
116 | 60 | DNSOutgoing newOut = out; |
117 | 60 | for (DNSRecord answer : info.answers(DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) { |
118 | 183 | newOut = this.addAnswer(newOut, null, answer); |
119 | } | |
120 | 60 | return newOut; |
121 | } | |
122 | ||
123 | /* | |
124 | * (non-Javadoc) | |
125 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#recoverTask(java.lang.Throwable) | |
126 | */ | |
127 | 0 |
![]() |
128 | protected void recoverTask(Throwable e) { | |
129 | 0 | this.getDns().recover(); |
130 | } | |
131 | ||
132 | /* | |
133 | * (non-Javadoc) | |
134 | * @see javax.jmdns.impl.tasks.state.DNSStateTask#advanceTask() | |
135 | */ | |
136 | 60 |
![]() |
137 | protected void advanceTask() { | |
138 | 60 | this.setTaskState(this.getTaskState().advance()); |
139 | 60 | if (!this.getTaskState().isCanceling()) { |
140 | 20 | cancel(); |
141 | } | |
142 | } | |
143 | } |
|