| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
package javax.jmdns.test; |
| 5 |
|
|
| 6 |
|
import static junit.framework.Assert.assertEquals; |
| 7 |
|
|
| 8 |
|
import java.util.Map; |
| 9 |
|
|
| 10 |
|
import javax.jmdns.ServiceInfo.Fields; |
| 11 |
|
import javax.jmdns.impl.ServiceInfoImpl; |
| 12 |
|
|
| 13 |
|
import org.junit.Before; |
| 14 |
|
import org.junit.Test; |
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (90) |
Complexity: 11 |
Complexity Density: 0.14 |
|
| 19 |
|
public class ServiceInfoTest { |
| 20 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 21 |
10
|
@Before... |
| 22 |
|
public void setup() { |
| 23 |
|
|
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
| 26 |
1
|
@Test... |
| 27 |
|
public void testDecodeQualifiedNameMap() { |
| 28 |
1
|
String domain = "test.com"; |
| 29 |
1
|
String protocol = "udp"; |
| 30 |
1
|
String application = "ftp"; |
| 31 |
1
|
String name = "My Service"; |
| 32 |
1
|
String subtype = "printer"; |
| 33 |
|
|
| 34 |
1
|
String type = "_" + application + "._" + protocol + "." + domain + "."; |
| 35 |
|
|
| 36 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMap(type, name, subtype); |
| 37 |
|
|
| 38 |
1
|
assertEquals("We did not get the right domain:", domain, map.get(Fields.Domain)); |
| 39 |
1
|
assertEquals("We did not get the right protocol:", protocol, map.get(Fields.Protocol)); |
| 40 |
1
|
assertEquals("We did not get the right application:", application, map.get(Fields.Application)); |
| 41 |
1
|
assertEquals("We did not get the right name:", name, map.get(Fields.Instance)); |
| 42 |
1
|
assertEquals("We did not get the right subtype:", subtype, map.get(Fields.Subtype)); |
| 43 |
|
} |
| 44 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1
PASS
|
|
| 45 |
1
|
@Test... |
| 46 |
|
public void testDecodeQualifiedNameMapDefaults() { |
| 47 |
1
|
String domain = "local"; |
| 48 |
1
|
String protocol = "tcp"; |
| 49 |
1
|
String application = "ftp"; |
| 50 |
1
|
String name = "My Service"; |
| 51 |
1
|
String subtype = ""; |
| 52 |
|
|
| 53 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMap(application, name, subtype); |
| 54 |
|
|
| 55 |
1
|
assertEquals("We did not get the right domain:", domain, map.get(Fields.Domain)); |
| 56 |
1
|
assertEquals("We did not get the right protocol:", protocol, map.get(Fields.Protocol)); |
| 57 |
1
|
assertEquals("We did not get the right application:", application, map.get(Fields.Application)); |
| 58 |
1
|
assertEquals("We did not get the right name:", name, map.get(Fields.Instance)); |
| 59 |
1
|
assertEquals("We did not get the right subtype:", subtype, map.get(Fields.Subtype)); |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 62 |
1
|
@Test... |
| 63 |
|
public void testDecodeServiceType() { |
| 64 |
1
|
String type = "_home-sharing._tcp.local."; |
| 65 |
|
|
| 66 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 67 |
|
|
| 68 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 69 |
1
|
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol)); |
| 70 |
1
|
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application)); |
| 71 |
1
|
assertEquals("We did not get the right name:", "", map.get(Fields.Instance)); |
| 72 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 73 |
|
|
| 74 |
|
} |
| 75 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 76 |
1
|
@Test... |
| 77 |
|
public void testDecodeServiceTCPType() { |
| 78 |
1
|
String type = "_afpovertcp._tcp.local."; |
| 79 |
|
|
| 80 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 81 |
|
|
| 82 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 83 |
1
|
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol)); |
| 84 |
1
|
assertEquals("We did not get the right application:", "afpovertcp", map.get(Fields.Application)); |
| 85 |
1
|
assertEquals("We did not get the right name:", "", map.get(Fields.Instance)); |
| 86 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 89 |
1
|
@Test... |
| 90 |
|
public void testDecodeServiceTypeWithSubType() { |
| 91 |
1
|
String type = "_00000000-0b44-f234-48c8-071c565644b3._sub._home-sharing._tcp.local."; |
| 92 |
|
|
| 93 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 94 |
|
|
| 95 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 96 |
1
|
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol)); |
| 97 |
1
|
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application)); |
| 98 |
1
|
assertEquals("We did not get the right name:", "", map.get(Fields.Instance)); |
| 99 |
1
|
assertEquals("We did not get the right subtype:", "00000000-0b44-f234-48c8-071c565644b3", map.get(Fields.Subtype)); |
| 100 |
|
} |
| 101 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 102 |
1
|
@Test... |
| 103 |
|
public void testDecodeServiceName() { |
| 104 |
1
|
String type = "My New Itunes Service._home-sharing._tcp.local."; |
| 105 |
|
|
| 106 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 107 |
|
|
| 108 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 109 |
1
|
assertEquals("We did not get the right protocol:", "tcp", map.get(Fields.Protocol)); |
| 110 |
1
|
assertEquals("We did not get the right application:", "home-sharing", map.get(Fields.Application)); |
| 111 |
1
|
assertEquals("We did not get the right name:", "My New Itunes Service", map.get(Fields.Instance)); |
| 112 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 113 |
|
} |
| 114 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 115 |
1
|
@Test... |
| 116 |
|
public void testDecodeDNSMetaQuery() { |
| 117 |
1
|
String type = "_services._dns-sd._udp.local."; |
| 118 |
|
|
| 119 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 120 |
|
|
| 121 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 122 |
1
|
assertEquals("We did not get the right protocol:", "udp", map.get(Fields.Protocol)); |
| 123 |
1
|
assertEquals("We did not get the right application:", "dns-sd", map.get(Fields.Application)); |
| 124 |
1
|
assertEquals("We did not get the right name:", "_services", map.get(Fields.Instance)); |
| 125 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 126 |
|
} |
| 127 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 128 |
1
|
@Test... |
| 129 |
|
public void testReverseDNSQuery() { |
| 130 |
1
|
String type = "100.50.168.192.in-addr.arpa."; |
| 131 |
|
|
| 132 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 133 |
|
|
| 134 |
1
|
assertEquals("We did not get the right domain:", "in-addr.arpa", map.get(Fields.Domain)); |
| 135 |
1
|
assertEquals("We did not get the right protocol:", "", map.get(Fields.Protocol)); |
| 136 |
1
|
assertEquals("We did not get the right application:", "", map.get(Fields.Application)); |
| 137 |
1
|
assertEquals("We did not get the right name:", "100.50.168.192", map.get(Fields.Instance)); |
| 138 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 139 |
|
} |
| 140 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 141 |
1
|
@Test... |
| 142 |
|
public void testAddress() { |
| 143 |
1
|
String type = "panoramix.local."; |
| 144 |
|
|
| 145 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 146 |
|
|
| 147 |
1
|
assertEquals("We did not get the right domain:", "local", map.get(Fields.Domain)); |
| 148 |
1
|
assertEquals("We did not get the right protocol:", "", map.get(Fields.Protocol)); |
| 149 |
1
|
assertEquals("We did not get the right application:", "", map.get(Fields.Application)); |
| 150 |
1
|
assertEquals("We did not get the right name:", "panoramix", map.get(Fields.Instance)); |
| 151 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 152 |
|
} |
| 153 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
| 154 |
1
|
@Test... |
| 155 |
|
public void testCasePreserving() { |
| 156 |
1
|
String type = "My New Itunes Service._Home-Sharing._TCP.Panoramix.local."; |
| 157 |
|
|
| 158 |
1
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 159 |
|
|
| 160 |
1
|
assertEquals("We did not get the right domain:", "Panoramix.local", map.get(Fields.Domain)); |
| 161 |
1
|
assertEquals("We did not get the right protocol:", "TCP", map.get(Fields.Protocol)); |
| 162 |
1
|
assertEquals("We did not get the right application:", "Home-Sharing", map.get(Fields.Application)); |
| 163 |
1
|
assertEquals("We did not get the right name:", "My New Itunes Service", map.get(Fields.Instance)); |
| 164 |
1
|
assertEquals("We did not get the right subtype:", "", map.get(Fields.Subtype)); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
} |