Search in sources :

Example 6 with ResponseListener

use of net.mm2d.upnp.SsdpSearchServer.ResponseListener in project mmupnp by ohmae.

the class SsdpSearchServerTest method onReceive_データに問題がある場合listenerコールされない.

@Test
public void onReceive_データに問題がある場合listenerコールされない() throws Exception {
    final NetworkInterface networkInterface = NetworkUtils.getAvailableInet4Interfaces().get(0);
    final SsdpSearchServer server = new SsdpSearchServer(Address.IP_V4, networkInterface);
    final ResponseListener listener = mock(ResponseListener.class);
    server.setResponseListener(listener);
    final InetAddress address = InetAddress.getByName("192.0.2.2");
    final byte[] data = new byte[0];
    server.onReceive(address, data, data.length);
    verify(listener, never()).onReceiveResponse(ArgumentMatchers.any(SsdpResponse.class));
}
Also used : NetworkInterface(java.net.NetworkInterface) ResponseListener(net.mm2d.upnp.SsdpSearchServer.ResponseListener) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 7 with ResponseListener

use of net.mm2d.upnp.SsdpSearchServer.ResponseListener in project mmupnp by ohmae.

the class SsdpSearchServerListTest method openAndStart.

@Test
public void openAndStart() throws Exception {
    final SsdpSearchServerList list = spy(new SsdpSearchServerList());
    final SsdpSearchServer server = mock(SsdpSearchServer.class);
    final ResponseListener listener = mock(ResponseListener.class);
    doReturn(server).when(list).newSsdpSearchServer(eq(Address.IP_V4), any(NetworkInterface.class), eq(listener));
    final NetworkInterface nif = NetworkUtils.getAvailableInet4Interfaces().get(0);
    list.init(Protocol.DEFAULT, Arrays.asList(nif), listener);
    list.openAndStart();
    verify(server, times(1)).open();
    verify(server, times(1)).start();
}
Also used : NetworkInterface(java.net.NetworkInterface) ResponseListener(net.mm2d.upnp.SsdpSearchServer.ResponseListener) Test(org.junit.Test)

Example 8 with ResponseListener

use of net.mm2d.upnp.SsdpSearchServer.ResponseListener in project mmupnp by ohmae.

the class SsdpSearchServerListTest method stop.

@Test
public void stop() {
    final SsdpSearchServerList list = spy(new SsdpSearchServerList());
    final SsdpSearchServer server = mock(SsdpSearchServer.class);
    final ResponseListener listener = mock(ResponseListener.class);
    doReturn(server).when(list).newSsdpSearchServer(eq(Address.IP_V4), any(NetworkInterface.class), eq(listener));
    final NetworkInterface nif = NetworkUtils.getAvailableInet4Interfaces().get(0);
    list.init(Protocol.DEFAULT, Arrays.asList(nif), listener);
    list.stop();
    verify(server, times(1)).stop();
}
Also used : NetworkInterface(java.net.NetworkInterface) ResponseListener(net.mm2d.upnp.SsdpSearchServer.ResponseListener) Test(org.junit.Test)

Example 9 with ResponseListener

use of net.mm2d.upnp.SsdpSearchServer.ResponseListener in project mmupnp by ohmae.

the class SsdpSearchServerListTest method close.

@Test
public void close() {
    final SsdpSearchServerList list = spy(new SsdpSearchServerList());
    final SsdpSearchServer server = mock(SsdpSearchServer.class);
    final ResponseListener listener = mock(ResponseListener.class);
    doReturn(server).when(list).newSsdpSearchServer(eq(Address.IP_V4), any(NetworkInterface.class), eq(listener));
    final NetworkInterface nif = NetworkUtils.getAvailableInet4Interfaces().get(0);
    list.init(Protocol.DEFAULT, Arrays.asList(nif), listener);
    list.close();
    verify(server, times(1)).close();
}
Also used : NetworkInterface(java.net.NetworkInterface) ResponseListener(net.mm2d.upnp.SsdpSearchServer.ResponseListener) Test(org.junit.Test)

Aggregations

ResponseListener (net.mm2d.upnp.SsdpSearchServer.ResponseListener)9 Test (org.junit.Test)9 NetworkInterface (java.net.NetworkInterface)8 InetAddress (java.net.InetAddress)4 IOException (java.io.IOException)1 InterfaceAddress (java.net.InterfaceAddress)1