FileDocCategorySizeDatePackage
NsdServiceInfoTest.javaAPI DocAndroid 5.1 API6273Thu Mar 12 22:22:42 GMT 2015android.core

NsdServiceInfoTest

public class NsdServiceInfoTest extends android.test.AndroidTestCase

Fields Summary
public static final InetAddress
LOCALHOST
Constructors Summary
Methods Summary
public voidassertEmptyServiceInfo(android.net.nsd.NsdServiceInfo shouldBeEmpty)

        assertTrue(null == shouldBeEmpty.getTxtRecord());
    
public voidassertEquality(java.lang.Object expected, java.lang.Object result)

        assertTrue(expected == result || expected.equals(result));
    
public voidcheckParcelable(android.net.nsd.NsdServiceInfo original)

        // Write to parcel.
        Parcel p = Parcel.obtain();
        Bundle writer = new Bundle();
        writer.putParcelable("test_info", original);
        writer.writeToParcel(p, 0);

        // Extract from parcel.
        p.setDataPosition(0);
        Bundle reader = p.readBundle();
        reader.setClassLoader(NsdServiceInfo.class.getClassLoader());
        NsdServiceInfo result = reader.getParcelable("test_info");

        // Assert equality of base fields.
        assertEquality(original.getServiceName(), result.getServiceName());
        assertEquality(original.getServiceType(), result.getServiceType());
        assertEquality(original.getHost(), result.getHost());
        assertTrue(original.getPort() == result.getPort());

        // Assert equality of attribute map.
        Map<String, byte[]> originalMap = original.getAttributes();
        Map<String, byte[]> resultMap = result.getAttributes();
        assertEquality(originalMap.keySet(), resultMap.keySet());
        for (String key : originalMap.keySet()) {
            assertTrue(Arrays.equals(originalMap.get(key), resultMap.get(key)));
        }
    
public voidtestLimits()

        // Because test.
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);

        InetAddress _host = null;
        try {
            _host = InetAddress.getLocalHost();
        } catch (UnknownHostException e) { }
        LOCALHOST = _host;
    
        NsdServiceInfo info = new NsdServiceInfo();

        // Non-ASCII keys.
        boolean exceptionThrown = false;
        try {
            info.setAttribute("ç