|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ServiceResolver | Line # 23 | 12 | 0% | 6 | 6 | 68.4% |
0.68421054
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (17) | |||
| Result | |||
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testUnregisterService
javax.jmdns.test.JmDNSTest.testUnregisterService
|
1 PASS | |
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
|
1 PASS | |
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
|
1 PASS | |
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testListMyService
javax.jmdns.test.JmDNSTest.testListMyService
|
1 PASS | |
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
|
1 PASS | |
|
0.68421054
|
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
|
1 PASS | |
|
0.6315789
|
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
|
1 PASS | |
|
0.6315789
|
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
|
1 PASS | |
|
0.6315789
|
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.TextUpdateTest.testSubtype
javax.jmdns.test.TextUpdateTest.testSubtype
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.JmDNSTest.testListenForMyService
javax.jmdns.test.JmDNSTest.testListenForMyService
|
1 PASS | |
|
0.36842105
|
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
|
1 PASS | |
|
0.15789473
|
javax.jmdns.test.JmDNSTest.testQueryMyService
javax.jmdns.test.JmDNSTest.testQueryMyService
|
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.resolver; | |
| 6 | ||
| 7 | import java.io.IOException; | |
| 8 | ||
| 9 | import javax.jmdns.ServiceInfo; | |
| 10 | import javax.jmdns.impl.DNSOutgoing; | |
| 11 | import javax.jmdns.impl.DNSQuestion; | |
| 12 | import javax.jmdns.impl.DNSRecord; | |
| 13 | import javax.jmdns.impl.JmDNSImpl; | |
| 14 | import javax.jmdns.impl.constants.DNSConstants; | |
| 15 | import javax.jmdns.impl.constants.DNSRecordClass; | |
| 16 | import javax.jmdns.impl.constants.DNSRecordType; | |
| 17 | ||
| 18 | /** | |
| 19 | * The ServiceResolver queries three times consecutively for services of a given type, and then removes itself from the timer. | |
| 20 | * <p/> | |
| 21 | * The ServiceResolver will run only if JmDNS is in state ANNOUNCED. REMIND: Prevent having multiple service resolvers for the same type in the timer queue. | |
| 22 | */ | |
| 23 | public class ServiceResolver extends DNSResolverTask { | |
| 24 | ||
| 25 | private final String _type; | |
| 26 | ||
| 27 | 28 |
public ServiceResolver(JmDNSImpl jmDNSImpl, String type) { |
| 28 | 28 | super(jmDNSImpl); |
| 29 | 28 | this._type = type; |
| 30 | } | |
| 31 | ||
| 32 | /* | |
| 33 | * (non-Javadoc) | |
| 34 | * @see javax.jmdns.impl.tasks.DNSTask#getName() | |
| 35 | */ | |
| 36 | 0 |
@Override |
| 37 | public String getName() { | |
| 38 | 0 | return "ServiceResolver(" + (this.getDns() != null ? this.getDns().getName() : "") + ")"; |
| 39 | } | |
| 40 | ||
| 41 | /* | |
| 42 | * (non-Javadoc) | |
| 43 | * @see javax.jmdns.impl.tasks.Resolver#addAnswers(javax.jmdns.impl.DNSOutgoing) | |
| 44 | */ | |
| 45 | 33 |
@Override |
| 46 | protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException { | |
| 47 | 33 | DNSOutgoing newOut = out; |
| 48 | 33 | long now = System.currentTimeMillis(); |
| 49 | 33 | for (ServiceInfo info : this.getDns().getServices().values()) { |
| 50 | 18 | newOut = this.addAnswer(newOut, new DNSRecord.Pointer(info.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getQualifiedName()), now); |
| 51 | // newOut = this.addAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(), | |
| 52 | // this.getDns().getLocalHost().getName()), now); | |
| 53 | } | |
| 54 | 33 | return newOut; |
| 55 | } | |
| 56 | ||
| 57 | /* | |
| 58 | * (non-Javadoc) | |
| 59 | * @see javax.jmdns.impl.tasks.Resolver#addQuestions(javax.jmdns.impl.DNSOutgoing) | |
| 60 | */ | |
| 61 | 81 |
@Override |
| 62 | protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException { | |
| 63 | 81 | DNSOutgoing newOut = out; |
| 64 | 81 | newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_type, DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
| 65 | // newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_type, DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); | |
| 66 | 81 | return newOut; |
| 67 | } | |
| 68 | ||
| 69 | /* | |
| 70 | * (non-Javadoc) | |
| 71 | * @see javax.jmdns.impl.tasks.Resolver#description() | |
| 72 | */ | |
| 73 | 0 |
@Override |
| 74 | protected String description() { | |
| 75 | 0 | return "querying service"; |
| 76 | } | |
| 77 | } | |
|
||||||||||||