use of net.mm2d.upnp.SsdpNotifyReceiver.NotifyListener in project mmupnp by ohmae.
the class SsdpNotifyReceiverTest method onReceive_IOExceptionが発生してもクラッシュしない.
@Test
public void onReceive_IOExceptionが発生してもクラッシュしない() throws Exception {
final SsdpNotifyReceiver receiver = spy(new SsdpNotifyReceiver(Address.IP_V4, NetworkUtils.getAvailableInet4Interfaces().get(0)));
final InterfaceAddress address = TestUtils.createInterfaceAddress("192.0.2.1", "255.255.0.0", 24);
doReturn(address).when(receiver).getInterfaceAddress();
doThrow(new IOException()).when(receiver).createSsdpRequestMessage(ArgumentMatchers.any(byte[].class), anyInt());
final NotifyListener listener = mock(NotifyListener.class);
receiver.setNotifyListener(listener);
final byte[] data = TestUtils.getResourceAsByteArray("ssdp-notify-alive0.bin");
receiver.onReceive(InetAddress.getByName("192.0.2.2"), data, data.length);
verify(listener, never()).onReceiveNotify(ArgumentMatchers.any(SsdpRequest.class));
}
Aggregations