当前位置: 首页>>代码示例>>Java>>正文


Java JmmDNS.close方法代码示例

本文整理汇总了Java中javax.jmdns.JmmDNS.close方法的典型用法代码示例。如果您正苦于以下问题:Java JmmDNS.close方法的具体用法?Java JmmDNS.close怎么用?Java JmmDNS.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jmdns.JmmDNS的用法示例。


在下文中一共展示了JmmDNS.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateINet

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testCreateINet() throws IOException {
    System.out.println("Unit Test: testCreateINet()");
    JmmDNS registry = JmmDNS.Factory.getInstance();
    // assertEquals("We did not register on the local host inet:", InetAddress.getLocalHost(), registry.getInterface());
    registry.close();
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:8,代码来源:JmmDNSTest.java

示例2: testRegisterService

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testRegisterService() throws IOException {
    System.out.println("Unit Test: testRegisterService()");
    JmmDNS registry = null;
    try {
        registry = JmmDNS.Factory.getInstance();
        registry.registerService(service);

        ServiceInfo[] services = registry.list(service.getType());
        assertTrue("We should see the service we just registered: ", services.length > 0);
        assertEquals(service, services[0]);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:16,代码来源:JmmDNSTest.java

示例3: testQueryMyService

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testQueryMyService() throws IOException {
    System.out.println("Unit Test: testQueryMyService()");
    JmmDNS registry = null;
    try {
        registry = JmmDNS.Factory.getInstance();
        registry.registerService(service);

        ServiceInfo[] queriedService = registry.getServiceInfos(service.getType(), service.getName());
        assertTrue("We expect to see the service we just registered", queriedService.length > 0);
        assertEquals(service, queriedService[0]);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:16,代码来源:JmmDNSTest.java

示例4: testListMyService

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testListMyService() throws IOException {
    System.out.println("Unit Test: testListMyService()");
    JmmDNS registry = null;
    try {
        registry = JmmDNS.Factory.getInstance();
        registry.registerService(service);

        ServiceInfo[] services = registry.list(service.getType());
        assertTrue("We should see the service we just registered: ", services.length > 0);
        assertEquals(service, services[0]);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:16,代码来源:JmmDNSTest.java

示例5: testListenForMyServiceAndList

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testListenForMyServiceAndList() throws IOException {
    System.out.println("Unit Test: testListenForMyServiceAndList()");
    JmmDNS registry = null;
    try {
        Capture<ServiceEvent> capServiceAddedEvent = new Capture<ServiceEvent>();
        Capture<ServiceEvent> capServiceResolvedEvent = new Capture<ServiceEvent>();
        // Expect the listener to be called once and capture the result
        serviceListenerMock.serviceAdded(capture(capServiceAddedEvent));
        serviceListenerMock.serviceResolved(capture(capServiceResolvedEvent));
        replay(serviceListenerMock);

        registry = JmmDNS.Factory.getInstance();
        registry.addServiceListener(service.getType(), serviceListenerMock);
        registry.registerService(service);

        // We get the service added event when we register the service. However the service has not been resolved at this point.
        // The info associated with the event only has the minimum information i.e. name and type.
        assertTrue("We did not get the service added event.", capServiceAddedEvent.hasCaptured());

        ServiceInfo info = capServiceAddedEvent.getValue().getInfo();
        assertEquals("We did not get the right name for the resolved service:", service.getName(), info.getName());
        assertEquals("We did not get the right type for the resolved service:", service.getType(), info.getType());

        // This will force the resolution of the service which in turn will get the listener called with a service resolved event.
        // The info associated with a service resolved event has all the information available.
        // Which in turn populates the ServiceInfo opbjects returned by JmmDNS.list.
        ServiceInfo[] services = registry.list(info.getType());
        assertTrue("We did not get the expected number of services: ", services.length > 0);
        assertEquals("The service returned was not the one expected", service, services[0]);

        assertTrue("We did not get the service resolved event.", capServiceResolvedEvent.hasCaptured());
        verify(serviceListenerMock);
        ServiceInfo resolvedInfo = capServiceResolvedEvent.getValue().getInfo();
        assertEquals("Did not get the expected service info: ", service, resolvedInfo);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:40,代码来源:JmmDNSTest.java

示例6: testCreate

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testCreate() throws IOException {
    System.out.println("Unit Test: testCreate()");
    JmmDNS registry = JmmDNS.Factory.getInstance();
    registry.close();
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:7,代码来源:JmmDNSTest.java

示例7: testListenForMyService

import javax.jmdns.JmmDNS; //导入方法依赖的package包/类
@Test
public void testListenForMyService() throws IOException {
    System.out.println("Unit Test: testListenForMyService()");
    JmmDNS registry = null;
    try {
        Capture<ServiceEvent> capServiceAddedEvent = new Capture<ServiceEvent>();
        Capture<ServiceEvent> capServiceResolvedEvent = new Capture<ServiceEvent>();
        // Add an expectation that the listener interface will be called once capture the object so I can verify it separately.
        serviceListenerMock.serviceAdded(capture(capServiceAddedEvent));
        serviceListenerMock.serviceResolved(capture(capServiceResolvedEvent));
        EasyMock.replay(serviceListenerMock);
        // EasyMock.makeThreadSafe(serviceListenerMock, false);

        registry = JmmDNS.Factory.getInstance();

        registry.addServiceListener(service.getType(), serviceListenerMock);

        registry.registerService(service);

        // We get the service added event when we register the service. However the service has not been resolved at this point.
        // The info associated with the event only has the minimum information i.e. name and type.
        assertTrue("We did not get the service added event.", capServiceAddedEvent.hasCaptured());
        ServiceInfo info = capServiceAddedEvent.getValue().getInfo();
        assertEquals("We did not get the right name for the added service:", service.getName(), info.getName());
        assertEquals("We did not get the right type for the added service:", service.getType(), info.getType());
        assertEquals("We did not get the right fully qualified name for the added service:", service.getQualifiedName(), info.getQualifiedName());

        // assertEquals("We should not get the server for the added service:", "", info.getServer());
        // assertEquals("We should not get the address for the added service:", null, info.getAddress());
        // assertEquals("We should not get the HostAddress for the added service:", "", info.getHostAddress());
        // assertEquals("We should not get the InetAddress for the added service:", null, info.getInetAddress());
        // assertEquals("We should not get the NiceTextString for the added service:", "", info.getNiceTextString());
        // assertEquals("We should not get the Priority for the added service:", 0, info.getPriority());
        // assertFalse("We should not get the PropertyNames for the added service:", info.getPropertyNames().hasMoreElements());
        // assertEquals("We should not get the TextBytes for the added service:", 0, info.getTextBytes().length);
        // assertEquals("We should not get the TextString for the added service:", null, info.getTextString());
        // assertEquals("We should not get the Weight for the added service:", 0, info.getWeight());
        // assertNotSame("We should not get the URL for the added service:", "", info.getURL());

        registry.requestServiceInfo(service.getType(), service.getName());

        assertTrue("We did not get the service resolved event.", capServiceResolvedEvent.hasCaptured());
        verify(serviceListenerMock);
        ServiceInfo resolvedInfo = capServiceResolvedEvent.getValue().getInfo();
        assertEquals("Did not get the expected service info: ", service, resolvedInfo);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:50,代码来源:JmmDNSTest.java


注:本文中的javax.jmdns.JmmDNS.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。